Reputation: 2667
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
.
Upvotes: 1
Views: 5172
Reputation: 11
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();
}
});
Upvotes: 1
Reputation: 4082
View curr = adapter.getView(getSelectedItemPosition(),null,null);
TextView c = (TextView)curr.findViewById(R.id.detail);
Upvotes: 0
Reputation: 13856
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
Upvotes: 0