How do I get focus on EditText
but still with problems?
I'm doing an ordering system, I have 3 EditText
(product, quantity and discount) and a Add button.
I need that when the user clicks the add button, the focus goes back to the product field, today the focus is going to a editText
of listView
(order items) that has just been added.
So if the user adds 30 products he has to scroll the screen up and focus on the product.
I'm using Android 4.1
Code (no onclick
of the add button)
try{
validaProdutoLista(item, pedido.getListaItemPedido());
pedido.adicionaItens(item);
listViewItensPedidos.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, pedido.getListaItemPedido().size() * 50));
TabelaItensPedidoAdapter adapter = new TabelaItensPedidoAdapter(PedidoActivity.this, pedido.getListaItemPedido());
listViewItensPedidos.setAdapter(adapter);
adapter.notifyDataSetChanged();
Log.i(TAG, "Itens add "+pedido.getListaItemPedido().size());
codProduto.setText("");
codProduto.requestFocus(); //voltar o foco para o produto
}catch (MyException e){
// TODO Auto-generated catch block
e.printStackTrace();
}