私はと追加ボタンを含むLinearLayout
を動的に作成しました。位置を決定するための動的な膨張表示
Webサービスによっては、LinearLayout
に2つ、3つのボタンなどがあります。
わかりやすくするために、私はを動的に膨らませて、EditTexts
と追加ボタンを持っているとしましょう。
さて、私は3つのWebサービスがあります。
- は、addData
- のgetData
- editData
我々は我々を追加するときは、addData Webサービスは、Webサーバーにデータを追加するために使用され、 getData webserviceを使用してデータを取得できます。 addData Webサービスで、私は、AddボタンとgetDataをPositionIndexで押しながら、LinearLayout
の位置インデックスをEditText
のテキストで渡しています。
[{"truckNo":"truck2_no","driverName":"driver2_name","driverMobile":"driver2_mobile","driverLicense":"driver2_license","placeOfIssue":"place2_of_issue","id":3,"positionIndex":1},{"truckNo":"ggg","driverName":"ggg","driverMobile":"vvh","driverLicense":" vv","placeOfIssue":"vvg","id":4,"positionIndex":3}]
のgetData Webサービス上positionIndexに嘘ならば、私は、対応する位置のデータを編集することができます。つまり、positionIndexが3の場合、JSONで確認できるように位置3のみを編集できます。位置1と位置3を編集してLinearLayout
を膨張させることができますが、位置2ではaddData Webサービスを使用する必要があります。
問題:私は、WebサービスからのgetDataを使用する場合 は、私が編集可能であるデータを区別することができませんし、1、私は位置に応じて追加する必要があります。ボタンのコードを追加打つオン
:
if(truckDetailList!=null && truckDetailList.size()>0) {
for(int k=0;k<truckDetailList.size();k++) {
Log.e("id--->>",""+(view1.getId()+1)+"");
Log.e("truckDetailList-->>",""+truckDetailList.get(k).getTruck_index_position());
int getTruckPosition=truckDetailList.get(k).getTruck_index_position();
if(getTruckPosition==(view1.getId()+1)) {
//Log.e("",""+truck_nmbr_autocmplt.getText().toString(), driverNames, driverMobiles, driverLicncs, plcOfIssues, truckDetailList.get(view1.getId()).getId(), truck_nmbr_autocmplt, driverName, driverMobile, driverLicnc, plcOfIssue)
editTruckDetail(truck_nmbr_autocmplt.getText().toString(), driverNames, driverMobiles, driverLicncs, plcOfIssues, truckDetailList.get(k).getId(), truck_nmbr_autocmplt, driverName, driverMobile, driverLicnc, plcOfIssue);
break;
}
else {
postTruckDetailToServer(truck_nmbr_autocmplt.getText().toString(), driverNames, driverMobiles, driverLicncs, plcOfIssues, subID, supplierResponse, truck_nmbr_autocmplt, driverName, driverMobile, driverLicnc, plcOfIssue, position_index);
break;
}
}
}
else {
postTruckDetailToServer(truck_nmbr_autocmplt.getText().toString(), driverNames, driverMobiles, driverLicncs, plcOfIssues, subID, supplierResponse, truck_nmbr_autocmplt, driverName, driverMobile, driverLicnc, plcOfIssue, position_index);
}