【发布时间】:2016-07-28 09:50:28
【问题描述】:
正在膨胀的 XML 文件 (matrix_cell.xml)。
<EditText
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rect_edit_text"
android:textCursorDrawable="@drawable/cursor_black"
android:textColor="@color/colorAccent"
android:gravity="center_horizontal"
android:inputType="number"
android:layout_margin="1dp"
android:layout_weight="1" />
膨胀视图的代码:
LayoutInflater inflater = LayoutInflater.from(this);
TableRow tableRow = new TableRow(this);
inflater.inflate(R.layout.matrix_cell, tableRow, true);
创建的 EditText 视图不可选择,当单击 EditText 视图时,输入焦点仍保留在前一个输入焦点上。
【问题讨论】:
-
可选择是什么意思?
-
单击时光标不会显示在 editText 上。它保留在上一个焦点上的输入上。
-
您是否在调试应用程序时尝试手动选择它?您是否尝试在代码中以编程方式选择它?你的代码的其余部分是什么样的? (xml, java)
-
当你点击时,你得到键盘了吗?如果是这样,当你打字时会发生什么?数字是否出现在编辑文本中?
标签: android