0
I own an Activity that has a ListView
. The items of ListView
I built it myself. I put a EditText
and I need to do an event setOnClickListener
in it. But the right thing would be to do this in the main Activity and not in the Adapter class. I have declared the Adpter in the main Activity, but how do I trigger this event?
Code of the Adapter:
public View getView(int position, View convertView, ViewGroup parent) {
final ExclusaoItem item = itens.get(position);
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.item_exclusao,null);
TextView ref = view.findViewById(R.id.txt_ref_exclusao);
ref.setText(String.valueOf(item.getProduto()));
TextView tamanho = view.findViewById(R.id.txt_tamanho_exclusao);
tamanho.setText(String.valueOf(item.getTamanho()));
TextView situacao = view.findViewById(R.id.txt_situacao_exclusao);
if(item.getEstoque()==1){
situacao.setVisibility(View.VISIBLE);
situacao.setText("Estoque");
}
final EditText codBarrasPainel = view.findViewById(R.id.edt_painel_produto);
I need to do setOnClickListener in codBarrasPainel that is at the end of the code.
I did a quick draft, might have some mistakes
– GabrielLocalhost
Will I have to use this huge code just for a setOnClicklistener in a field of the list. I did not understand very well, but I will try. I thought it would be simpler. =(
– Bruno
It is that in Adapter you will create an interface, you can search about them and try to reduce in the way that suits you most.
– GabrielLocalhost