
usar un spinner con un switch
Publicado por liantony (6 intervenciones) el 25/03/2017 23:11:48
Hola trato de usar un switch con spinner y lo he intentado de varias maneras y no puedo encontrar una solución
cuando intento hacer la referencia dentro del switch me da un error
cuando intento hacer la referencia dentro del switch me da un error
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
public class SenoCosenoTangente extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
EditText ca,
co,
a,
h;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seno_coseno_tangente);
ca = (EditText)findViewById(R.id.cateto_acyasente);
co = (EditText)findViewById(R.id.cateto_opuesto);
a = (EditText)findViewById(R.id.angulo);
h = (EditText)findViewById(R.id.hipotenusa);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.setOnItemSelectedListener(this);
List<String> funciones = new ArrayList<String>();
funciones.add("sin");
funciones.add("cos");
funciones.add("tang");
ArrayAdapter <String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item , funciones);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String item = parent.getItemAtPosition(position).toString();
Toast.makeText(parent.getContext(), "Selected: " + item, Toast.LENGTH_LONG).show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
public void calcular4 (View v ){
double cateto_o = Integer.parseInt(co.getText().toString());
double cateto_a = Integer.parseInt(ca.getText().toString());
double angulo = Integer.parseInt(a.getText().toString());
double hipotenusa = Integer.parseInt(h.getText().toString());
switch ()
}
}
Valora esta pregunta


0