完整行可点击主屏幕小部件

时间:2013-08-05 18:21:09

标签: android android-listview android-appwidget

我已经构建了一个主屏幕小部件,它使用列表视图和列表项,其相对布局包含两个文本视图和一个图像视图。我想要的是,当您单击列表视图中的项目时,应选择完整项目,而不是现在只选择您点击的文本视图或图像视图。我怎样才能做到这一点?我尝试了一些东西,但没有任何效果。贝娄是一张图片,展示了它现在的样子。

Only row two is selected

这是小部件布局,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="0dp"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#80FFFFFF"
    android:orientation="horizontal" >

    <ImageView
        android:id="@android:id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:contentDescription="@string/widget_icon_description"
        android:src="@drawable/ic_logo" />

    <TextView
        android:id="@android:id/text1"
        style="@android:style/TextAppearance.DeviceDefault.Large.Inverse"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:gravity="center_vertical"
        android:text="@string/widget_list_heading"
        android:textIsSelectable="false" />
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/holo_blue_bright"
    android:paddingBottom="2dp" >
</LinearLayout>

<ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="0dip"
    android:layout_marginBottom="0dp"
    android:layout_weight="1"
    android:background="#f1f1f1"
    android:listSelector="@android:color/holo_blue_bright"
    android:paddingBottom="0dp" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/holo_blue_bright"
    android:paddingBottom="2dp" >
</LinearLayout>

这是列表视图项目布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:background="@drawable/list_selector_background_light" >

<TextView
    android:id="@android:id/text1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMediumInverse"
    android:textIsSelectable="false"
    android:textStyle="bold" />

<TextView
    android:id="@android:id/text2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@android:id/text1"
    android:layout_below="@android:id/text1"
    android:textAppearance="?android:attr/textAppearanceSmallInverse"
    android:textIsSelectable="false" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="right"
    android:paddingRight="10dip"
    android:paddingTop="8dip" >

    <ImageView
        android:id="@android:id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:contentDescription="@string/expandable_heading_list_item_image_description" />
</LinearLayout>

/尤

1 个答案:

答案 0 :(得分:0)

好的,现在找到了解决方案,在提问后13分钟...刚刚将“android:clickable = true”添加到列表视图项中的相对布局,并将“android:clickable = false”添加到子项布局,从文本视图和图像视图中删除所有挂起的意图,并将其添加到相对布局。意图不起作用,但希望可以解决的问题。

/尤

相关问题