我在菜單「desktop-> add-> widget->」中使用widgets時遇到了一些問題。 我不明白爲什麼我的小部件不能在小屏幕(ldpi)上訪問,以及它何時移動到SD卡上。 清單 Android,widgets無法使用的原因
<application android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:process="@string/app_name"
android:persistent="true" android:debuggable="false"
android:description="@string/app_desc">
<receiver android:name="widget.Widget_4_1" android:label="Rozmiar 4x1">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_provider_4_1" />
</receiver>
</application>
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:smallScreens="true"
android:normalScreens="true" android:largeScreens="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
控件提供者
<?xml version="1.0" encoding="utf-8" ?>
<appwidget-provider
xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="294dip"
android:initialLayout="@layout/widget41"
android:updatePeriodMillis="@string/UpdatePeriod"
android:minHeight="72dip"/>
佈局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Widget41"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:background="@drawable/frame41"
android:layout_width="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/widgettextview41"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center"
android:textColor="@android:color/black"
android:text="@string/widget_loading"
android:padding="10dip"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:textSize="5pt" />
</LinearLayout>
任何幫助表示讚賞
ldpi上的小部件問題仍然沒有解決(這個線索並沒有幫助)。感謝您提供有關「ShouldNot」的參考:) – zawart 2011-03-12 17:44:15
是您的提供商中的minWidth對於ldpi設備來說太大了嗎?把它回到一個更小的數字來測試 – SteelBytes 2011-03-15 08:28:23