IME parameters not working for Custom edittext
Here I am creating a custom editor using the following code. Now I am facing some weird problem when I try to put an IME parameter to override the enter button and change its functionality for submit, I cannot reach this option. Someone please help me with this.
public class CustomEditText extends EditText {
public CustomEditText (Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public CustomEditText (Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public CustomEditText (Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
System.out.println("kkeeueueueehu");
if (keyCode == KeyEvent.KEYCODE_BACK
&& event.getAction() == KeyEvent.ACTION_UP) {
li_bootm.setVisibility(View.GONE);
// Do your thing here
return false;
}
return false;
}
}
//here is how i use it in my fragment
private CustomEditText messageEditText;
private LinearLayout liedittext;
in my onCreateView
liedittext = (LinearLayout) v.findViewById(R.id.liedittext);
messageEditText = new NoImeEditText(getActivity());
liedittext.addView(messageEditText);
messageEditText.setBackgroundColor(Color.TRANSPARENT);
messageEditText.setHint("enter_message");
messageEditText.setSingleLine(false);
messageEditText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
// TODO Auto-generated method stub
// InputMethodManager imm = (InputMethodManager) getActivity()
// .getSystemService(Context.INPUT_METHOD_SERVICE);
// imm.hideSoftInputFromWindow(messageEditText.getWindowToken(),
// 0);
doSave();
li_bootm.setVisibility(View.GONE);
return false;
}
});
When I put
messageEditText.setSingleLine(false);
IME parameter is not available, but when
messageEditText.setSingleLine(true);
IME options are available, but I need multiple lines in my edittext
Here is my linear layout
<LinearLayout
android:id="@+id/liedittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
+3
source to share
No one has answered this question yet
Check out similar questions: