这个listview哪错了。 看看 cat里面有没有什么提示啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1 layout R.layout.main2 new SimpleAdapter(this, list,R.layout.user, new String[] { "name", "ip" }, new int[] {R.id.name, R.id.ip }); 你的xml文件仔细检查下, 就是这个出的问题, 我觉得。 setContentView(R.layout.main);这句有问题,需要检查main.xml的布局。 请LZ注意,你既然继承的是 ListActivity 不是 Activity,ListActivity 中没有 setContentView()所以出错了,要继承 ListActivity ,你就要用setListAdapter(listadapter) 方法 到2就挂了?logcat输出什么?肯定是R.layout.main的问题,贴出来看看 这是main.xml中的内容:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/linear" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <ListView android:id="@+id/listview" android:layout_width="fill_parent" android:layout_height="wrap_content" android:drawSelectorOnTop="false" android:scrollbars="vertical" /> </LinearLayout></LinearLayout>看6楼说的,把setContentView(R.layout.main);注释掉了。就可以运行了。可是我的那个教程里是有这句,同样可以运行。 注意,如果从ListActivity可以不需要这句了,默认就是listview的activity了 这个书和APIDemo要互相参考着看,你比较看看书上的例子到底有什么不同没,可能一个很小的不同就导致结果出问题 <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" ><ListView android:id="@+id/listview"android:layout_width="fill_parent"android:layout_height="wrap_content"android:drawSelectorOnTop="false"android:scrollbars="vertical"/></LinearLayout>试试 widget添加至桌面代码怎么实现 用webview写了个简单的浏览器(暂时这么叫吧),地址栏网址一定要输全,就是要加http,怎么弄不加http也能解析啊 百度android地图,要以当前位置为圆心画个半径200米的圆,代码怎么写 关于模拟同步下载,出了点状况 APK更新问题? 分享快速入门android应用开发的心得 怎样push一个c语言开发的程序到Android下去用 求助一下,android已停止运行 新手求助,新建工程时问题!! intent.putExtra参数问题 BREW和Android的安全思想 Android1.5和2.1系统的OPENGL ES版本
R.layout.user, new String[] { "name", "ip" }, new int[] {
R.id.name, R.id.ip });
这句有问题,需要检查main.xml的布局。
肯定是R.layout.main的问题,贴出来看看
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout android:id="@+id/linear"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ListView android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
android:scrollbars="vertical"
/>
</LinearLayout>
</LinearLayout>看6楼说的,把setContentView(R.layout.main);注释掉了。就可以运行了。
可是我的那个教程里是有这句,同样可以运行。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
android:scrollbars="vertical"
/>
</LinearLayout>试试