I got a button which opens up a spinner:
butonLista.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v){
spinnerLista.performClick();
}
});
This is the spinner:
spinnerLista = new Spinner(this);
public void spinnerLista(){
adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, masini);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerLista.setAdapter(adapter);
spinnerLista.setOnItemSelectedListener(new listaOnClickListener());
}
In the listaOnClickListener i have a log:
public class listaOnClickListener implements OnItemSelectedListener{
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos,
long arg3) {
String nrInmat = String.valueOf(spinnerLista.getItemAtPosition(pos));
Log.w("Numar inmatriculare:", nrInmat+"");
txtNrInmat.setText(nrInmat);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// TODO Auto-generated method stub
}
}
After i click the button, the spinner list pops up, When i click an item from the list the log doesnt appear, the commands i put in the OnClickListener arent called, what can i do?
I finally want to set an EditText to spinnerLista.getItemAtPosition(pos);