如何在EditText验证后设置requestFocus

时间:2016-03-01 11:46:53

标签: java android xml validation android-layout

请注意,虽然这是一个重复的问题,但没有一个答案可行。

注意我已根据我添加的评论尝试了更多内容。简而言之,问题似乎是实际requestFocus()实际上禁用了需要编辑的EditText,因为验证发现数据无效。

我有一个包含6个EditText视图的活动。目前我正在研究用于修改日期的1。对于这个特定的EditText,我通过OnFocusChangedListener验证文本(目前这只是检查文本是8到10个字符)并且只有焦点已经转移到其他地方。

这似乎工作正常,对于有效日期(考虑到目前进行的非常有限的验证)显示的时间戳。这按预期发生。对于无效日期(即少于8个或超过10个字符)而不是时间戳,将显示一条消息。

但是,对于无效日期,我希望焦点重新回到EditText上。这是我遇到问题的地方。由于焦点不在于EditText。另外,据我所知,EditText无法手动获取Focus(永久性地见到以后)。

我将一些消息写入日志。一个是调用侦听器而另一个是遇到(!hasFocus)时。我相信,这些显示正在遵循逻辑/过程,而且requestFocus实际上将焦点放回EditText。因此,似乎有些事情正在把焦点拉开,而且我相信每当焦点放在EditText时就会这样做。

另一个奇怪/异常的情况是验证失败并尝试将焦点放在EditText上。光标在有问题的EditText和下面的EditText之间交替显示。

我在这里和其他地方查看过很多帖子(我目前打开了16个标签页)。我尝试了很多东西。我在所有LinearLayouts的开头以及XML中的所有EditTexts上都有focusable和focusableInTouchMode。我也在他的活动中设置了它们。我已经从XML中删除了输入类型(这是一张海报得出的结论)。另一个建议将两个焦点都设置为false,然后再设置为true。我尝试了这个,结果是听众被无休止地召唤。我已经转向使用Swift软键盘并使用默认值,结果是一样的。

无论如何这里是代码(目前将焦点设置为真两次)。

    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;
}

xml(对不起,有问题的EditText是apue_productusage_firstbuydate_data,大约是2 / 3rds): -

<?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>

这是一个典型的日志,我将日期更改为无效日期(请注意,此类错误检查从未触发过,因此排除项似乎不会按照

进行申请
  

public final boolean requestFocus()   调用此方法以尝试将焦点放在特定视图或其中一个视图上   后代并给出一个关于焦点方向的暗示。   如果视图不可聚焦,则视图实际上不会成为焦点   (isFocusable()返回false),或者它是可聚焦的而不是   设备可以在触摸模式(isFocusableInTouchMode())中进行聚焦   在触摸模式。   来自developer.android.com/intl/ko/reference/android/view/View.html#requestFocus()

这里是日志(相关部分(焦点变化信息)来自22:38:27.192,大概是3/4左右): -

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})

1 个答案:

答案 0 :(得分:0)

我通过在onFocusChangeListener之外进行验证和后续requestFocus解决了这个问题。相反,我通过“保存”按钮调用验证和requestFocus。但是,这不是理想情况,因为需要验证许多EditTexts。

看来,在各自的EditText的OnFocusChangeListener中设置EditText的焦点,只是一个可撤销的。