I have a listview with textView and a button in each line, i'm trying to get the text by clicking on the button not by clicking the whole line but the adapterView method:(AdapterView arg0, View v,int position, long arg3) is not working for buttons click.
public View getView(int position, View convertView, ViewGroup parent) {
//Set the view for each item in the list view
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.employeeitem, null);
}
//Get the Textviews from the row view and set the appropriate values for them
TextView labelName=(TextView) v.findViewById(R.id.labelName);
TextView labelAddress=(TextView)v.findViewById(R.id.labelAddress);
TextView labelImmat=(TextView)v.findViewById(R.id.labelImmat);
labelName.setText(array[position].marque);
labelAddress.setText(array[position].categorie);
labelImmat.setText(array[position].Prix_Achats);
return v;
}
This is how I select item by clicking the line of the listview but, I want to select item by clickin on the button not the whole line:
listEmployeeDetails.setOnItemClickListener(new OnItemClickListener(){
public void onItemClick(AdapterView<?> arg0, View v,int position, long arg3)
{
TextView tv=(TextView)v.findViewById(R.id.labelName);
String name=tv.getText().toString();
Toast.makeText(getApplicationContext(), "Contact Selected "+name, Toast.LENGTH_LONG).show();
}
});