我试图在这里从不同的类似问题中得到答案,但没有得到任何答案。实际上,我正在尝试从任何列表视图项的多个文本视图中获取值。这是代码
ListView listView = getListView();
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int postion, long id) {
String contactId = ((TextView) findViewById(R.id.cid)).getText().toString();
String contactName= ((TextView) findViewById(R.id.contactName)).getText().toString();
String contactNo= ((TextView) findViewById(R.id.contactNo)).getText().toString();
Intent i = new Intent(getApplicationContext(), editContactActivity.class);
i.putExtra(TAG_ID, contactId );
i.putExtra(TAG_NAME, contactName);
i.putExtra(TAG_CONTACT_NO, contactNo);
startActivityForResult(i, 100);
}
});
我得到什么结果,我在 listview 中获得第一项(位置)的 textviews 值,或者我正在单击任何项目,但我在 listview 中获得第一项(位置)的 textviews 值,这是我如何获取值的代码在其他活动上
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edit_contact);
btnSave = (Button) findViewById(R.id.btnSaveContact);
btnDelete = (Button) findViewById(R.id.btnDeleteContact);
Intent i = getIntent();
cId = i.getStringExtra(TAG_CONTACT_ID);
cNameTxt = i.getStringExtra(TAG_CONTACT_NAME);
cNumberTxt = i.getStringExtra(TAG_CONTACT_NUMBER);
//Log.d("Value of contact name", cNameTxt);
//Log.d("Value of contact name", cNumberTxt);
TextView contactIdTxtView = (TextView) findViewById(R.id.cid);
cName = (EditText) findViewById(R.id.editCName);
cNumber = (EditText) findViewById(R.id.editCNumber);
cName.setText(cId);
cNumber.setText(cNumberTxt);
}
如果有人能提供详细帮助,我将不胜感激。感谢 Akmal Rasool