我想知道是否有一种暂时做到的方法,以便无法暂时使用搜索视图来输入但仍然可以看到。我宁愿这样做,也不愿一遍又一遍地重新创建不同的动作栏。
更新:这两个答案都在这里工作是stacktrace:
05-08 18:51:38.981 18963-18963/com.parse.starter W/ResourceType﹕ No package identifier when getting value for resource number 0x00000001
05-08 18:51:38.989 18963-18963/com.parse.starter W/ImageView﹕ Unable to find resource: 1
android.content.res.Resources$NotFoundException: Resource ID #0x1
at android.content.res.Resources.getValue(Resources.java:1019)
at android.content.res.Resources.getDrawable(Resources.java:663)
at android.widget.ImageView.resolveUri(ImageView.java:542)
at android.widget.ImageView.onMeasure(ImageView.java:647)
at android.view.View.measure(View.java:12752)
at android.widget.RelativeLayout.measureChild(RelativeLayout.java:579)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:392)
at android.view.View.measure(View.java:12752)
at android.widget.ListView.measureScrapChild(ListView.java:1181)
at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
at android.widget.ListView.onMeasure(ListView.java:1155)
at android.view.View.measure(View.java:12752)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376)
at android.view.View.measure(View.java:12752)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
at android.view.View.measure(View.java:12752)
at android.widget.RelativeLayout.measureChild(RelativeLayout.java:579)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:392)
at android.view.View.measure(View.java:12752)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:848)
at android.view.View.measure(View.java:12752)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
at android.view.View.measure(View.java:12752)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
at android.view.View.measure(View.java:12752)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2267)
at android.view.View.measure(View.java:12752)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1074)
at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2462)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4558)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
您可以轻松地启用和禁用onCreateOptionsMenu
中的菜单项。只需获取您的搜索视图并放置setEnabled(false)
,例如:
MenuItem item= menu.findItem(R.id.action_search);
item.setEnabled(false);
我希望这对您有帮助。
来自http://developer.android.com/reference/Randroid/android/widget/searchview.html
对于值0x00000000-没有内容类型。文本不是可编辑的。
所以尝试一下:
mSearchView.setInputType(0x00000000);
并切换回编辑:
mSearchView.setInputType(0x00000001);