2013-02-19 41 views
1

我在我的應用程序的ListActivity中使用的自定義ListView出現問題。我的問題是,通過ArrayAdapter添加到ListView的所有TextView項目都顯示上面有一個灰色條。我會包含顯示的ListView的圖像,但我無法使用,因爲我沒有計算器站點所需的10的聲望。自定義ListView TextView項目全部顯示頂部的灰色欄

佈局文件(INDEX.XML)用於生產的ListView定義如下:

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

    <ListView 
     android:divider="@color/mg_red" 
     android:dividerHeight="1sp" 
     android:id="@android:id/list" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" /> 


    <TextView 
     android:title="text_view" 
     android:background="@drawable/listitemback" 
     android:cacheColorHint="@drawable/listitemback" 
     android:id="@+id/listItem" 
     android:layout_width="fill_parent"  
     android:layout_height="fill_parent" 
     android:padding="10sp"  
     android:textColor="@color/listitemtext" 
     android:textSize="16sp" />  

</LinearLayout> 

用於顯示列表中的ListActivity代碼如下:

public class IndexListActivity extends ListActivity 
{ 
    private ListView m_listView = null; 

    @Override 
    public void onCreate(Bundle savedInstanceState) 
    {  
     try 
     { 
      if (MGApplication.DEBUG_BUILD) 
      Log.i("TMG", "IndexListActivity.onCreate"); 

     super.onCreate(savedInstanceState); 

     // Get our global data object. 
     MGApplication mgApp = (MGApplication) getApplication(); 

     // Set view layout 
     SetContentView(R.layout.index); 

     // Get references to our ListView and AdView objects 
     m_listView = (ListView) findViewById(android.R.id.list); 


      // Create a new ArrayAdapter object that will be used to initialize 
     // the underlying ListView object. 
     ArrayAdapter<String> aa = new ArrayAdapter<String>(this, R.layout.index, 
                   R.id.listItem, 
                   mgApp.m_strAZRhymeNames); 

     // Assign array adapter 
     m_listView.setAdapter(aa); 
     }   
     catch (Exception e) 
     { 
     } 

     return; 
    } 
} 

任何幫助非常感謝,因爲我在這個問題上很有智慧。我想我已經嘗試了所有可以在網絡上找到的建議,但我無法刪除灰色條。

謝謝你,

鮑勃

+0

您使用哪種語言? – 2013-02-19 00:58:47

+0

你可以試試這個android:scrollingCache =「false」 – Harshid 2013-02-19 04:59:33

回答

0

你有的test.xml文件與設置該屬性。

 <ListView 
      android:id="@+id/listview_middle" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_margin="1dip" 
      android:layout_weight="1" 
      android:background="#ffffff" 
      android:cacheColorHint="@android:color/transparent" 
      android:choiceMode="singleChoice" 
      android:scrollingCache="false" /> 

,並設置在列表視圖對象某些屬性。

lv.setVerticalFadingEdgeEnabled(false); 

在我身邊這是完美的工作。

+0

你所識別的附加ListView屬性都不正確,我看到的問題。 – Bob 2013-02-19 15:26:10

相關問題