Skip to content Skip to sidebar Skip to footer

Dynamically Add Edit Text To A Layout

I am trying to add an edit text view dynamically to a layout from the java class. However from what I have implemented nothing changes on my action. This is what I have: public fin

Solution 1:

It sure gets added but you are not seeing it cause there is no space left. Two things to test:

  • Place the LinearLayout inside a ScrollView.
  • Use the weight parameter.

Using the weight parameter:

EditText temp = new EditText(ContactEdit.this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
                            LayoutParams.WRAP_CONTENT, 1);
temp.setLayoutParams(params);

Post a Comment for "Dynamically Add Edit Text To A Layout"