Android 数据库与MapView总结
2010-11-05 00:54:34 来源:WEB开发网);
d.setTitle(R.string.str_edit_it);
d.setContentView(R.layout.layout_edit);
/* 将User点击的餐厅数据放入窗口Widget当中 */
final EditText mEditText01 =
(EditText)d.findViewById(R.id.myEditText1);
final EditText mEditText02 =
(EditText)d.findViewById(R.id.myEditText2);
final EditText mEditText03 =
(EditText)d.findViewById(R.id.myEditText3);
mEditText01.setText
(allRestaurantName.get(intItemSelected));
mEditText02.setText
(allRestaurantAddress.get(intItemSelected));
mEditText03.setText
(allRestaurantCal.get(intItemSelected));
/* 更新数据按钮事件处理 */
Button mButton01 = (Button)d.findViewById(R.id.myButton2);
mButton01.setOnClickListener(new Button.OnClickListener()
{
public void onClick(View arg0)
{
// TODO Auto-generated method stub
String[] updateFields =
{
"f_name", "f_address", "f_cal"
};
String[] updateValues =
{
mEditText01.getText().toString(),
mEditText02.getText().toString(),
mEditText03.getText().toString()
};
String where = "f_id=?";
String[] whereValue =
{
allRestaurantID.get(intItemSelected)
};
/* 调用update()更新数据表里的记录 */
int intCol = dbHelper.update
(
tables[0], updateFields, updateValues,
where, whereValue
);
/* 返回更新成功笔数 >0时 */
if(intCol>0)
{
updateListView();
}
d.dismiss();
}
});
d.show();
}
break;
case 1:
/* 删除数据 */
if(intItemSelected>=0)
更多精彩
赞助商链接