2012-11-29 45 views
1

我有它擴展了Dialog類和一個簡單的自定義佈局像一個從下自定義對話框:Android的軌跡球在自定義對話框

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@android:drawable/list_selector_background" 
    > 


<TextView 
     android:id="@+id/text_view" 
     android:layout_width="fill_parent" 
     android:layout_height="50dp" 
     android:gravity="center_vertical" 
     android:paddingLeft="10dp" 
     android:background="@color/transparent" 
     android:textColor="@color/black" 
     android:textSize="16sp" 
     android:focusable="true"/> 

我的問題是軌跡球使文本不當選中一行時,就可以看到該圖像。

enter image description here

的list_selector_background代碼是從Android和它看起來像這樣:

<?xml version="1.0" encoding="utf-8"?> 
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - >

<item android:state_window_focused="false" android:drawable="@color/transparent" /> 

<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. --> 
<item android:state_focused="true" android:state_enabled="false" android:state_pressed="true" android:drawable="@drawable/list_selector_background_disabled" /> 
<item android:state_focused="true" android:state_enabled="false"        android:drawable="@drawable/list_selector_background_disabled" /> 
<item android:state_focused="true"        android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" /> 
<item android:state_focused="false"        android:state_pressed="true" android:drawable="@drawable/list_selector_background_transition" /> 
<item android:state_focused="true"                android:drawable="@drawable/list_selector_background_focus" /> 

而且我的ListView XML代碼是這樣的:

<ListView xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:drawSelectorOnTop="true" 
      android:background="@color/white" 
      android:cacheColorHint="@color/transparent"> 

</ListView> 

我看到上AlertDialog(一於Android)好的工作。我該怎麼做才能解決這個問題?

謝謝

+0

這一項工作是所選擇的顏色,添加圖像? – kittu88

+0

我還沒有設置任何圖片供您選擇。我猜是Android的默認顏色... – Laura

+0

android:background =「@ android:drawable/list_selector_background」你在這裏有什麼樣的圖像? – kittu88

回答

0

試試這個:從這一行刪除「android」文本。喜歡;

android:background="@drawable/list_selector_background" 

在列表視圖

android:cacheColorHint="@android:color/transparent" 
android:drawSelectorOnTop="false" 
android:listSelector="@android:color/transparent" 
android:fadingEdge="none" 

+0

我已經嘗試過,但它沒有工作:(我真的不知道問題可能是什麼 – Laura

+0

在AlertDialog中使用listview嗎 – Maulik

+0

是的,我使用的是一個列表視圖 – Laura