Android动态编辑文本
我动态创建Android动态编辑文本,android,android-edittext,Android,Android Edittext,我动态创建EditText,但当我单击它们以插入数据时,键盘不会打开 MaterialEditText ed = new MaterialEditText(getApplicationContext()); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CON
EditText
,但当我单击它们以插入数据时,键盘不会打开
MaterialEditText ed = new MaterialEditText(getApplicationContext());
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(0, 20, 30, 0);
rlCampi.addView(ed, layoutParams);
试试这个
youredittextname.setFocusableInTouchMode(true);
youredittextname.requestFocus();
要添加编辑文本,请尝试以下方法:
// Pass it an Activity or Context
EditText myEditText = new EditText(context);
// Pass two args; must be LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, or an integer pixel value.
myEditText.setLayoutParams(new LayoutParams(..., ...));
myLayout.addView(myEditText);
MaterialEditText:您使用什么版本?此:@DeboraCarnevali很高兴帮助您:)快乐编码