Java Android中的ListView透明性
我设置了四个选项卡,每个选项卡上都有一个listview,我在listview java文件中添加了代码以使列表透明,但是,我有一个半透明的灰色框,覆盖了75%的屏幕,我不知道为什么,我在其他listview上有一个背景,它们是完全透明的,但是tabhost中的列表具有灰色框Java Android中的ListView透明性,java,android,Java,Android,我设置了四个选项卡,每个选项卡上都有一个listview,我在listview java文件中添加了代码以使列表透明,但是,我有一个半透明的灰色框,覆盖了75%的屏幕,我不知道为什么,我在其他listview上有一个背景,它们是完全透明的,但是tabhost中的列表具有灰色框 <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/andr
<?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"
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"/>
</LinearLayout>
</TabHost>
导入android.app.TabActivity;
导入android.content.Intent;
导入android.content.res.Resources;
导入android.os.Bundle;
导入android.widget.TabHost;
公共类选项卡扩展了TabActivity{
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res=getResources();//要绘制的资源对象
TabHost TabHost=getTabHost();//活动TabHost
TabHost.TabSpec;//每个选项卡可重复使用的TabSpec
意图;//每个选项卡的可重用意图
//创建为选项卡启动活动的意图(要重用)
intent=new intent().setClass(this,prem.class);
//为每个选项卡初始化TabSpec并将其添加到TabHost
spec=tabHost.newTabSpec(“Prem”).setIndicator(“Prem”,
res.getDrawable(R.drawable.icontab))
.setContent(意图);
tabHost.addTab(spec);
//创建为选项卡启动活动的意图(要重用)
intent=new intent().setClass(this,champ.class);
//为每个选项卡初始化TabSpec并将其添加到TabHost
spec=tabHost.newTabSpec(“Champ”).setIndicator(“Champ”,
res.getDrawable(R.drawable.champ))
.setContent(意图);
tabHost.addTab(spec);
//对其他选项卡执行相同的操作
intent=newintent().setClass(这是l1.class);
spec=tabHost.newTabSpec(“联赛1”).setIndicator(“L”,
res.getDrawable(R.drawable.l1))
.setContent(意图);
tabHost.addTab(spec);
intent=newintent().setClass(this,ll2.class);
spec=tabHost.newTabSpec(“l2”).setIndicator(“Le”,
res.getDrawable(R.drawable.l2))
.setContent(意图);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}
公共类l1扩展了ListActivity{
/**在首次创建活动时调用*/
@凌驾
创建公共空间(捆绑冰柱){
超级冰柱;
//创建一个字符串数组,将其放入我们的ListActivity
字符串[]名称=新字符串[]{“Le”};
ListView lv=getListView();
lv.退耕地资源(R.可提取的le2);
lv.setCacheColorHint(00000000);
此.setListAdapter(新阵列适配器)(此,
R.layout.list_项目、名称);
}
//获取已单击的项目
@凌驾
public void onListItemClick(列表视图l、视图v、整数位置、长id){
如果(位置==0){
在布局XML文件中,选项卡内容(框架布局)应该在选项卡小部件之后,而不是之前。您看到的框可能是选项卡小部件的背景
像这样:
<?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>
缺少代码的结尾。
<?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>