ListView and Buttons inside ListView

后端 未结 5 2248
花落未央
花落未央 2020-11-29 00:54

I want to display a Button inside the ListView. The goal should be to click on the ListView line or on the button.

Click on th

5条回答
  •  清酒与你
    2020-11-29 01:05

    In my case i had to add this attribute in the listView :

    
    

    And in the adapter just add on click listener in the button view.

    wrapper.getButtonHi().setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                DebugUtils.logDebug("Clickeado :: "+ mContact.getUserId());
            }
    });
    

    Its important to set final the variables:

    public View getRowView(final int position, View convertView, ViewGroup parent) {
        final BrowseContactItemWrapper wrapper;
        final UserModel mContact = lstContact.get(position);
        .....
    }
    

提交回复
热议问题