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画面
麻烦高手帮说的详细些,呵呵谢谢
解决方案 »
- android中 如何获取drawable中的png图片 并显示成背景透明效果
- 关于谷歌天气预报的API。。
- 求教从图片上获取文字
- android_2.2 camera问题
- android RTSP协议视频流播放的没有声音的问题
- 如何在eclipse中把Android工程编译为apk安装文件??
- res->layout 文件夹中的activity_main.xml 打开时报错
- 用FrameLayout布局,为什么上面的层都挡住了下面的还会点击到?
- 想要实现密码功能怎么做,大概指个方向
- 请问关于如何获取返回值并显示出来的问题
- 请问地图怎么做?
- 在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);
}