1

我在一个 ActivityGroup 中有两个活动,一个是“ProvinceActivity”,另一个是“CityActivity”。所以代码:

public class CityManagerActivity extends ActivityGroup {
    View v1 = getLocalActivityManager().startActivity(
                "tab1",
                new Intent(this, ProvinceActivity.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
                .getDecorView();
    replaceView(v1);
}

但是当我通过按“tab1”中的搜索键进行默认搜索时,搜索我有错误:

08-19 17:18:23.438: ERROR/AndroidRuntime(9078): Uncaught handler: thread main exiting due to uncaught exception 
08-19 17:18:23.458: ERROR/AndroidRuntime(9078): java.lang.IllegalArgumentException: no ident 
08-19 17:18:23.458: ERROR/AndroidRuntime(9078):     at android.app.Activity.ensureSearchManager(Activity.java:3499) 
08-19 17:18:23.458: ERROR/AndroidRuntime(9078):     at android.app.Activity.startSearch(Activity.java:2648) 
08-19 17:18:23.458: ERROR/AndroidRuntime(9078):     at android.app.Activity.onSearchRequested(Activity.java:2612) ...

第二次搜索有效,告诉我怎么做,请...

4

2 回答 2

0

有同样的问题。我使用它,它解决了这个问题。

@Override
public boolean onSearchRequested() {
    return true;
}
于 2011-08-25T09:15:16.410 回答
0

对于其他人,我认为仅返回 true 应用程序会显示用户不期望的行为,因为它应该显示某种搜索,并且返回 true 会被覆盖。

文章http://www.app-solut.com/blog/2011/10/unexpected-behavior-when-working-with-nested-tabhosts/展示了如何在不更改默认值的情况下在 TabHost 中解决此问题的好方法行为。

于 2011-10-21T14:31:47.050 回答