Extract elements from a ListView and use them in a Button (Android)

0

help, I must choose an element of a ListView and after that fill the EditText with the data that is requested and the button that calculates the operation, and display it in a TextView, but when running it does not execute it on the button, but in the same listview when I clicked it again ... does anyone know how to execute my method when clicking on the button and not on the ListView? (I am a beginner) here my code:

public void calcula(View view){
lv1.setOnItemClickListener(new AdapterView<?> adapterView.OnItemClickListener()){
public void onItemClick(AdapterView<?> adapterView,View view, int i,long l){
String num1= et1.getText().toString();
String num2= et1.getText().toString();
double nro1= Double.parseDouble(num1);
double nro2= Double.parseDouble(num2);

String selec = listview1.getItemAtPosition(i).toString();
if(selec.equals("Volumen")){
double vol= nro1/nro2; 
tv1.setText("El volumen es"+vol);
}else if(selec.equals("Temperatura")){
double tempe= nro1*nro2;
tv1.setText("La temperatura es"+tempe);
}
}
{); 
    }
    
asked by Oscar Peralta Najera 05.02.2018 в 01:55
source

0 answers