我需要在我的imeOptions上设置CustomEditText。但是imeOptions是不可用的。
我的CustomEditText:
public class CustomEditText extends AppCompatEditText {
private Context context;
public CustomEditText(Context context) {
super(context);
this.context = context;
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}
public CustomEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
}
}发布于 2018-04-19 12:35:58
你的CustomEditText代码在我的分支中运行得很好
您需要使用android:inputType="text"设置android:imeOptions="actionNext"
您可以根据需要设置inputType和imeOptions
请检查下面的示例
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.example.nilesh.testapp.CustomEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text" />
<com.example.nilesh.testapp.CustomEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text" />
<com.example.nilesh.testapp.CustomEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text" />
<com.example.nilesh.testapp.CustomEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text" />
<com.example.nilesh.testapp.CustomEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="text" />
</LinearLayout>发布于 2018-04-19 12:36:23
创建设置imeOption的方法,如下所示:
public class CustomEditText extends AppCompatEditText {
private Context context;
public CustomEditText(Context context) {
super(context);
this.context = context;
setImeOption();
}
public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
setImeOption();
}
public CustomEditText(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
setImeOption();
}
private void setImeOption() {
this.setImeOptions(EditorInfo.IME_ACTION_NEXT);
}
}https://stackoverflow.com/questions/49921045
复制相似问题