【发布时间】:2017-01-09 09:45:32
【问题描述】:
我创建了一个使用视图的应用程序,现在我希望在触摸视图时弹出键盘,即用户名、地址或电话视图我使用了以下代码行,但它不起作用
1)getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
这不起作用,我也尝试了以下但没有帮助
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))
.showSoftInput(username, InputMethodManager.SHOW_FORCED);
请帮我解决这个问题。This is the image of my custom view app
我的 EditText XML 在这里
<com.github.florent37.materialtextfield.MaterialTextField
android:layout_below="@+id/view"
app:mtf_image="@drawable/phon" android:id="@+id/view3">
<EditText android:layout_width="wrap_content"
android:layout_height="40dp"
android:id="@+id/phoneNo"
android:focusableInTouchMode="true"
android:textSize="18sp"
android:inputType="phone"
android:background="@drawable/phone"
android:hint="Phone Number" />
</com.github.florent37.materialtextfield.MaterialTextField>
【问题讨论】:
-
您是否在布局中使用 EditText :
-
是的,我正在使用编辑文本。
-
用户名是您的editText吗?
-
在此处复制您的用户名 XML。
-
xml太长了,这里无法复制
标签: android view textfield android-custom-view