如何隐藏控件。如果不支持Android的API? [英] How to hide Widget If not supported by Android API?

查看:89
本文介绍了如何隐藏控件。如果不支持Android的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在开发的多个部件,其中一人使用的ListView ListView的,但不支持Android 2.3的。
所以,如果我的应用程序在那个时候小部件应的ListView控件中的列表中未显示已安装的是Android 2.3。
但是,我认为小部件的ListView是显示在小部件的清单,如果我点击它比它让我强制关闭。

这就是为什么我要隐藏控件的列表中的那些部件。
如果任何人有任何建议,请回复。

这表明我强制关闭和窗口小部件
以下错误

一个widget我运行的Andr​​oid 4.2就说明我按下面的列表



谢谢你。

解决方案
  

我正在开发多个小部件

没有,你正在开发多个应用小工具。虽然我很抱歉,该条款是混乱的,这是非常重要的,你要使用正确的术语,你的问题。

  

其中一人使用的ListView ListView的,但不支持Android 2.3的。

正确的,的ListView 不支持应用小工具中的Andr​​oid 2.3或更低。

  

所以,如果我的应用程序在那个时候小部件应的ListView控件中的列表中未显示已安装的是Android 2.3。

步骤#1:创建一个 RES /价值/ bools.xml 文件,定义一个布尔资源,用的名称 is_honeycomb ,和值

第2步:创建一个 RES /值-V11 / bools.xml 文件,定义其他布尔资源,使用相同的名称( is_honeycomb ),和值

第三步:在您的清单,在<接收器> 元素 AppWidgetProvider 的使用的ListView 添加 Android的:启用=@布尔/ is_honeycomb

最终的效果是,在Android 3.0+设备,你的的ListView 应用程序插件将是一个可行的选择,但是在Android 2.3和更低的设备,它不会。


I am developing multiple widgets, One of them uses ListView but ListView is not supported by Android 2.3.
So, if my app is installed in Android 2.3 at that time widget with ListView should not display in widget's list.
But my that widget with ListView is showing in widget's list and if i click on it than it shows me Force Closed.

That's why i want to hide Those Widgets from widget's list.
If any one has any suggestions please reply.

It shows me Force Closed and following Error for widget


Same widget i run in Android 4.2 then it shows me as per following list



Thank you.

解决方案

I am developing multiple widgets

No, you are developing multiple app widgets. While I am sorry that the terms are confusing, it is very important for you to use the right terminology in your question.

One of them uses ListView but ListView is not supported by Android 2.3.

Correct, ListView is not supported in app widgets in Android 2.3 or lower.

So, if my app is installed in Android 2.3 at that time widget with ListView should not display in widget's list.

Step #1: Create a res/values/bools.xml file, defining a boolean resource, with a name of is_honeycomb, and a value of false.

Step #2: Create a res/values-v11/bools.xml file, defining another boolean resource, with the same name (is_honeycomb), and a value of true

Step #3: In your manifest, on the <receiver> element for the AppWidgetProvider that uses a ListView, add android:enabled="@bool/is_honeycomb".

The net effect is that on Android 3.0+ devices, your ListView app widget will be an available option, but on Android 2.3 and lower devices, it will not.

这篇关于如何隐藏控件。如果不支持Android的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆