开发者

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.


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜