Can't click on items in ListView with custom adapter

前端 未结 5 2209
梦谈多话
梦谈多话 2020-12-17 09:42

I am trying to write an application which takes items from a database and populates rows within a ListView. I can\'t click on the items after tapping on the rows and the dpa

5条回答
  •  清歌不尽
    2020-12-17 10:20

    I usually put the click listener in the adapter itself:

    @Override
          public View getView(int position, View convertView, ViewGroup parent) {
    
            OnClickListener yourClickListener = new OnClickListener() {
                  public void onClick(View v) {
                    //put your desired action here
                    v.callOnClick();
                  }
              };
    
        ...
    
        // then add the listener to your view
        tweetView.setOnClickListener(yourClickListener);
    

提交回复
热议问题