在Android中我要在Tab中掉用List
(这里面要求:list和Tab用同一个Activity)
哪位高手给个方案?
(这里面要求:list和Tab用同一个Activity)
哪位高手给个方案?
解决方案 »
- 地球已经不能阻止安卓了!安卓安装模拟xp/98系统、不是美化!
- 求助关于DevicePolicyManager的问题
- 求助:关于用Intent传递List<>类型的问题
- 再问谷歌地图的离线保存/读取
- layout_gravity的问题
- android源码定制之初探--定制android关机界面
- 通过Button获取EditText中的数据并保存怎么实现
- 编译最新版本的android2.2,找不到javax.tools包,编译报错
- Android 多点触控和单点触控同时进行的问题
- 求帮助~~有谁使用过百度的API来定位显示当前的城市呢?
- 文件下载问题
- 关于Android团队开发运行Activity问题(eclipse + vss)
TabHost tabhost = getTabHost();
LayoutInflater.from(this).inflate(R.layout.listview, tabhost.getTabContentView(), true);
tabhost.addTab(tabhost.newTabSpec("tab1").
setIndicator("手机").setContent(R.id.phone));
//R.id.phone是在layout中的包含list区域的layout 的id
phoneListView = (ListView)findViewById(R.id.phoneList);
//R.id.phonelist是在layout中的包含listView 的id
ArrayAdapter<String> adapterPhone = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, data);
phoneListView.setAdapter(adapterPhone);xml:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/phone"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/phoneList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView android:id="@+id/phone_empty"
android:background="@drawable/sample_0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No files found!"/>
</LinearLayout>
<LinearLayout android:id="@+id/sdcard"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/sdcardList"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView android:id="@+id/sdcard_empty"
android:background="@drawable/sample_0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="No files found!"/>
</LinearLayout>
</FrameLayout>
FrameLayout的目地是将下面的两个区与实现重叠显示
看代码吧.
谢谢,list的使用我还有很多东西要学啊.呵呵!
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); final TabHost tabHost = getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("demo1")
.setContent(new Intent(this, demo1Activity.class)));
tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("demo2")
.setContent(new Intent(this, demo2Activity.class))); }
}demo1Activity与demo2Activity是两个activity,你在它们里面用列表用啥ui组件都行。
tab中的每项项页面上都是一个activity,至于楼主说的要“list和Tab用同一个Activity”不太明白楼主要表达什么意思
demo2Activity不就是你为了显示list重新定义的一个activity吗?
谁能帮忙解释下这句代码的意思,尤其是List<? extends Map <String,?>> 是什么类型啊?
List<? extends Map <String,?>> 是什么类型啊?