Edittext does not open the keyboard inside the listview

Asked

Viewed 113 times

2

A listView within a dialog and put in front of each information one EditText, but when I click on EditText to change the information it puts the cursor inside the EditText, but does not open the keyboard so I can change the data.

Obs: that editText he’s in a layout, I don’t believe him at all adapter.

Follows the codes.

XML who loads the list:

<TableLayout
    android:id="@+id/TableLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:showDividers="middle"
    android:shrinkColumns="*"
    android:stretchColumns="*"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true">

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal" >

        <TextView
            android:id="@+id/txtMateriais"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="0.40"
            android:gravity="center"
            android:padding="10dip"
            android:text="Lançamento de Materiais"
            android:textColor="@color/colorPreto"
            android:textSize="20sp"
            android:textStyle="bold"
            android:typeface="normal" />
    </TableRow>

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="center_horizontal">

        <TextView
            android:id="@+id/txtProduto"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="2dp"
            android:layout_weight="0.75"
            android:background="@drawable/shape_text_dialog"
            android:gravity="left"
            android:padding="10dip"
            android:text="Produto:"
            android:textColor="@color/colorPreto"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/txtProdutoDose"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="2dp"
            android:layout_weight="0.25"
            android:background="@drawable/shape_text_dialog"
            android:gravity="left"
            android:padding="10dp"
            android:textColor="@color/colorPreto"
            android:textStyle="bold" />

        <EditText
            android:id="@+id/edtProdutoUsado"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_margin="2dp"
            android:layout_weight="0.25"
            android:background="@drawable/shape_text_dialog"
            android:inputType="numberDecimal"
            android:windowSoftInputMode="adjustResize|stateHidden"
            android:padding="10dp" />


    </TableRow>

</TableLayout>

Adapter:

@SuppressLint({ "ViewHolder", "InflateParams" })
public class ListaMateriaisAdapter extends BaseAdapter {

    private LayoutInflater mInflater;
    private List<Materiais> listMateriais;
    private Context context;
    protected LinkedList<Materiais> material;

    public ListaMateriaisAdapter(Context context, List<Materiais> listMateriais)
    {
        this.listMateriais = listMateriais;
        this.context = context;
        mInflater = LayoutInflater.from(context);
    }

    public int getCount()
    {
        return listMateriais.size();
    }

    public Materiais getItem(int position)
    {
        return listMateriais.get(position);
    }

    public long getItemId(int position)
    {
        return position;
    }

    public Context getContext()
    {
        return this.context;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {

        final Materiais materiais = listMateriais.get(position);

        view = mInflater.inflate(R.layout.activity_lista_materiais, null);

        final MateriaisDAO materiaisDAO = new MateriaisDAO(this.getContext());

        //Produto
        TextView txtProduto = (TextView) view.findViewById(R.id.txtProduto);
        txtProduto.setText(String.valueOf(materiais.getDescricaoMaterial()));

        //Dose
        TextView txtProdutoDose = (TextView) view.findViewById(R.id.txtProdutoDose);
        txtProdutoDose.setText(String.valueOf(String.format("%.2f",(materiaisDAO.getQntRecomendada(materiais.getNumeroOrdem, materiais.getCodigoMaterial())))));

        //Quantidade Aplicada
        final EditText edtQntUsada = (EditText) view.findViewById(R.id.edtProdutoUsado);
        edtQntUsada.setText(String.valueOf(String.format("%.2f",((materiaisDAO.getQntRecomendada(materiais.getNumeroOrdem, materiais.getCodigoMaterial())) * LancamentoActivity.areaApl))));

        //------------------------------------------------------------------------------------------

        View convertView = view;

        view = convertView;

        return view;


    }
}

Dialog who loads the list:

private void dialogMateriais(){
        final View dialogView = inflater.inflate(R.layout.lista_materiais, null);

        android.app.AlertDialog.Builder dialog = new android.app.AlertDialog.Builder(LancamentoActivity.this);
        dialog.setTitle("MATERIAIS");
        dialog.setView(dialogView);

        List<Materiais> listaMaterial = new ArrayList<Materiais>();
        MateriaisDAO materiaisDAO = new MateriaisDAO(LancamentoActivity.this);

        inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        listView = (ListView) dialogView.findViewById(R.id.listMateriais);

        listMateriais = materiaisDAO.getMateriais(EntradaActivity.numeroOrdem);

        ListarMateriais = new ListaMateriaisAdapter(LancamentoActivity.this, listMateriais);

        listView.setAdapter(ListarMateriais);
        listView.setCacheColorHint(Color.TRANSPARENT);

        dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });

        dialog.setNegativeButton("CANCELAR", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        dialog.show();
    }
  • Is there any way to code that? Hardly anyone will help you without any code.

  • I put the code to make it easy

  • 1

    Try adding these 2 lines to your Edittext android:focusable="true"&#xA;android:focusableInTouchMode="true". See if it works :)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.