与ListView和R.layout.main帮助(安卓) [英] help with listview and R.layout.main (Android)

查看:127
本文介绍了与ListView和R.layout.main帮助(安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即时通讯相当新的机器人,所以我道歉,如果这是一个小白上下的问题(:

im quite new to android, so i apologise if this is a noob-ish question (:

我设计我的下面发现这里的例子列表:的http://android-er.blogspot.com/2010/06/custom-arrayadapter-with-with-different.html

i designed my list following the example found here: http://android-er.blogspot.com/2010/06/custom-arrayadapter-with-with-different.html

但我想知道的是我将如何去有关添加的setContentView(R.layout.main),这样我就可以显示与列表中其他(XML)元素?

but what i would like to know is how would i go about adding setContentView(R.layout.main) so that i can display other (xml) elements along with the list?

感谢您的建议(:

推荐答案

您只需编辑您的main.xml看任何你希望它看起来,例如:

You just edit your main.xml to look whatever you want it to look, eg:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
  <View android:id="@+id/emptyview"
    android:layout_height="30dp"
    android:layout_width="fill_parent" 
  />
  <ListView android:id="@+id/listview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="true"
    android:stackFromBottom="true"
    android:layout_below="@id/emptyview"
    android:headerDividersEnabled="true"
  />
</RelativeLayout>  

改变你的活动范围只能活动,不ListActivity。最后,在你的活动,你就可以获取你的列表视图:

Change your activity to extend only Activity, not ListActivity. Finally, in your activity you can then fetch your list view with:

ListView list = (ListView) findViewById(R.id.listview);

和做任何你需要做的清单。

and do whatever you need to do with the list.

这篇关于与ListView和R.layout.main帮助(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆