开发者

How to get the value from the listview

开发者 https://www.devze.com 2023-02-10 01:58 出处:网络
How to get the value fromthe 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:

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

精彩评论

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