0
You can associate a slightly different Switch for each of these buttons directly in the Adapter. Your getView
would look something like this:
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View linha = inflater.inflate(R.layout.linha_de_produto, parent,
false);
ImageButton carrinhoButton = (ImageButton) linha.findViewById(R.id.carrinhoButton);
carrinhoButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Aqui entra o código que vai usar a variável position para fazer uma coisa diferente pra cada caso.
}
});
}
But what is the doubt?
– Pablo Almeida
how can I count these Buttons, since it creates the button as a string is added
– Carlos Alberto
But what has to do with counting the buttons to save the product with the price?
– Pablo Almeida
if I click the button, it will save the product and the price, how do I do it, sorry if I’m not able to express myself
– Carlos Alberto
All right. I edited your question by removing the information not related to doubt. Remember to only say what is relevant so your question doesn’t get too big. Also, when someone asks for clarification in the comments, remember that you can (and should!) edit your question with the details instead of just putting them in the comments. Another tip: put descriptions on the images, otherwise your question becomes invisible to screen reader users. Take a look at how I did it if you want an idea of how it’s done. Otherwise, welcome!
– Pablo Almeida