OnItemCLickListener not working in listview

前端 未结 24 2274
悲&欢浪女
悲&欢浪女 2020-11-22 11:21

Activity class code:

conversationList = (ListView)findViewById(android.R.id.list);
ConversationArrayAdapter conversationArrayAdapter=new  Conver         


        
24条回答
  •  执笔经年
    2020-11-22 11:48

    The thing that worked for me was to add the below code to every subview inside the layout of my row.xml file:

    android:focusable="false"
    android:focusableInTouchMode="false"
    

    So in my case:

    
    
    
    
        
    
        
    
        
    
        
    
        
    
    
    

    And this is my setOnItemClickListener call in my Fragment subclass:

    CustomListView = (PullToRefreshListCustomView) layout.findViewById(getListResourceID());
            CustomListView.setAdapter(customAdapter);
            CustomListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    
                @Override
                public void onItemClick(AdapterView parent, View view, int position, long id) {
                    Log.d("Testing", "onitem click working");
                  //  other code
                }
    
            });
    

    I got the answer from here!

提交回复
热议问题