EditText focus not going after finishing activity - android

In my form activity, I've 3 fields. After confirming the form to the server it finishes and go to the previous activity. But the problem , After finish the keyboard is still pop up and the previous activity has no input field.
Here is the layout file.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="#color/colorWhite"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="#layout/toolbar"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_gravity="center"
android:layout_margin="20dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<sslwireless.com.easycorporate.Fonts.LoraBold
android:layout_marginBottom="20dp"
android:text="#string/change_password_title"
android:textSize="25sp"
android:textColor="#color/colorAccent"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/oldPassword"
android:background="#drawable/super_white_style"
android:padding="12dp"
android:layout_marginTop="15dp"
android:singleLine="true"
android:inputType="textPassword"
android:hint="#string/hints_old_password"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/newPassword"
android:background="#drawable/super_white_style"
android:padding="12dp"
android:layout_marginTop="15dp"
android:singleLine="true"
android:inputType="textPassword"
android:hint="#string/hints_new_password"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/confirmPassword"
android:background="#drawable/super_white_style"
android:padding="12dp"
android:layout_marginTop="15dp"
android:singleLine="true"
android:inputType="textPassword"
android:hint="#string/hints_confirm_password"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/changePassword"
android:text="#string/change_password"
android:layout_marginTop="20dp"
android:textColor="#color/colorWhite"
android:background="#drawable/primary_dark_color_style"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
</LinearLayout>
Here what actually happening.
i also set the android:windowSoftInputMode="stateHidden" for both activity in the manifest file. is there any way I can remove focus after go back to the previous activity ?

In onStop() of the finishing Activity, disable all the EditText fields like this in order to make the soft keyboard disappear:
EditText et = (EditText)findViewById(R.id.confirmPassword);
et.setEnabled(false);

You may force IME to close (before you finish() your activity):
public void hideSoftKeyboard(#NonNull Activity activity) {
IBinder windowToken = activity.getWindow().getDecorView().getRootView().getWindowToken();
InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(windowToken, 0);
}

Here's something that actually fixed an identical bug today.
#Override
public void closeKeyboard(View view) {
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
//Log.d("RKZ", "isKeyboardShown("+((ViewGroup) findViewById(android.R.id.content)).getChildAt(0)+") = "+isKeyboardShown(((ViewGroup) findViewById(android.R.id.content)).getChildAt(0)));
if(view != null && Util.isSoftKeyboardShown(imm, view)) {
Util.hideKeyboard(ActivityASG.this, view);
}
}
And in your CHANGE PIN Button's onClick() just call it like this:
//close keyboard
callback.closeKeyboard(noteInput);
callback.closeKeyboard(mailInput);
//callback.closeKeyboard(yourCHANGE_PINview);

call below code for close keybord , call when click on button
InputMethodManager imk = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imk.isActive()){
imk.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); // hide key board
}

Related

ButterKnife #onClick method for Button view is not working

I was updating an existing code by introducing dismiss button, and the onClick Butterknife method is not working for dismiss button, whereas its working for close button. In the below code, I am enabling the close button for some devices and for other devices I am enabling the dismiss button. I am quite unsure why this "dismiss" button is not working, whereas the close button is working fine. And both of them use the ButterKnife, onClick method - onSkip()
InfoActivity.java :
public class InfoActivity extends BccActiviy {
#BindView(R.id.ImageView_CloseView)
ImageView tCloseView;
#BindView(R.id.Dismiss)
Button tDismiss;
.....
#OnClick({R.id.Dismiss, R.id.ImageView_CloseView})
public void onSkip(View v) {
onDissmissPressed();
}
public void initialize(Bundle savedInstanceState) {
if (tConfig.isDismiss()) {
tCloseView.setVisibility(View.GONE);
tDismiss.setVisibility(View.VISIBLE);
} else {
tDismiss.setVisibility(View.GONE);
}
}
}
info_screen.xml :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:ignore="All"
android:id="#+id/root_layout"
android:background="#color/fd_theme"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/ImageView_CloseView"
style="#style/CancelButton"
android:layout_width="#di/target_size"
android:layout_marginTop="#di/p_6"
android:layout_height="#di/target_size"
android:layout_alignParentStart="true"
android:clickable="true"
android:contentDescription="#string/close_btn_txt"
android:importantForAccessibility="yes"
android:paddingStart="#di/p_14"
android:paddingEnd="#di/p_14"
android:background="?attr/bg_color"
app:srcCompat="#drawable/icn_close_white"/>
<LinearLayout
android:id="#+id/TextView_Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/TextContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="#di/size_2x"
android:focusableInTouchMode="true"
android:gravity="center"
android:text="#string/text"
android:textColor="#color/white"
android:textSize="#di/rating"
android:textAlignment="center"/>
<com.package.button.star.views.widgets.StaView
android:id="#+id/StarView_AppRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center">
</com.package.button.star.views.widgets.StarView>
<Button
android:id="#+id/Dismiss"
style="#style/buttonStyle"
android:layout_marginTop="#di/margin_top"
android:paddingLeft="#di/padding_50"
android:paddingTop="#di/padding_18"
android:paddingRight="#di/padding_50"
android:paddingBottom="#di/padding_18"
android:text="Dismiss"
android:onClick="onSkip"
android:textAlignment="center"
android:textAllCaps="false"
android:textSize="#di/dismiss_fontSize"
android:visibility="visible"
android:focusable="true"
tools:text="Dismiss" />
<ViewStub
android:id="#+id/actions_stub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#di/margin_center"
android:inflatedId="#+id/view_actions"
android:layout="#layout/view_actions" />
</LinearLayout>
</FrameLayout>
Try removing the onClick from xml.

EditText doen't open keyboard in popup

This layout is used for popup window to change name of a textview.But the edittext doesnt show keyboard even on clicking the edittext. I'm using it in a fragment. fragment has a namefield which is meant to be changed on clicking OK in this popup.
This is the xml file for popup window.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:id="#+id/name_status_btns"
>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:elevation="2dp"
android:background="#fff"
android:text="CANCEL"
android:textSize="18sp"
android:textColor="#000"
android:id="#+id/cancel_change_name"/>
<TextView
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#b1b0b0"/>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="OK"
android:textColor="#000"
android:textSize="18sp"
android:elevation="2dp"
android:background="#fff"
android:id="#+id/ok_change_name"
/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#b1b0b0"
android:layout_above="#id/name_status_btns"
android:id="#+id/name_status_horizontal_liner"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="15dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:id="#+id/name_status_edit_field">
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="5"
android:hint="write your name here"
android:scrollHorizontally="true"
android:id="#+id/change_name"
android:focusable="true"
android:focusableInTouchMode="true"/>
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/mainColor"
android:layout_below="#id/name_status_edit_field"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
/>
</RelativeLayout>
This is the java file for above xml.
public class Name_Status extends AppCompatActivity implements View.OnClickListener {
EditText name_change;
RelativeLayout name_status_edit_field;
String name;
Button cancel_name_change , ok_name_change;
#Override
protected void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.name_status);
DisplayMetrics dm=new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width=dm.widthPixels;
int height=dm.heightPixels;
getWindow().setLayout((int)(width*.8),(int)(height*.3));
name_change=(EditText)findViewById(R.id.change_name);
name_status_edit_field=(RelativeLayout)findViewById(R.id.name_status_edit_field);
name=name_change.getText().toString();
cancel_name_change=(Button)findViewById(R.id.cancel_change_name);
ok_name_change=(Button)findViewById(R.id.ok_change_name);
ok_name_change.setOnClickListener(this);
name_change.setOnClickListener(this);
name_status_edit_field.clearFocus();
name_change.setFocusable(true);
//name_change.update();
}
#Override
public void onClick(View v) {
if(v.getId()==R.id.ok_change_name)
{FragActivity1 obj=new FragActivity1();
obj.changeName(name);
Intent intent=new Intent();
intent.setClass(Name_Status.this , MainActivity.class);
startActivity(intent);}
if(v.getId()==R.id.change_name)
{
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInputFromWindow(name_change.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);
}
}
}
The main problem is your EditText has a 0dp width and a layout_weight attribute in a RelativeLayout, which does not make any sense.
Either make the parent of the EditText a LinearLayout or remove the layout_weight attribute from the EditText and give it a proper width:
<EditText
android:id="#+id/change_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="write your name here"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true"/>
The following code is completely unnecessary, you should just remove it from onClick():
if(v.getId()==R.id.change_name)
{
InputMethodManager imm = (InputMethodManager) getSystemService(Context.
INPUT_METHOD_SERVICE);
imm.toggleSoftInputFromWindow(name_change.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, 0);
}
You can also try the following for EditText
editText.setOnFocusChangeListener(new OnFocusChangeListener() {
#Override
public void onFocusChange(final View v, final boolean hasFocus) {
if (hasFocus && editText.isEnabled() && editText.isFocusable())
editText.post(new Runnable() {
#Override
public void run() {
final InputMethodManager imm = (InputMethodManager) context
.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
});
}
});
For more details refer Keyboard not shown when i click on edittextview in android?
EditText is not suppose to have 0dp width and layout_weight inside a RelativeLayout. Weight works inside LinearLayout. So change your EditText to below:
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="write your name here"
android:scrollHorizontally="true"
android:id="#+id/change_name"
android:focusable="true"
android:focusableInTouchMode="true"/>
And change your OnClick to because EditText will take care of click by itself:
#Override
public void onClick(View v) {
if(v.getId()==R.id.ok_change_name){
FragActivity1 obj=new FragActivity1();
obj.changeName(name);
Intent intent=new Intent();
intent.setClass(Name_Status.this , MainActivity.class);
startActivity(intent);
}
}
And finally remove the below line from your OnCreate() method:
name_change.setOnClickListener(this);
Because EditText will open keyboard by itself when clicked.

android edittext request focus at specific position

I have an edittext view and button , Edit text has some default value.
when i click on button i give focus to the edit text. but problem is cursor is at the start of edit text. how to place cursor after the default text.
what i did.
mobile_text =(EditText)findViewById(R.id.mobile_text);
mobile_edit = (ImageView)findViewById(R.id.mobile_edit_icon);
mobile_edit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mobile_text.setEnabled(true);
mobile_text.requestFocus();
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
});
My layout.xml file
<RelativeLayout
android:paddingTop="#dimen/pad_3dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/pad_5dp"
android:paddingBottom="#dimen/pad_5dp"
>
<TextView
android:id="#+id/mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MOBILE"
android:paddingLeft="2dp"
android:textSize="#dimen/txt_12sp"
/>
<EditText
android:paddingTop="#dimen/pad_5dp"
android:layout_below="#+id/mobile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
android:id="#+id/mobile_text"
android:text="9581129423"
/>
<ImageView
android:clickable="true"
android:id="#+id/mobile_edit_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/edit"
android:layout_below="#+id/mobile"
android:layout_alignParentRight="true"
android:gravity="right|end"
/>
</RelativeLayout>
Google Docs here : EditText - setSelection, Selection - setSelection
add this line
mobile_text.setSelection(mobile_text.getText().length());

How to get Focus in editText that is in a ViewSwitcher

I have a form with a lot of ViewSwitcher that change a TextView to an EditText with a clic.
The thing is I must clic 2 times to be able to insert value : Here are the screenshots :
The good thing would be not passing by the second state....
Here is my code.
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|right"
android:text="Colonia:"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/android_blue" />
<ViewSwitcher
android:id="#+id/vs2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical" >
<TextView
android:id="#+id/txt_colonia"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:clickable="true"
android:onClick="TextViewClicked"
android:paddingLeft="12dp"
android:text="Colonia"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_colonia"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:focusableInTouchMode="true"
android:text="Colonia 13"
android:textAppearance="?android:attr/textAppearanceLarge" />
</ViewSwitcher>
</TableRow>
And here is the java part :
switcher = (ViewSwitcher) findViewById(switchId);
View newView = switcher.getNextView();
if (newView instanceof TextView) {
((TextView) newView).setText(valor);
} else if (newView instanceof EditText) {
((EditText) newView).setText(valor);
((EditText) newView).setFocusableInTouchMode(true);
((EditText) newView).requestFocus();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
switcher.showNext();
Try switching to the edittext and then formatting it,
viewswitcher.showNext();
edittext.requestFocus();
edittext.setSelection(edittext.getText().length());
Try this:
If you are in a fragment
switcher.showNext();
edittext.requestFocus();
InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(edittext, 1);
If you are in an Activity
switcher.showNext();
edittext.requestFocus();
InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(edittext, 1);
A little late, but might help someone else...

Android: EditText NextFocusDown not trigger Spinner

In my application I have one registration screen, There are lot of EditTexts and Spinners.
I want to go through the Registrations field one by one.
So I applied android:imeOptions="actionNext" . But It ignores all the Spinners. It will give focus only to EditText. I have also tried setNextFocusDownId(). This is also ignore the spinners.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/reportentry11"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/numbers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:imeOptions="actionNext"
android:inputType="phone"
>
<requestFocus/>
</EditText>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/reportentry12"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="#+id/txt_exp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="EXP:"
android:textColor="#000000"
android:textSize="12dp" />
<Spinner
android:id="#+id/spin_date"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
android:focusable="true"
android:focusableInTouchMode="true"
android:nextFocusDown="#+id/spin_year"
android:text="date"
android:textSize="12dp" />
<Spinner
android:id="#+id/spin_year"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginRight="5dp"
android:nextFocusDown="#+id/cvc"
android:text="year"
android:textSize="12dp" />
</LinearLayout>
<EditText
android:id="#+id/cvc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:hint="#string/reg_label_cvc"
android:imeOptions="actionNext"
android:inputType="phone" />
<EditText
android:id="#+id/fname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/reg_label_fname"
android:imeOptions="actionNext" />
<EditText
android:id="#+id/address"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/reg_label_address"
android:imeOptions="actionNext" />
<EditText
android:id="#+id/city"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/reg_label_city"
android:imeOptions="actionNext"
android:nextFocusDown="#+id/pr_spin" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/reportentry13"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/txt_pr"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="PROV:"
android:textColor="#000000"
android:textSize="12dp" />
<Spinner
android:id="#+id/pr_spin"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="date"
android:imeOptions="actionNext"
android:textSize="14dp" />
<EditText
android:id="#+id/pcode"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:hint="#string/reg_label_pcode"
android:imeOptions="actionDone" />
</LinearLayout>
<Button
android:id="#+id/register_register_button"
android:layout_width="wrap_content"
android:background="#drawable/green_button_bg"
android:onClick="completeClicked"
android:text="#string/reg_label_complete"
android:textSize="28dp"
android:textStyle="bold" />
</LinearLayout>
Please provide me the best way to trigger the spinners.
On your edit texts, override onEditorAction and give focus (or do whatever like open your spinner)...
yourEditTXT.setOnEditorActionListener(new OnEditorActionListener() {
#Override
public boolean onEditorAction(TextView view, int actionID, KeyEvent event) {
if (actionID == EditorInfo.IME_ACTION_NEXT) {
//do your stuff here...
return true;
}
return false;
}
});
Edit 12/4:
I see you were still struggling with this as of last night, if you didn't find a solution (and didn't post one) or to help others who may read this, this may help to get from spinner to edit text.
mySpinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
public class MyOnItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parentview, View v, int position, long id) {
// your spinner proces code
// then when you are done,
yourEditText.setFocusableInTouchMode(true); //if this is not already set
yourEditText.requestFocus(); //to move the cursor
final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.showSoftInput(yourEditText, InputMethodManager.SHOW_IMPLICIT); // this line and the one above will open the soft keyboard if it doesn't already open
}
public void onNothingSelected(AdapterView<?> arg0) { }
};
do the following in your xml file:
<Spinnner
android:focusable="true"
android:focusableInTouchMode="true"
android:nextFocusDown="#+id/youedittextid"
/>
Apart from the solutions above to focus on Spinners, here are further troubles with ime options:
If the spinners are between the EditTexts, then the EditTexts that are below the spinners ignore imeOption="actionDone" and lines="1" attributes. In both the cases they accept enter keys and move to next line, when, it should not allow the enter key event.
I found that though the listener for ime was still intact, the ime option set to whatever (next or done), it changed to 0.
So my answer is for second part while I am still trying to make spinners focusable:
xml:
<EditText
android:id="#+id/et_1"
android:layout_width="match_parent"
android:layout_height="#dimen/dp_40"
android:layout_marginLeft="#dimen/dp_8"
android:layout_marginStart="#dimen/dp_8"
android:gravity="start|bottom"
android:hint="#string/et_1"
android:imeOptions="actionNext"
android:inputType="textCapWords" />
<!--This ime option works fine-->
<!--lots of spinners in between these Edit texts-->
<EditText
android:id="#+id/et_2"
android:layout_gravity="start|bottom"
android:layout_marginLeft="#dimen/dp_8"
android:layout_marginStart="#dimen/dp_8"
android:gravity="start|bottom"
android:hint="#string/et_2"
android:imeOptions="actionDone" />
<!--this actionDone is ignored and set to 0-->
[value of actionNext = 5 while that of actionDone = 0, but for edit text et2 reports as 0 in the listener]
set listener:
...
EditText et_1 = view.findViewById(R.id.et_1);
fet_1.setOnEditorActionListener(this);
//==
EditText et_2 = view.findViewById(R.id.et_2);
et_2.setOnEditorActionListener(this);
...
The handling of listeners where the ime actions are ignored too:
#Override
public boolean onEditorAction(TextView textView, int actionID, KeyEvent keyEvent) {
FontEditText et_1 = getView().findViewById(R.id.et_1);
//==
EditText et_2 = getView().findViewById(R.id.et_2);
final int id = textView.getId();
switch (id) {
case R.id.et_1: {
if (actionID == EditorInfo.IME_ACTION_NEXT) {
// works actionID = 5.
//inherited method
activity.hideKeyboard(textView);
fet_bus_entity.clearFocus();
et_business_add.requestFocus();
et_business_add.performClick();
return true;
}
}
break;
case R.id.et_2: {
//following line doesn't work hence commented, value of actionID = 0 here.
// if (actionID == EditorInfo.IME_ACTION_DONE) {
et_business_add.clearFocus();
//inherited method
activity.hideKeyboard(textView);
return true;
// }
}
// break;
}
return false;
}

Categories

Resources