我有一个应用程序,其中有两个下拉列表。第一个是#34;社会"第二个用于"门牌号码"。 "门牌号码"下拉列表基于" Society"地选择。
我面临的问题是,在很少的电话中,当用户选择" House Number"," Society"下拉列表重置为空白值。我不明白这是怎么可能的,因为我还没有更新社会对门牌号码选择的下拉,这种情况只发生在我测试过的近100部电话中。
这是我的代码。
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// Check which request we're responding to
if (requestCode == Society_REQUEST) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// The user picked a contact.
// The Intent's data Uri identifies which contact was selected.
try {
String cityObj = data.getExtras().getString("cityObj");
CommonClass.writelog(tag,
"onActivityResult()102 Reqestcode:" + requestCode
+ " ResultCode:" + resultCode + " data:"
+ data.getStringExtra("cityObj"));
try {
JSONObject cObj = new JSONObject(cityObj);
// common.setSession("selected_city_id",cObj.getString("Id"));
TextView txtSocity = (TextView) findViewById(R.id.txtSocity);
CommonClass
.writelog(tag,
"onActivityResult()109:Society_REQUEST: txtSocity TextView Variable Create:");
txtSocity.setText(cObj.getString("Name"));
CommonClass.writelog(tag,
"onActivityResult()111:Society_REQUEST: txtSocity.setText:"
+ cObj.getString("Name")
+ " txtSocity.getText:"
+ txtSocity.getText().toString());
socity_id = cObj.getString("Id");
CommonClass.writelog(tag,
"onActivityResult()114:Society_REQUEST: socity_id:"
+ cObj.getString("Id"));
} catch (JSONException e) {
CommonClass.writelog(
tag,
"onActivityResult()117:Society_REQUEST: Reqestcode:"
+ requestCode + " ResultCode:"
+ resultCode + " data:"
+ data.getStringExtra("cityObj") + "\n"
+ e.getMessage());
e.printStackTrace();
}
// Do something with the contact here (bigger example below)
} catch (Exception ex) {
String cityObj = data.getExtras().getString("cityObjOther");
CommonClass.writelog(
tag,
"onActivityResult()102 Reqestcode:" + requestCode
+ " data:"
+ data.getStringExtra("cityObjOther"));
try {
flg = 1;
String[] tmep = cityObj.split("##");
TextView txtSocity = (TextView) findViewById(R.id.txtSocity);
txtSocity.setText(tmep[1].toString());
socity_id = tmep[0].toString();
} catch (Exception e) {
e.printStackTrace();
}
}
}
} else if (requestCode == Homeno_REQUEST) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// Make sure the request was successful
if (resultCode == RESULT_OK) {
// The user picked a contact.
// The Intent's data Uri identifies which contact was
// selected.
try {
String cityObj1 = data.getExtras().getString("homeObj");
try {
JSONObject cObj = new JSONObject(cityObj1);
TextView txtHomeNo = (TextView) findViewById(R.id.txtHomeno);
txtHomeNo.setText(cObj.getString("Name"));
home_id = cObj.getString("Id");
} catch (JSONException e) {
e.printStackTrace();
}
// Do something with the contact here (bigger example
// below)
} catch (Exception ex) {
String cityObj = data.getExtras().getString(
"homeObjOther");
try {
flg = 1;
String[] tmep = cityObj.split("##");
TextView txtHomeNo = (TextView) findViewById(R.id.txtHomeno);
txtHomeNo.setText(tmep[1].toString());
home_id = tmep[0].toString();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
listView.setAdapter(selectHomenoAdapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Intent returnIntent = getIntent();
returnIntent.putExtra("homeObj",
selectHomenoAdapter.getItem(position).toString());
setResult(RESULT_OK, returnIntent);
finish();
}
});
}