现在的位置: 首页 > 综合 > 正文

高焕堂Android應用框架原理與程式設計代码补遗(一)

2012年03月18日 ⁄ 综合 ⁄ 共 709字 ⁄ 字号 评论关闭

相信很多没有做过移动开发的朋友和我一样从高焕堂老师的这本书开始Android入门,但是看到第5计以及后面的几计发现照着敲代码总是有问题,因为没有simple_list_item_1,后面的代码解释貌似也没有提到这个文件是什么其实这个xml文件现在看来就像是Flex中的ItemRenderer或者asp.net中ItemTemplate的意思,内容只是如下的内容

<?xml version="1.0" encoding="UTF-8"?>
<TextView android:text="TextView01" android:id="@+id/TextView01"
android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"></TextView>

 

adapter = new ArrayAdapter<String>
(this, android.R.layout.simple_list_item_1, dm.loadData());

这句话就是把数据用simple_list_item_1来渲染数据,
lv.setAdapter(adapter);

把数据显示在listview上

貌似Android中的Adapter是设定渲染与数据绑定的工具,然后再将渲染和数据与容器绑定。

ps:貌似现在应用程序界面设计模式都趋向于xml了,Flex,Silverlight,WPF,Android都是使用XML布局,只要搞懂术语间的对应似乎方法都出不多。

抱歉!评论已关闭.