Sunday, November 18, 2012

How to get correct position of list item when custom list button clicked

use setTag attribute of the View..............

use this button code in getView() method
Button call = (Button) rowView.findViewById(;

and after that directly use onClick listner for that listview item button
call.setOnClickListener(new OnClickListener() {

      public void onClick(View v) {
         int which = -1;
         Obejct obj =  v.getTag();
         if(obj instaceof Integer){
         which  = ((Integer)obj).intValue();

      if(which >-1){
      //write code here to get value from any way using position means which
      Toast.makeText(getContext(), "Current clicked position is : "+which, 1).show();

Reference from:

No comments:

Post a Comment