0
"Which function to use" is something very generic. If you want to do some action when one of the buttons is pressed, you have two alternatives.
The first alternative is to create in the class of this Activity (in this case, your "Burguerking.java") an Onclicklistener on the two buttons.
For this, you will need to give a findView on the two components
private <Componente> botaoAdicionar = findViewById(R.id.<seuID>);
Then to create the Onclicklistener
botaoAdicionar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Faça o que desejar
}
});
To second alternative (not very recommended) is to create a function and link it to your component. For this, create the function, click your button and go to inputMethod
. There, you select the function you created.
If you want to add and remove items, you will need an Arraylist. If the items you want to add have specific features, for example, nome do pedido, preço, quantidade, etc...
you will need to create an object with these features and an Array of that object.
ArrayList<Pedido> listaDePedidos = new ArrayList<Pedido>();
If you’re not familiar with this, I recommend reading "Object-Oriented Programming".
Then, of course, just use the methods of your Array that add and remove items.
listaDePedidos.add(...);
listaDePedidos.remove(...);
Already helped me Enough, I was needing a North to implement the functions.
– Luiz Natanael