A
A
Aydomir Salchak2014-06-27 19:13:24
Java
Aydomir Salchak, 2014-06-27 19:13:24

How to programmatically add an EditText?

Here is the code I am trying to do it:

LinearLayout LL = (LinearLayout)findViewById(R.id.section_label);
EditText ET = new EditText(this);
ET.setText("hallo hallo");
ET.setId(5);
ET.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
LL.addView(ET);

Problem:
7ba14ef13eaf47e2820632e72ad82452.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey M, 2014-06-27
@Collosteam

Are you writing this code in Fragment or Activity? This information is not sufficient for analysis. Attach the entire file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question