public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.select);
final Button button_select=(Button)findViewById(R.id.button2);
button_select.setOnClickListener(new View.OnClickListener() {
/*************************单击按钮查询数据开始**************************/
public void onClick(View v) {
database temp = new database(select.this, "database_sage");
SQLiteDatabase db = temp.getWritableDatabase();
Cursor cursor = db.query("user", new String[]{"name", "phone","address"}, null, null, null, null, null);
while(cursor.moveToNext()) {
?? ??????? }
}
});
/*********************************单击按钮查询数据结束*************************/ 我初学,想问一下在问号处用什么样的代码可以得到我想要的功能
1.遍历出数据库中的全部数据显示在屏幕上
2.当在画面出点击其中一条记录时可以跳到新的activity画面
麻烦高手帮说的详细些,呵呵谢谢
super.onCreate(savedInstanceState);
setContentView(R.layout.select);
final Button button_select=(Button)findViewById(R.id.button2);
button_select.setOnClickListener(new View.OnClickListener() {
/*************************单击按钮查询数据开始**************************/
public void onClick(View v) {
database temp = new database(select.this, "database_sage");
SQLiteDatabase db = temp.getWritableDatabase();
Cursor cursor = db.query("user", new String[]{"name", "phone","address"}, null, null, null, null, null);
while(cursor.moveToNext()) {
?? ??????? }
}
});
/*********************************单击按钮查询数据结束*************************/ 我初学,想问一下在问号处用什么样的代码可以得到我想要的功能
1.遍历出数据库中的全部数据显示在屏幕上
2.当在画面出点击其中一条记录时可以跳到新的activity画面
麻烦高手帮说的详细些,呵呵谢谢
解决方案 »
- 由经纬度查询实际地址,报java.io.IOException: Service not Available
- 以下方式可以从某个点下载文件吗?
- Android播放rtsp协议视频的问题
- socket 问题,怎样能够接收数据,并且在没有数据时不阻塞线程?
- android ProgressDialog不转动怎么解决
- android软键盘问题请教
- 做asp.net 开发的想转android开发,应该怎样进行学习呢?
- 运行HttpUrlConnection错误
- java.lang.ClassNotFoundException: 是什么意思?
- 关于app用户登录认证安全设计的一些问题
- 请问地图怎么做?
- 在listview中edittext控件的setOnFocusChangeListener问题
private List<HashMap<String, String>> List;
while (cursor.moveToNext()) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("_id", cursor.getString(cursor.getColumnIndex("_id")));
Car_List.add(map);
}
在吧list绑定到listview上
2.当在画面出点击其中一条记录时可以跳到新的activity画面
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
System.out.println(position);
Intent intent = new Intent(xxx,xxx);
startActivity(intent);
}
比如说我表里总共有2个字段,name,password那当我点击listview里其中一条数据怎样获得该记录name和password字段所对应的值呢。
super.onListItemClick(l, v, position, id);
System.out.println(position);
String name = List.get(position).get("name").tostring();
....
Intent intent = new Intent(xxx,xxx);
startActivity(intent);
}