actually I\'ve read some previous questions about this...
this is the code that I use
auto = (ListView)findViewById(R.id.auto);
String[] projection =
I think one more best approach is there.You can add one tag as position with the button using (button.setTag()) method and whenever user will click button just take the tag of this button. it will more easy.
Thanks and Regards Rahul
Very Simple. In your Adapter class getView
method change int position to final int position.
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = inflater.inflate(yourcustomizeditemview.xml, parent,
false);
Button btn= (Button) row.findViewById(R.id.btn);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(context, " "+position, Toast.LENGTH_SHORT).show();
}
});
return row;
}
now on Button
click Toast
shows the position of item in which Button
is present.