Android中List的调用方式 在Android中我要在Tab中掉用List(这里面要求:list和Tab用同一个Activity)哪位高手给个方案? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Activity: 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的使用我还有很多东西要学啊.呵呵! public class demo extends TabActivity { @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”不太明白楼主要表达什么意思 就是不用你说的这个方式,setContent(new Intent(this, demo2Activity.class)));demo2Activity不就是你为了显示list重新定义的一个activity吗? public List<? extends Map <String,?>> generateDataList();谁能帮忙解释下这句代码的意思,尤其是List<? extends Map <String,?>> 是什么类型啊?List<? extends Map <String,?>> 是什么类型啊? 如何设置imageView的高和宽? 电脑上的一个软件通过usb数据线获得手机的来电然后显示在电脑上,能实现吗?在线等 TextView.setText疑问 AES 在不同平台下的加密和解密错误 android:allowClearUserData textview一行最多可以容纳多少个字符 求教~这个小程序为什么崩溃~在线等~~ 请教一个关于ffmpeg Deinterlace的问题 关于ListActivity中的CheckBox fragment模拟tab标签 文件下载问题 关于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,?>> 是什么类型啊?