I want to add a call button in list view. I have tried adding the button in the list row file and cannot add Onclick on a Java file. There are more errors happening. Are there any other methods without button? Anyone please help me. Thank you.
Here is the Adapter code
class adapter extends BaseAdapter {
LayoutInflater Inflater;
@Override
public int getCount() {
// TODO Auto-generated method stub
return place.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
Inflater=(LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView=Inflater.inflate(R.layout.blood_lst,null);
Viewholder holder=new adapter.Viewholder();
holder.pl=(TextView)convertView.findViewById(R.id.bld_name);
holder.pl.setText(place.get(position));
holder.in=(TextView)convertView.findViewById(R.id.bld_nm);
holder.in.setText(incharge.get(position));
holder.em=(TextView)convertView.findViewById(R.id.bld_em);
holder.em.setText(email.get(position));
holder.ph=(TextView)convertView.findViewById(R.id.bld_phn);
holder.ph.setText(phone.get(position));
holder.ph=(TextView)convertView.findViewById(R.id.bld_grp);
holder.ph.setText(Bld.get(position));
return convertView;
}
class Viewholder{
TextView pl;
TextView in;
TextView em;
TextView ph;
}
}
}
Add a onClick
to the convertView
like so:
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// do stuff here
}
});