I have a Spinner with a custom adapter. When giving on a number the setOnItemSelectedListener does not answer me, I think the problem is the focus that goes to my custom adapter and I do not know how to deactivate that, if someone helps me by favor .. Here my code:
private Spinner spMonto
spMonto = (Spinner)view.findViewById(R.id.SpMonto);
List<Integer> montos = new ArrayList<>();//cargar de la base de datos
montos.add(100000);
montos.add(200000);
montos.add(300000);
montos.add(400000);
montos.add(500000);
montos.add(600000);
montos.add(700000);
montos.add(800000);
montos.add(900000);
montos.add(1000000);
adaptadorS = new AdaptadorTextViewSimple(montos,C);
spMonto.setAdapter(adaptadorS);
spMonto.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
TextView textView = (TextView)view.findViewById(R.id.txtText);
montoSelec = Integer.parseInt(textView.getTag().toString());
Log.i(Constantes.TAG,"montoX "+montoSelec);
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
});
Here is my adapter (AdaptadorTextViewSimple):
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
LayoutInflater inflater = (LayoutInflater)C.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (view==null){
view=inflater.inflate(R.layout.text_view_simple,null);
}
TextView texto = (TextView)view.findViewById(R.id.txtText);
texto.setFocusable(false);
texto.setText(String.valueOf(formatomil.format(integerList.get(i).intValue())));
texto.setTag(integerList.get(i).intValue());
return view;
}
my custom adapter XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="false" >
<TextView
android:focusable="false"
android:id="@+id/txtText"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center"
android:inputType="textMultiLine"
android:textColor="@color/Negro"
android:textSize="20sp" />