我有这样的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/widget_frame"
android:orientation="vertical"
android:textAlignment="gravity" >
<FrameLayout
android:id="@+id/widget_details"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="@dimen/widget_spacing"
android:layout_marginLeft="@dimen/widget_spacing"
android:layout_marginRight="@dimen/widget_spacing"
android:background="@drawable/widget_background"
android:gravity="center_vertical"
android:padding="@dimen/widget_spacing" >
<ListView
android:id="@+id/image_flipper"
android:clickable="true"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
</FrameLayout>
</LinearLayout>
我正在附加一个未决意图:
RemoteViews remView = new RemoteViews(ctxContext.getPackageName(), R.layout.widget);
PendingIntent pitClick = WidgetHelpers.getClickIntent(ctxContext, getKlass(), intInstance);
remView.setOnClickPendingIntent(R.id.widget_details, pitClick);
AppWidgetManager.getInstance(ctxContext).updateAppWidget(intInstance, remView);
如果我将ListView
替换为AdapterViewFlipper
之类的其他视图,则可行,但由于某种原因,ListView
无法正确处理点击。使用ListView
时,如果我非常小心地点击边缘,我可以点击,但是当使用AdapterViewFlipper
时,整个内容都是可点击的。