English 中文(简体)
如何为1.6和3.0+提供不同的海底植被?
原标题:how to provide different android widget for 1.6 and 3.0+?

I am targeting 1.6 but I would like to have nice widget that can use stackview and other improvement Android SDK provides for widget if user is on 3.0 above device. and a plain widget on 1.6-2.3/

我应怎样做这两个版本的植被?

感谢很多人

最佳回答

我的建议:

创建两种植被,利用资源价值方法实现/处置。

转口/价值/包料:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="atLeastHoneycomb">false</bool>
    <bool name="notHoneycomb">true</bool>
</resources>

页: 1

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="atLeastHoneycomb">true</bool>
    <bool name="notHoneycomb">false</bool>
</resources>

注:

<receiver android:name="MyOldAppWidgetProvider"
          android:enabled="@bool/notHoneycomb">

    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
    </intent-filter>
    <meta-data android:name="android.appwidget.provider"
               android:resource="@xml/example_oldappwidget_info" />
</receiver>

<receiver android:name="MyNewAppWidgetProvider"
          android:enabled="@bool/atLeastHoneycomb">

    <intent-filter>
        <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
    </intent-filter>
    <meta-data android:name="android.appwidget.provider"
               android:resource="@xml/example_newappwidget_info" />
</receiver>
问题回答

您可在res上打分。 特定目录,添加像<代码>-v11这样的斜体。

例如,将你的布局称为main.xml。 可在<代码>layout/code>上填上你的1.6-2.3码>main.xml文档,然后将新的正文(main.xml文档列入layout-v11。 在使用Honeycomb和编造时,填写在-v11。 请参看R.layout.main等你的档案时选择文件夹。

从那以后,您的活动中可以有某种逻辑,即检查您的新植被物的存在(或仅检查Build.VERIONS

For more details on this, check out the Qualifier name rules from the Android documentation.

You can check the device api version like:

int apiLevel = android.os.Build.VERSION.SDK_INT;

从复印件的水平来看,如果是,你可以用来为不同的复印件/照片装上不同的布局。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签