user555910
user555910

Reputation: 2667

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 ListViewand set the value of ListView in an EditText.

Upvotes: 1

Views: 5172

Answers (3)

Rajesh Chandra
Rajesh Chandra

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

9nix00
9nix00

Reputation: 4082

View curr = adapter.getView(getSelectedItemPosition(),null,null);
TextView c = (TextView)curr.findViewById(R.id.detail);

Upvotes: 0

ninjasense
ninjasense

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

Related Questions