Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 列表视图的选择器_Android_Xml_List_Android Layout_Selector - Fatal编程技术网

Android 列表视图的选择器

Android 列表视图的选择器,android,xml,list,android-layout,selector,Android,Xml,List,Android Layout,Selector,我有一个用于列表视图不同状态的选择器。我为背景选择了灰色,但它不工作,按下状态正常,但我的列表视图背景仍为白色,当我选择列表项时,其颜色变为灰色,我为背景选择了灰色,背景仍为白色。 请帮忙,很抱歉这个愚蠢的问题,因为我是android新手。 我的列表视图是: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/androi

我有一个用于列表视图不同状态的选择器。我为背景选择了灰色,但它不工作,按下状态正常,但我的列表视图背景仍为白色,当我选择列表项时,其颜色变为灰色,我为背景选择了灰色,背景仍为白色。 请帮忙,很抱歉这个愚蠢的问题,因为我是android新手。 我的列表视图是:

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

   android:background="?android:attr/activatedBackgroundIndicator">


  <ListView
      android:id="@android:id/list"
      android:layout_width="match_parent"
      android:layout_height="match_parent" 
    android:divider="#b5b5b5"
      android:dividerHeight="1dp"
      android:listSelector="@drawable/list_selector">

  </ListView>

        </FrameLayout>

选择器xml是:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
     android:state_selected="false"
        android:state_pressed="false"
        android:drawable="@drawable/gradient_bg" />
    <item android:state_pressed="true"
        android:drawable="@drawable/gradient_bg_hover" />
    <item android:state_selected="true"
     android:state_pressed="false"
        android:drawable="@drawable/gradient_bg_hover" />
</selector> 

状态xml为:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <gradient
      android:startColor="#78DDFF"
      android:centerColor="#16cedb"
      android:endColor="#09adb9"
      android:angle="270" />
</shape>

背景xml是:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
  <gradient
      android:startColor="#D5DDE0"
      android:centerColor="#e7e7e8"
      android:endColor="#CFCFCF"
      android:angle="270" />
</shape>

将选择器应用于ListView项,我指的是row.xml的viewgroup或您为ListView项定义的任何名称