为什么我的ListActivity似乎已停用且未响应点击?

时间:2014-02-23 23:16:11

标签: android

更新:我发现这仅仅是因为API 19的默认主题设置。花费数小时追逐它非常令人沮丧。 在styles.xml中,主题被设置为android:Theme.Light坦率地说,这是一个糟糕的风格 - 不可读并且小部件显示为禁用!

screenshot of list activity appearing disabled

MyListActivity扩展了ListActivity,它的适配器是一个扩展BaseAdapter的列表适配器。 但是,列表项显示为禁用,文本几乎不可见,实际上,未调用重写的onListItemClick()。从Ewoks的SO回答中,我设置了

android:descendantFocusability="blocksDescendants"

我可以点击它。但是,列表显示为禁用,文本几乎不可见。

列表项XML如下:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" 
    android:descendantFocusability="blocksDescendants">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="first line of message..."
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <ToggleButton
        android:id="@+id/on_off"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/repeatDays"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:text="on/off" />

    <TextView
        android:id="@+id/repeatDays"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/end_time"
        android:text="S M T W T F S"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/periodic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/start_time"
        android:layout_alignBottom="@+id/start_time"
        android:layout_alignParentLeft="true"
        android:text="periodic"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/duration"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/on_off"
        android:layout_toLeftOf="@+id/on_off"
        android:text="duration"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/start_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/title"
        android:layout_marginLeft="14dp"
        android:layout_toRightOf="@+id/periodic"
        android:text="start time"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <TextView
        android:id="@+id/end_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/start_time"
        android:layout_centerHorizontal="true"
        android:text="end time"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</RelativeLayout>

0 个答案:

没有答案