I have this code:
nuevo.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if((event.getAction()==KeyEvent.ACTION_DOWN)&&(keyCode==KeyEvent.KEYCODE_ENTER))
{
String articulo;
articulo = nuevo.getText().toString();
listas.add(new ListasSecundarias(articulo));
if (listas.isEmpty())
{
adapter.notifyItemInserted(0);
}
adapter.notifyItemInserted(listas.size()+1);
guardar(articulo,NombreDeLaLista);
nuevo.setText("");
}
return false;
}
});
and what happens is that if I press enter with the keyboard of the PC, it performs the corresponding actions, but when I press enter on the mobile key, nothing happens.