There is a custom markup for the ListVIew element. It has three textviews. How to catch a click on each of them?

    1 answer 1

    Add onClickListener to each textview in the adapter.

     public class FundAdapter extends ArrayAdapter<Fund> { private int resource; public FundAdapter(Context context, int resource, List<Fund> items) { super(context, resource, items); this.resource = resource; } @Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout view; Fund fund = getItem(position); if(convertView == null) { view = new LinearLayout(getContext()); String inflater = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater vi = (LayoutInflater)getContext().getSystemService(inflater); vi.inflate(resource, view, true); } else { view = (LinearLayout) convertView; } TextView quantity = (TextView) view.findViewById(R.id.quantity); TextView itemView = (TextView) view.findViewById(R.id.walletItem); quantity.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { <--А ТУТ ВСЕ ДЕЙСТВИЯ КОТОРЫЕ ХОТИТЕ СДЕЛАТЬ)--> } }); itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { <--А ТУТ ВСЕ ДЕЙСТВИЯ КОТОРЫЕ ХОТИТЕ СДЕЛАТЬ)--> } }); return view; } } 

    Apparently from an example the listener is imposed on both TextView

     quantity.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { <--А ТУТ ВСЕ ДЕЙСТВИЯ КОТОРЫЕ ХОТИТЕ СДЕЛАТЬ)--> } }); itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { <--А ТУТ ВСЕ ДЕЙСТВИЯ КОТОРЫЕ ХОТИТЕ СДЕЛАТЬ)--> } }); 
    • Please show me an example - Beginner
    • Better you put your adapter here, I'll make it - elik
    • If you want to attach your code part only where you redefine BaseAdapter I will show you by example - elik
    • I use the Fundapter, it is imported .. - Beginner
    • Keep searching the foundation for adaptr prescribed out and 2 listeners) and also for 3 texts and for 4) - elik