I have created an EditText programmatically. This EditText has one line and is added to a LinearLayout:
LinearLayout ll = (LinearLayout) myView.findViewById(R.id.select_options_option);
v = new EditText(context);
((EditText) v).setLines(1);
ll.addView(v);
My problem is that I can only type one character in this EditText. How can I set the width of an EditText, so that I can type in 3 or more charaters?
Try adding layout parameters to the linear layout before adding the TextView
LinearLayout ll = (LinearLayout) myView.findViewById(R.id.select_options_option);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(lp);
v = new EditText(context);
((EditText) v).setLines(1);
ll.addView(v)
You can also add the WRAP_CONTENT in your xml file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With