actually I\'ve read some previous questions about this...
this is the code that I use
auto = (ListView)findViewById(R.id.auto);
String[] projection =
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.