i am trying to put a button on my listView item and make a call… but so far, I couldn’t figure out how to assign that data to that button action and here is my code… The list item itself is not clickable, only the button is. I use an adapter to get the data from the array
public View getView(int position, View convertView, ViewGroup parent)
{
ViewHolder holder;
//Get the current location object
info lm = (info) getItem(position);
//Inflate the view
if(convertView==null)
{
convertView = dInflater.inflate(R.layout.dealbranch_layout, null);
holder = new ViewHolder();
holder.name = (TextView) convertView.findViewById(R.id.address);
holder.call = (Button) convertView.findViewById(R.id.call);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
holder.name.setText(lm.getName());
holder.call.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent call = new Intent (Itent.ACTION_CALL);
/// No clue.. >,< /// /// lm.getPhone() should get the phone# for this row.
/// this action does not work /////
startActivity(call);
}
});
return convertView;
}
Would be great if someone could show me the way. Thanks.
We don’t know how you define the class ‘info’ so here’s my guess:
first, change the line:
to
then here’s how to invoke ACTION_DIAL with phone number:
This is assuming the lm.getPhone() method returns a phone number in string.