Skip to content Skip to sidebar Skip to footer

How Can I Use The Number From Textfield Of Each Row In Listview And Make A Call On This Number?

here is my custom adapter. public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater= (LayoutInflater) context.getSystemService(Context.LA

Solution 1:

Here is what I do:

privateclassMyAdapterextendsBaseAdapter {
   private ListView listView;
   ...
   @Overridepublic View getView(int i, View view, ViewGroup viewGroup) {
      this.listView = (ListView) viewGroup;

and then in each View.OnClickListener I can get the position of the clicked item by

@OverridepublicvoidonClick(View view) {
   ...
   MyAdapter.this.listView.getPositionForView((View) view.getParent()));

Solution 2:

use this in adapter getView method:

yourViewHolder.callBtn.setOnClickListener(newView.OnClickListener(View view){

String callNum=yourViewHolder.textField.getText().toString();
String callUri="tel:"+callNum;
Intent callIntent = newIntent(Intent.ACTION_CALL);
    callIntent.setData(Uri.parse(callUri));
    startActivity(callIntent);
}
);

Post a Comment for "How Can I Use The Number From Textfield Of Each Row In Listview And Make A Call On This Number?"