在我的应用程序中,我希望当我从列表中选择一个特定项目时,它会给出它的保存数据,因为每个项目都是一个包含一些数据的字段。我怎样才能做到这一点???
我的Java代码是:
public void Onclick_click4(final TextView task_detail_txt)
{
final TextView txtbox = (TextView) task_detail_txt ;
if(task_detail_txt.getId()==R.id.textView4)
{
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Task Details");
ListView modeList = new ListView(this);
final String[] stringArray = new String[] { "Ticket Number", "Job Performed", "Date and Time", "GPS-Latitude", "GPS-Longitude", "Status", "Next Due on" };
ArrayAdapter<String> modeAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, stringArray);
modeList.setAdapter(modeAdapter);
builder.setItems(stringArray, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(getApplicationContext(), stringArray[item], Toast.LENGTH_SHORT).show();
txtbox.setText(stringArray[item]);
System.out.println("Item is: "+stringArray[item]);
/*CONTRY_ID = con.get(item).getCountryId();
stateET.requestFocus();*/
}
});
builder.show();
}
}
正如我想要的那样,当我点击票号时,它会给我保存在另一个活动中的号码。ETC