I am in the dilemma of having a listview, with a custom adapter
I have the following adapter
What I would like to achieve is that if you click on the sign to accept, or if you click on the sign to reject something happens,
The first thing I thought was to add an onclick to each image,
those icons are images, but it turns out that doing so, I do not know which of the items in the listView was clicked, I've researched and I have not found something that guides me to solve this problem, any help on how to solve this problem It's welcome, thank you very much
this is my adapter class
<TextView
android:layout_marginTop="5dp"
android:id="@+id/txtNumberPhoneBilling"
android:layout_width="168dp"
android:layout_height="wrap_content"
android:paddingLeft="20dp"
android:text="textview"
android:textSize="16dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_weight="0.67" />
<TextView
android:id="@+id/txtMountBillingNotifications"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txtNumberPhoneBilling"
android:paddingLeft="20dp"
android:text="TextViewss"
android:textColor="@color/black"
android:layout_gravity="center_vertical"
android:textSize="16dp"/>
<TextView
android:textColor="@color/black"
android:id="@+id/txtDateBillingNotifications"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/txtMountBillingNotifications"
android:text="TextView"
android:textSize="16dp"
android:paddingLeft="20dp"
/>
<ImageView
android:id="@+id/btnAcceptBillingNotifications"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:paddingRight="40dp"
android:layout_marginRight="100dp"
android:background="@mipmap/aceptar"
android:onClick="Acept"
android:layout_centerInParent="true" />
<ImageView
android:id="@+id/btnCancelBillingNotifications"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:layout_alignParentRight="true"
android:paddingRight="40dp"
android:layout_marginRight="50dp"
android:background="@mipmap/cancelar"
android:onClick="Cancel"
android:layout_centerInParent="true" />
and this is my adapter class
package banred.twoinnovateit.com.Utils;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import banred.twoinnovateit.com.bimo.R;
/*
*Create by: Bruno Sosa
*Date: 17-10-2017
*Description: Clase de adapter del listado de cobros pendientes
*/
public class AdapterCobroPendiente extends BaseAdapter {
protected Activity activity;
protected ArrayList<CobroPendiente> items;
public AdapterCobroPendiente(Activity activity, ArrayList<CobroPendiente> itemsCompra) {
this.activity = activity;
this.items = itemsCompra;
}
@Override
public int getCount() {
return items.size();
}
@Override
public Object getItem(int position) {
return items.get(position);
}
@Override
public long getItemId(int position) {
return Integer.parseInt(items.get(position).getNumber());
}
@Override
public View getView(int position, View contentView, ViewGroup parent) {
View vi = contentView;
if (contentView == null) {
LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
vi = inflater.inflate(R.layout.activity_billing_notifications_adapter, null);
}
CobroPendiente item = items.get(position);
TextView number = (TextView) vi.findViewById(R.id.txtNumberPhoneBilling);
number.setText(item.getNumber());
TextView mount = (TextView) vi.findViewById(R.id.txtMountBillingNotifications);
mount.setText(item.getMonto());
TextView date = (TextView) vi.findViewById(R.id.txtDateBillingNotifications);
date.setText(item.getFecha());
return vi;
}
}