好吧,我投降了,这个问题折磨了我一天啊!!!!!!

Andy韩 2010-10-17 01:44:43
各位高手帮我看看吧。我写的显示ListView的例子始终被显示出错。。。。我也查不出错误在哪。
我的Activity代码:
public class ShowAllItem extends ListActivity {
/** Called when the activity is first created. */

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showall);
List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
HashMap<String, String> map1 = new HashMap<String, String>();
HashMap<String, String> map2 = new HashMap<String, String>();
HashMap<String, String> map3 = new HashMap<String, String>();
map1.put("user_name", "zhangsan");
map1.put("user_ip", "192.168.0.1");
map2.put("user_name", "zhangsan");
map2.put("user_ip", "192.168.0.2");
map3.put("user_name", "wangwu");
map3.put("user_ip", "192.168.0.3");
list.add(map1);
list.add(map2);
list.add(map3);
SimpleAdapter listAdapter = new SimpleAdapter(this, list,
R.layout.showallitem, new String[] { "user_name", "user_ip" },
new int[] { R.id.user_name,R.id.user_ip});
setListAdapter(listAdapter);
}
}

我的showall.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">
<ListView android:id="@+id/list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:drawSelectorOnTop="false"
android:scrollbars="vertical" />
</LinearLayout>

我的showallitem.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="horizontal" android:paddingLeft="10dip"
android:paddingRight="10dip" android:paddingTop="1dip"
android:paddingBottom="1dip">
<TextView android:id="@+id/user_name" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textSize="10pt"
android:singleLine="true" />
<TextView android:id="@+id/user_ip" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:gravity="right"
android:textSize="10pt" />
</LinearLayout>




说明一点这些代码在另一个程序中就可以运行,我试过了,可是我放在我现在正在开发的程序中就不能运行了,不知道为什么,我还试过将这段代码放在一个按钮事件中去调用Activity的方法运行,还是不行。我也试过把自己的项目中的其他文件都删除就留下和ListView相关联的文件,还是不能运行。。而我看过报错,没说什么异常,就是说第几行出错了。。。。我很郁闷,这个问题搞了我一天。

我这一天都在忙着解决这个问题,还是没有用,我实在不知道该怎么办了。。。。。。。希望能有高人或者以前有过类似经历的人给我讲讲是怎么回事,我真的被这个问题打败了。。。


你们也可以把你们的邮箱发给我,我发给你们你们帮我看看,然后在给我讲讲,谢谢了~~~~~~~~~~~
...全文
141 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 archko 的回复:]
<ListView android:id="@+id/list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:drawSelectorOnTop="false"
android:scrollbars="vertical" />
这个不对,因为你继承了ListActivity所以……
[/Quote]

应该是!楼主试下!
archko 2010-10-17
  • 打赏
  • 举报
回复
<ListView android:id="@+id/list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:drawSelectorOnTop="false"
android:scrollbars="vertical" />
这个不对,因为你继承了ListActivity所以它的ID不是这样的.android:id/list..
改成:<ListView android:id="@id/android:list"
随着通信电子技术的迅速发展,信息技术给家居行业产生了深远的影响,家居环境的智能化监控已经成为智能家居的一个重要的发展方向。人们逐渐对自己的生活提出一种更高的要求,他们需要一种智能化、可交互,并且融合现代创新科技的产品来改善他们的生活环境,使他们生活更加安全、舒适、便捷、智能。本文根据智能家居的发展背景和研究现状,并且从实用性和可行性角度出发,研究设计了一种基于STM32单片机的智能家居系统。该系统由一个多功能综合的技术系统组成,各个多功能子系统间具有协同配合能力。基于STM32单片机实现的功能子系统包括:智能温度检测,智能湿度检测,智能烟雾/火灾检测智能检测,无线传输,人机交互机构,风扇调节,报警模块。 整个系统分为前端51单片机采集板和后端STM32单片机接收板。 采集板使用DHT11温湿度传感器、MQ烟雾传感器完成室内家居环境的采集。然后通过nRFL24L01将采集到的数据发送给后端。接收板使用LCD1602完成数据显示、使用蜂鸣器模块报警,使用风扇驱动模块调节室内家居环境。本文完成了智能家居控制系统前端、后端软硬件的设计,使用Altium designer绘制了电路原理图,使用Keil C完成了51单片机和STM32单片机的编程与调试。 最后,对本文设计的基于STM32的智能家居控制系统进行部署调试。试验结果表明,该系统可成功应用在智能家居环境检测调节和火灾安全防护的领域,可提高家居生活智能化水平。

80,488

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧