+ Reply to Thread
Results 1 to 2 of 2

Thread: Listener of Button Inside Listview not Working - Android

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    8

    Listener of Button Inside Listview not Working - Android

    I have a ListView that contains a TextView and a RelativeLayout with 5 buttons (visibility:gone). When I click in the TextView it shows that RelativeLayout. My problem is, the setOnclickListener() of those buttons are not working. They were supposed to start another Activity onClick. The Listener of the Listiview works fine, my problem is the listeners of buttons.

    Here's my layout

    The buttons below "Text later" are the ones that are not working.

    EDIT: It only works for the last item of the last filter.

    Thanks.

  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    14
    Code:
    convertView.setOnClickListener(new OnClickListener() {
       private int pos = position;
    
       @Override
       public void onClick(View v) {
           Toast.makeText(context, "Click-" + String.valueOf(pos), Toast.LENGTH_SHORT).show();   
       }
    });
    
    holder.buttonLine.setOnClickListener(new OnClickListener() {
        private int pos = position;
    
        @Override
        public void onClick(View v) {
           Toast.makeText(context, "Delete-" + String.valueOf(pos), Toast.LENGTH_SHORT).show();
        }
    });

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts