How to get the value from the listview
How to get the value from the ListView
,
i.e when an list item is clicked 开发者_高级运维it sends the data from the ListView
and set the value of ListView
in an EditText
.
Try this:
listview.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Toast.makeText(<Your Class Name>.this,
"posisiton: "+position+" "+"Id: "+id, Toast.LENGTH_SHORT).show();
}
});
Something like this:
list.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView parentView, View childView, int position, long id) {
String str = ((TextView)childView).getText().toString();
(EditText)findViewById(R.id.EditText01).setText(str);
}
});
This thread and this thread should help
View curr = adapter.getView(getSelectedItemPosition(),null,null);
TextView c = (TextView)curr.findViewById(R.id.detail);
精彩评论