我想做的是将单击的项目的文本设置为myEditText。虽然不确定如何访问ListView中的特定项目...

    ListView myListView = (ListView)findViewById(R.id.myListView);
    final EditText myEditText = (EditText)findViewById(R.id.myEditText);
    ...
    myListView.setAdapter(aa);

    myListView.setOnClickListener(new OnClickListener(){
        public void onClick(View v){
            myEditText.setText("You clicked something!");
        }
    });

最佳答案

我是新手,但最近做了这个,所以,如果您能理解我的代码段,则如下所示:

setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, array_of_something));

ListView lv = getListView();
lv.setTextFilterEnabled(true);

lv.setOnItemClickListener(new OnItemClickListener() {

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int arg2, long arg3) {

        String item_clicked_on = (String)((TextView) view).getText();

        }
      });


也许有帮助吗?

07-25 22:19