程序一运行就异常强制关闭,也不知道错误原因,求助,谢谢XML<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/content01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/><CheckBox
android:id="@+id/textbox01"
android:text="Done?"
android:layout_below="@id/content01"
/>
<TextView
android:id="@+id/priority01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignRight="@id/textbox01"
/>
</RelativeLayout>java代码:public class Lab02Activity extends Activity {
/** Called when the activity is first created. */
private Button bottom_button;
private ListView list;
private TextView item_content;
private CheckBox item_check;
private TextView item_priority;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bottom_button = (Button)findViewById(R.id.button01);
list = (ListView)findViewById(R.id.listview01);
item_content = (TextView)findViewById(R.id.content01);
item_check = (CheckBox)findViewById(R.id.textbox01);
item_priority = (TextView)findViewById(R.id.priority01);
ArrayList<HashMap<String,Object>> listitem = new ArrayList<HashMap<String,Object>>();
for(int i=0;i<5;i++)
{
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("content", "homework");
//map.put("done", "true");
map.put("priority", "normal");
listitem.add(map);
}
SimpleAdapter listItemAdapter = new SimpleAdapter(this, listitem, R.layout.listviewitem_layout,new String[]{"content","priority"} , new int[] {R.id.content01,R.id.priority01});
list.setAdapter(listItemAdapter);
}
}
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/content01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
/><CheckBox
android:id="@+id/textbox01"
android:text="Done?"
android:layout_below="@id/content01"
/>
<TextView
android:id="@+id/priority01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignRight="@id/textbox01"
/>
</RelativeLayout>java代码:public class Lab02Activity extends Activity {
/** Called when the activity is first created. */
private Button bottom_button;
private ListView list;
private TextView item_content;
private CheckBox item_check;
private TextView item_priority;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bottom_button = (Button)findViewById(R.id.button01);
list = (ListView)findViewById(R.id.listview01);
item_content = (TextView)findViewById(R.id.content01);
item_check = (CheckBox)findViewById(R.id.textbox01);
item_priority = (TextView)findViewById(R.id.priority01);
ArrayList<HashMap<String,Object>> listitem = new ArrayList<HashMap<String,Object>>();
for(int i=0;i<5;i++)
{
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("content", "homework");
//map.put("done", "true");
map.put("priority", "normal");
listitem.add(map);
}
SimpleAdapter listItemAdapter = new SimpleAdapter(this, listitem, R.layout.listviewitem_layout,new String[]{"content","priority"} , new int[] {R.id.content01,R.id.priority01});
list.setAdapter(listItemAdapter);
}
}
解决方案 »
- listview滑动时不加载图片,并且加载只加载当前屏幕上的图片
- android-sdk-windows-1.6_r1 下载链接
- 请问:能不能写个app,实现在安装这个app的时候就能实现某些功能,比如换掉某些库或删掉sdcard上的某些文件
- android sdk安装问题
- 怎样把sqllite数据库文件打包一起发布?
- Ubuntu + VMware+ xp + NDK 报错:ndk-build命令不存在 请求高手解答
- camera和video的默认存储路径是什么?
- android.process.acore 对应源代码哪个目录?
- android之路
- 有段UDP SOCKET的代码,不知道怎么添加到线程中去,请高手帮一下
- 请教andorid通讯录开发中的一个问题
- ListView 怎么加列边框?
setContentView(R.layout.main);//Acitivty加载的是main.xml
//下面两个控件不在main.xml中,肯定出错啊!!
item_content = (TextView)findViewById(R.id.content01);
item_check = (CheckBox)findViewById(R.id.textbox01);SimpleAdapter listItemAdapter = new SimpleAdapter(this, listitem, R.layout.listviewitem_layout,new String[]{"content","priority"} , new int[] {R.id.content01,R.id.priority01});
//R.id.priority01不在listviewitem_layout.xml上,肯定不能显示修改:public class Lab02Activity extends Activity {
/** Called when the activity is first created. */
private Button bottom_button;
private ListView list;
private TextView item_content;
private CheckBox item_check;
private TextView item_priority;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
bottom_button = (Button)findViewById(R.id.button01);
list = (ListView)findViewById(R.id.listview01);
ArrayList<HashMap<String,Object>> listitem = new ArrayList<HashMap<String,Object>>();
for(int i=0;i<5;i++)
{
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("content", "homework");
//map.put("done", "true");
map.put("priority", "normal");
listitem.add(map);
}
SimpleAdapter listItemAdapter = new SimpleAdapter(this, listitem, R.layout.listviewitem_layout,new String[]{"content","priority"} , new int[] {R.id.content01,R.id.textbox01});
list.setAdapter(listItemAdapter);
}
}