Problem in editText inside a Listview

Asked

Viewed 140 times

1

Essa é a imagem da editext dentro da listviewHello, I created a list of questions within a Listview, I created all the questions by programming, I’m not doing any components in the.xml layout, I just have a frameLayout, but the moment I click on the edittext it doesn’t let me type, I click and the keyboard of the phone appears and disappears quickly, anyone knows what can be? And how to solve ?

Follow the editext creation code:

public LinearLayout createEditText(String question, int line, EditText editText){

    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    ViewGroup.LayoutParams lpView = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    ViewGroup.LayoutParams
            lpViewEdit = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    TextView tv = new TextView(context);
    tv.setTextColor(Color.BLACK);
    tv.setText(question);
    tv.setLayoutParams(lpView);
    linearLayout.addView(tv);

    editText= new EditText(context);
    editText.setEnabled(true);
    editText.setInputType(InputType.TYPE_CLASS_TEXT);
    editText.setFocusable(true);
    editText.setMaxLines(10);
    editText.setEms(2);
    editText.setLayoutParams(lpViewEdit);
    linearLayout.addView(editText);

    return linearLayout;
}

Follow the code where I’m calling this method of creation:

editText = new EditText(context);
        frameLayout.addView(createEditText(id + "." + listaPergunta.get(position).getTxtPergunta(), lines, editText));
  • 1

    You have to enter your code here, otherwise it becomes difficult to help you.

1 answer

0

To the setInputType enter the value for the field type. Example: password field, numeric field, text field, etc.

EditText edit = new EditTex(context);   
edit.setEnabled(true);
edit.setInputType(InputType.TYPE_CLASS_TEXT);
edit.setFocusable(true);

Browser other questions tagged

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