How to set requestFocus after EditText validation

By : MikeT
Source: Stackoverflow.com
Question!

Note although this is a duplicate question as such, none of the answers appear to work.

Note I've been trying out more things, as per the comments that I've added. In short the issue very much appears to be the actual requestFocus() that is effectively disabling the EditText that needs to be editable as validation has found the data to be invalid.

I have an activity with 6 EditText views. Currently I am working on 1 that is for amending a date. For this specific EditText I am validating the text via an OnFocusChangedListener (currently this just checks that the text is between 8 and 10 characters) and only if the focus has gone elsewhere.

This appears to be working fine, for a valid date (considering the very limited validation undertaken at present) the timestamp displayed. This happens as expected. For an invalid date (ie less than 8 or more than 10 characters) instead of the timestamp a message is displayed.

However, for an invalid date, I want the focus to be back on the EditText. This is where I am having problems. As the focus is not being placed at that EditText. Additonally the EditText can not, as far as I can tell, get the Focus (permanently see later) manually.

I have some messages written to the log. One when the listener is invoked and the other when (!hasFocus) is encountered. These show, I believe, that the logic/process is being followed and also that the requestFocus is in fact placing the focus back to the EditText. So it very much appears that something is then taking the focus away and I believe to be doing this whenever the focus is placed on that EditText.

Another weird/unusual occurrence is that after the failed validation and attempt to place the focus on the EditText. The cursor alternates between the EditText in question and the following EditText.

I have looked through many posts, on here and elsewhere (I currently have 16 tabs open). I've tried many things. I have focusable and focusableInTouchMode at the start of all the LinearLayouts and also on all of the EditTexts in the XML. I also set them both in my activity. I've removed inputtypes from the XML (which was the conclusion reached by one poster). Another suggested setting both focusables to false and then back to true. I attempted this and it resulted in the listener being called endlessly. I've turned of Swift soft-keyboard and used the default, the results are the same.

Anyway here's the code (currently setting the focusables to true twice).

    this.findViewById(R.id.apue_productusage_firstbuydate_data).setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            Log.i(Constants.LOG,"Focus Change Listener - Fired - Before Has Focus Check.");
            EditText data_et = (EditText) findViewById(R.id.apue_productusage_firstbuydate_data);
            TextView check_tv = (TextView) findViewById(R.id.apue_firstbuydate_check);
            if(!hasFocus) {
                Log.i(Constants.LOG,"Focus Change Listener - Fired AND it isn't me that is focused.");
                String givendate = data_et.getText().toString();
                Emsg emsg = validateDate(givendate);
                if(emsg.getErrorIndicator()) {
                    check_tv.setText(emsg.getErrorMessage());
                    //check_tv.requestFocus();
                    data_et.setText(data_et.getText());
                    //data_et.setHint("DD/MM/YYYY");
                    data_et.setFocusable(true);
                    data_et.setFocusableInTouchMode(true);
                    data_et.requestFocusFromTouch();
                    //data_et.setFocusable(false);  These two, this and InTouchMode, caused an endless loop (had to kill)
                    //data_et.setFocusableInTouchMode(false);
                    data_et.setFocusable(true);
                    data_et.setFocusableInTouchMode(true);
                    data_et.requestFocus();
                    if(!data_et.isFocusable()) {
                        Log.i(Constants.LOG,"I am not Focusable even though id had both setFocusable and setFocusableInTouchMode set to true!!!!");
                    }
                    if(!data_et.isFocusableInTouchMode()) {
                        Log.i(Constants.LOG,"I am not FocusableInTouchMode even though id had both setFocusable and setFocusableInTouchMode set to true!!!!");
                    }
                    //data_et.requestFocus(View.FOCUS_UP,null);
                    return;
                }
                try {
                    Date date = sdf.parse(givendate);
                    long timestamp = date.getTime();
                    ((TextView) findViewById(R.id.apue_firstbuydate_check)).setText(Long.toString(timestamp));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
        }
    });

.....

public Emsg validateDate(String datetocheck) {
    Emsg retmsg = new Emsg(false, 0, "");
    // Valid Length Check ie must be a minimum of 8 characters in Length and a maximum of 10
    if(datetocheck.length() < 8 | datetocheck.length() > 10)  {
        retmsg.setAll(true, 1, "Invalid Length (must be 8-10) it was " + datetocheck.length());
        return retmsg;
    }
    return retmsg;
}

The xml (sorry for the length of this, the EditText in question is apue_productusage_firstbuydate_data and is about 2/3rds down) :-

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginStart="@dimen/activity_horizontal_margin"
    android:layout_marginLeft="@dimen/activity_horizontal_margin">
    <LinearLayout
        android:id="@+id/apue_shop_container"
        android:layout_width="match_parent"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_height="@dimen/standard_heading_height"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/apue_shopname_label"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text="@string/shopnamelabel"
            android:textSize="@dimen/standard_heading_text_size"
            android:textStyle="bold"/>
        <TextView
            android:id="@+id/apue_shopname_data"
            android:layout_width="500dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text=""
            android:textSize="@dimen/standard_listview_row_height"/>
        <TextView
            android:id="@+id/apue_shop_id"
            android:layout_width="@dimen/standard_realnumb_width"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:textSize="@dimen/standard_listview_row_height"
            android:textColor="@color/colorRequiredLabel"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_aisle_container"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_heading_height"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/apue_aislename_label"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text="@string/aislelabel"
            android:textSize="@dimen/standard_heading_text_size"
            android:textStyle="bold"/>
        <TextView
            android:id="@+id/apue_aislename_data"
            android:layout_width="500dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text=""
            android:textSize="@dimen/standard_listview_row_height"/>
        <TextView
            android:id="@+id/apue_aisle_id"
            android:layout_width="@dimen/standard_realnumb_width"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:textSize="@dimen/standard_listview_row_height"
            android:textColor="@color/colorRequiredLabel"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_product_container"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_heading_height"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/apue_product_label"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text="@string/productlabel"
            android:textSize="@dimen/standard_heading_text_size"
            android:textStyle="bold"/>
        <TextView
            android:id="@+id/apue_product_data"
            android:layout_width="500dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text=""
            android:textSize="@dimen/standard_listview_row_height"/>
        <TextView
            android:id="@+id/apue_product_id"
            android:layout_width="@dimen/standard_realnumb_width"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:textSize="@dimen/standard_listview_row_height"
            android:textColor="@color/colorRequiredLabel"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_productcost_container"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_heading_height"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/apue_productcost_label"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text="@string/productusage_cost_label"
            android:textSize="@dimen/standard_heading_text_size"
            android:textStyle="bold"/>
        <EditText
            android:id="@+id/apue_productcost_data"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:layout_width="@dimen/standard_realnumb_width"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text=""
            android:padding="0dp"
            android:textSize="@dimen/standard_listview_row_height"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_productusage_orderinaisle_container"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_heading_height"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/apue_product_orderinaisle_label"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text="@string/productusage_orderinaisle_label"
            android:textSize="@dimen/standard_heading_text_size"
            android:textStyle="bold"/>
        <EditText
            android:id="@+id/apue_productusage_orderinaisle_data"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:padding="0dp"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text=""
            android:textSize="@dimen/standard_listview_row_height"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_advancedoptions_explian_text_container"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_heading_height">
        <TextView
            android:id="@+id/apue_advancedoptions_explian_text"
            android:layout_width="match_parent"
            android:layout_height="@dimen/standard_subheading_height"
            android:text="@string/productusage_advanced_options_explanatory_text"
            android:textSize="@dimen/standard_subheading_text_size"
            android:textColor="@color/advancedinputoption"
            android:textStyle="bold|italic"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_productusage_buycount_container"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_heading_height"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/apue_product_buycount_label"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text="@string/productusage_buycount_label"
            android:textSize="@dimen/standard_heading_text_size"
            android:textStyle="bold|italic"
            android:textColor="@color/advancedinputoption"/>
        <EditText
            android:id="@+id/apue_productusage_buycount_data"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:padding="0dp"
            android:text=""
            android:textSize="@dimen/standard_listview_row_height"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_productusage_firstbuydate_container"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_heading_height"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/apue_product_firstbuydate_label"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text="@string/productusage_firstbuydate_label"
            android:textSize="@dimen/standard_heading_text_size"
            android:textStyle="bold|italic"
            android:textColor="@color/advancedinputoption"/>
        <EditText
            android:id="@+id/apue_productusage_firstbuydate_data"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text=""
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:padding="0dp"
            android:textSize="@dimen/standard_listview_row_height"/>
        <TextView
            android:id="@+id/apue_firstbuydate_check"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:padding="0dp"
            android:textSize="18dp"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_productusage_lastbuydate_container"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_heading_height"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/apue_product_lastbuydate_label"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text="@string/productusage_lastbuydate_label"
            android:textSize="@dimen/standard_heading_text_size"
            android:textStyle="bold|italic"
            android:textColor="@color/advancedinputoption"/>
        <EditText
            android:id="@+id/apue_productusage_lastbuydate_data"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text=""
            android:padding="0dp"
            android:textSize="@dimen/standard_listview_row_height"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_productusage_mincost_container"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_heading_height"
        android:orientation="horizontal">
        <TextView
            android:id="@+id/apue_product_mincost_label"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text="@string/productusage_mincost_label"
            android:textSize="@dimen/standard_heading_text_size"
            android:textStyle="bold|italic"
            android:textColor="@color/advancedinputoption"/>
        <EditText
            android:id="@+id/apue_productusage_mincost_data"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:singleLine="true"
            android:text=""
            android:padding="0dp"
            android:textSize="@dimen/standard_listview_row_height"/>
    </LinearLayout>
    <LinearLayout
        android:id="@+id/apue_actions"
        android:layout_width="match_parent"
        android:layout_height="@dimen/standard_button_height"
        android:gravity="right"
        android:orientation="horizontal">
        <Button
            android:id="@+id/apue_savechanges"
            android:layout_width="@dimen/standard_button_width"
            android:layout_height="@dimen/standard_button_height"
            android:backgroundTint="@color/colorNormalButton"
            android:textColor="@color/colorNormalButtonText"
            android:text="@string/standardsavebutton"/>
        <Button
            android:id="@+id/apue_advancedoptions"
            android:layout_width="@dimen/standard_button_width"
            android:layout_height="@dimen/standard_button_height"
            android:backgroundTint="@color/colorNormalButton"
            android:textColor="@color/colorNormalButtonText"
            android:text="@string/standardmoretext"
            android:onClick="apue_advancedoptions_flip"/>
        <Button
            android:id="@+id/apue_done"
            android:layout_width="@dimen/standard_button_width"
            android:layout_height="@dimen/standard_button_height"
            android:backgroundTint="@color/colorNormalButton"
            android:textColor="@color/colorNormalButtonText"
            android:text="@string/standarddonebutton"
            android:onClick="apue_done"/>
    </LinearLayout>
</LinearLayout>

Here's a typical log where I've change the date to an invalid date (note the isfocuable checks have never fired so the exclusions don't appear to apply as per

public final boolean requestFocus () Call this to try to give focus to a specific view or to one of its descendants and give it a hint about what direction focus is heading. A view will not actually take focus if it is not focusable (isFocusable() returns false), or if it is focusable and it is not focusable in touch mode (isFocusableInTouchMode()) while the device is in touch mode. From developer.android.com/intl/ko/reference/android/view/View.html#requestFocus()

Here's the log (The relevant part (The Focus Change messages) is from 22:38:27.192 which is around 3/4 of the way down):-

03-01 22:38:04.304 24757-24757/? I/Timeline: Timeline: Activity_launch_request id:mjt.shopper time:2150430366
03-01 22:38:04.305 769-1316/? V/ActivityManager: notify app switch for new activity mjt.shopper Where 1
03-01 22:38:04.306 769-1316/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=mjt.shopper/.MainActivity (has extras)} from uid 10025 on display 0
03-01 22:38:04.308 769-28600/? D/ActivityManager: notifyAppSwitch resumed: true; pkg:mjt.shopper
03-01 22:38:04.310 769-1316/? V/WindowManager: addAppToken: AppWindowToken{11fa5df1 token=Token{19a3f198 ActivityRecord{3fc47f7b u0 mjt.shopper/.MainActivity t1012}}} to stack=1 task=1012 at 0
03-01 22:38:04.323 769-795/? V/WindowManager: Adding window Window{22eb5bb0 u0 Starting mjt.shopper} at 3 of 9 (after Window{a17be98 u0 com.cyanogenmod.trebuchet/com.android.launcher3.Launcher})
03-01 22:38:04.396 769-32022/? I/ActivityManager: Start proc 28604:mjt.shopper/u0a121 for activity mjt.shopper/.MainActivity
03-01 22:38:04.530 28604-28604/? I/mjt.shopper:  onExpand started.
03-01 22:38:04.588 28604-28604/? I/mjt.shopper:  onExpand completed.
03-01 22:38:04.734 769-1347/? V/WindowManager: Adding window Window{b38efe5 u0 mjt.shopper/mjt.shopper.MainActivity} at 3 of 10 (before Window{22eb5bb0 u0 Starting mjt.shopper})
03-01 22:38:04.891 769-795/? I/ActivityManager: Displayed mjt.shopper/.MainActivity: +536ms
03-01 22:38:04.891 769-795/? I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord{3fc47f7b u0 mjt.shopper/.MainActivity t1012} time:2150430953
03-01 22:38:08.659 28604-28604/? I/Timeline: Timeline: Activity_launch_request id:mjt.shopper time:2150434722
03-01 22:38:08.660 769-9335/? V/ActivityManager: notify app switch for new activity mjt.shopper Where 0
03-01 22:38:08.661 769-9335/? I/ActivityManager: START u0 {cmp=mjt.shopper/.ShopListByCursorActivity (has extras)} from uid 10121 on display 0
03-01 22:38:08.667 769-9335/? V/WindowManager: addAppToken: AppWindowToken{1c1e369d token=Token{3dfa5174 ActivityRecord{2dd34547 u0 mjt.shopper/.ShopListByCursorActivity t1012}}} to stack=1 task=1012 at 1
03-01 22:38:08.679 769-1301/? D/AppOps: noteOperation: allowing code 11 uid 10121 package mjt.shopper
03-01 22:38:08.681 769-28630/? D/ActivityManager: notifyAppSwitch resumed: true; pkg:mjt.shopper
03-01 22:38:08.773 769-20945/? V/WindowManager: Adding window Window{2f2c9f99 u0 mjt.shopper/mjt.shopper.ShopListByCursorActivity} at 4 of 11 (after Window{b38efe5 u0 mjt.shopper/mjt.shopper.MainActivity})
03-01 22:38:09.284 769-795/? I/ActivityManager: Displayed mjt.shopper/.ShopListByCursorActivity: +592ms
03-01 22:38:09.491 769-795/? I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord{2dd34547 u0 mjt.shopper/.ShopListByCursorActivity t1012} time:2150435554
03-01 22:38:11.264 769-1180/? V/WindowManager: not Base app: Adding window Window{e120e37 u0 mjt.shopper/mjt.shopper.ShopListByCursorActivity} at 5 of 11
03-01 22:38:13.329 28604-28604/? I/Timeline: Timeline: Activity_launch_request id:mjt.shopper time:2150439392
03-01 22:38:13.331 769-1301/? V/ActivityManager: notify app switch for new activity mjt.shopper Where 0
03-01 22:38:13.331 769-1301/? I/ActivityManager: START u0 {cmp=mjt.shopper/.AddProductToShopActivity (has extras)} from uid 10121 on display 0
03-01 22:38:13.336 769-28645/? D/ActivityManager: notifyAppSwitch resumed: true; pkg:mjt.shopper
03-01 22:38:13.343 769-1301/? V/WindowManager: addAppToken: AppWindowToken{298e7210 token=Token{31ef56d3 ActivityRecord{d1398c2 u0 mjt.shopper/.AddProductToShopActivity t1012}}} to stack=1 task=1012 at 2
03-01 22:38:13.501 769-30333/? V/WindowManager: Adding window Window{164e8d2f u0 mjt.shopper/mjt.shopper.AddProductToShopActivity} at 5 of 11 (after Window{2f2c9f99 u0 mjt.shopper/mjt.shopper.ShopListByCursorActivity})
03-01 22:38:14.095 769-795/? I/ActivityManager: Displayed mjt.shopper/.AddProductToShopActivity: +721ms
03-01 22:38:14.268 769-795/? I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord{d1398c2 u0 mjt.shopper/.AddProductToShopActivity t1012} time:2150440331
03-01 22:38:17.189 769-785/? V/WindowManager: not Base app: Adding window Window{18b9ac3 u0 mjt.shopper/mjt.shopper.AddProductToShopActivity} at 6 of 12
03-01 22:38:21.695 769-1323/? D/AppOps: noteOperation: allowing code 11 uid 10121 package mjt.shopper
03-01 22:38:21.702 28604-28604/? I/Timeline: Timeline: Activity_launch_request id:mjt.shopper time:2150447764
03-01 22:38:21.703 769-32022/? V/ActivityManager: notify app switch for new activity mjt.shopper Where 0
03-01 22:38:21.704 769-32022/? I/ActivityManager: START u0 {cmp=mjt.shopper/.ProductUsageEdit (has extras)} from uid 10121 on display 0
03-01 22:38:21.715 769-28664/? D/ActivityManager: notifyAppSwitch resumed: true; pkg:mjt.shopper
03-01 22:38:21.721 769-32022/? V/WindowManager: addAppToken: AppWindowToken{24f3a1ca token=Token{2d14e935 ActivityRecord{5184f6c u0 mjt.shopper/.ProductUsageEdit t1012}}} to stack=1 task=1012 at 3
03-01 22:38:21.910 769-785/? V/WindowManager: Adding window Window{6ab2004 u0 mjt.shopper/mjt.shopper.ProductUsageEdit} at 6 of 13 (after Window{164e8d2f u0 mjt.shopper/mjt.shopper.AddProductToShopActivity})
03-01 22:38:22.036 769-795/? I/ActivityManager: Displayed mjt.shopper/.ProductUsageEdit: +273ms
03-01 22:38:22.243 769-795/? I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord{5184f6c u0 mjt.shopper/.ProductUsageEdit t1012} time:2150448306
03-01 22:38:27.192 28604-28604/? I/mjt.shopper: Focus Change Listener - Fired - Before Has Focus Check.
03-01 22:38:27.220 769-32022/? V/WindowManager: Adding window Window{3a989234 u0 PopupWindow:216f0592} at 7 of 13 (after Window{6ab2004 u0 mjt.shopper/mjt.shopper.ProductUsageEdit})
03-01 22:38:47.465 28604-28604/? I/mjt.shopper: Focus Change Listener - Fired - Before Has Focus Check.
03-01 22:38:47.465 28604-28604/? I/mjt.shopper: Focus Change Listener - Fired AND it isn't me that is focused.
03-01 22:38:47.487 28604-28604/? I/mjt.shopper: Focus Change Listener - Fired - Before Has Focus Check.
03-01 22:38:47.523 769-873/? V/WindowManager: Adding window Window{20591f6 u0 PopupWindow:ae45019} at 7 of 13 (after Window{6ab2004 u0 mjt.shopper/mjt.shopper.ProductUsageEdit})
03-01 22:38:52.016 769-9335/? V/WindowManager: Adding window Window{109fec9 u0 PopupWindow:581fabf} at 7 of 13 (after Window{6ab2004 u0 mjt.shopper/mjt.shopper.ProductUsageEdit})
By : MikeT


Answers

I have got around the issue by doing the validation and subsequent requestFocus outside of the onFocusChangeListener. Instead I invoke the validation and requestFocus via the Save button. However, this isn't the ideal situation as a number of EditTexts will need to be validated.

It appears that setting an EditText's focus, to itself, from within the respective EditText's OnFocusChangeListener is simply an undo-able.

By : MikeT


This video can help you solving your question :)
By: admin