I'm creating an intelligent greenhouse monitored and controlled by an application, and I'm creating a logic to register it. To choose the type of plant to be cultivated, I used a spinner on two screens, registration and data exchange (in case the farmer wants to use that greenhouse for another planting). However, only the data exchange screen spinner is working and the codes are identical, does anyone know what I can do to solve it?
This is the registration spinner:
Spinner spinner1 = findViewById(R.id.plantsCadastro_spinner);;
spinner1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView1, View view1, int position1, long l1) {
String item1 = adapterView1.getItemAtPosition(position1).toString();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView1) {
}
});
ArrayList<String> arrayList1 = new ArrayList<>();
arrayList1.add("product1");
arrayList1.add("product2");
arrayList1.add("product3");
ArrayAdapter<String> adapter1 =
new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, arrayList1);
adapter1.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
spinner1.setAdapter(adapter1);
and this is the config spinner:
Spinner spinner = findViewById(R.id.plants_spinner);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
String item = adapterView.getItemAtPosition(position).toString();
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
ArrayList<String> arrayList = new ArrayList<>();
arrayList.add("product1");
arrayList.add("product2");
arrayList.add("product3");
ArrayAdapter<String> adapter =
new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, arrayList);
adapter.setDropDownViewResource(android.R.layout.select_dialog_singlechoice);
spinner.setAdapter(adapter);