How to get the selected item from ListView?

前端 未结 9 701
我寻月下人不归
我寻月下人不归 2020-11-29 03:26

in my Android app I have created a ListView component called myList, and filled it with objects of my own custom type:

class MyClass{

    private String di         


        
9条回答
  •  南方客
    南方客 (楼主)
    2020-11-29 04:02

    myList.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView adapter, View v, int position, long id) {
          MyClass selItem = (MyClass) adapter.getItem(position);
       }
    }
    

提交回复
热议问题