帮助ListView透明度

我已经设置了四个选项卡,每个选项卡都有一个列表视图,我在listview java文件中添加了代码以使列表透明,但是,我有一个覆盖屏幕75%的半透明灰色框,我无法弄清楚为什么,我在我的其他列表视图上有一个背景,并且它们是完全透明的,但tabhost中的列表具有灰色框。

<?xml version="1.0" encoding="utf-8"?>

android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<LinearLayout
    android:orientation="vertical"
   android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="2dp">
   <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="3dp"
        android:layout_weight="1"/>

    <TabWidget
        android:id="@android:id/tabs"
       android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"/>

导入android.app.TabActivity; 导入android.content.Intent; 导入android.content.res.Resources; 导入android.os.Bundle; 导入android.widget.TabHost;

公共类标签扩展TabActivity {@Override公共无效的onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState); 的setContentView(R.layout.main);

    Resources res = getResources(); // Resource object to get Draw
    TabHost tabHost = getTabHost();  // The activity TabHost
    TabHost.TabSpec spec;  // Reusable TabSpec for each tab
    Intent intent;  // Reusable Intent for each tab

    // Create an Intent to launch an Activity for the tab (to be reused)
    intent = new Intent().setClass(this, prem.class);

    // Initialise a TabSpec for each tab and add it to the TabHost
    spec = tabHost.newTabSpec("Prem").setIndicator("Prem",
                      res.getDrawable(R.drawable.icontabs))
                  .setContent(intent);
    tabHost.addTab(spec);

    // Create an Intent to launch an Activity for the tab (to be reused)
    intent = new Intent().setClass(this, champ.class);

    // Initialise a TabSpec for each tab and add it to the TabHost
    spec = tabHost.newTabSpec("Champ").setIndicator("Champ",
                      res.getDrawable(R.drawable.champ))
                  .setContent(intent);
    tabHost.addTab(spec);


    // Do the same for the other tabs
    intent = new Intent().setClass(this, l1.class);
    spec = tabHost.newTabSpec("League 1").setIndicator("L",
                      res.getDrawable(R.drawable.l1))
                  .setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, ll2.class);
    spec = tabHost.newTabSpec("l2").setIndicator("Le",
                      res.getDrawable(R.drawable.l2))
                  .setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(0);
}

}

enter code hepublic class l1 extends ListActivity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    // Create an array of Strings, that will be put to our ListActivity
    String[] names = new String[] {"Le"};
    ListView lv = getListView();  
    lv.setBackgroundResource(R.drawable.le2);
    lv.setCacheColorHint(00000000); 
    this.setListAdapter(new ArrayAdapter<String>(this,
            R.layout.list_item, names));
}

// Get the item that was clicked
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
      if (position == 0) {re

有任何想法吗

提前致谢


在您的布局XML文件中,您的标签内容( FrameLayout )应位于标签小部件之后,而不是之前。 有可能您看到的框是标签部件的背景。

喜欢这个:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
    </LinearLayout>
</TabHost>
链接地址: http://www.djcxy.com/p/26229.html

上一篇: Help with ListView transparency

下一篇: Tab bar application with Menu Item