我的问题是,你如何称呼这种方法。我已经知道如何实施。这是方法的内容:
public boolean updateDebt(long updateId, String debtName, String debtTotal,
String debtApr, String paymentGoal) {
ContentValues values = new ContentValues();
values.put(MySQLiteHelper.COLUMN_DEBT_NAME, debtName);
values.put(MySQLiteHelper.COLUMN_DEBT_TOTAL, debtTotal);
values.put(MySQLiteHelper.COLUMN_APR, debtApr);
values.put(MySQLiteHelper.COLUMN_PAYMENT, paymentGoal);
String whereClause = MySQLiteHelper.COLUMN_ID + " = ?";
String[] whereArgs = new String[]{ String.valueOf(updateId) };
return database.update(MySQLiteHelper.TABLE_DEBT, values, whereClause, whereArgs) > 0;
我的问题在于“强烈”调用 强烈>这个更新的Debt方法。
使用更新按钮绘制四个字段的对话框。 字段预先配有表格数据。 用户更改字段数据和点击更新, 表格应该更改 。
这是呼叫前的代码 。 记住, 我通过点击在 ListTroundClick 的对话框中 呼叫它 。
(我编辑了很多不相干的东西出来)
List<Debt> values;
MyArrayAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.debts);
datasource = new DebtDataSource(this);
datasource.open();
values = datasource.getAllDebt();
adapter = new MyArrayAdapter(this, values);
setListAdapter(adapter);
}
protected void onListItemClick(ListView l, View v, final int position, long id) {
Debt item = values.get(position);
final long boxId = item.getId();
final String BoxName = item.getName();
final String BoxBalance = item.getBalance();
final String BoxApr = item.getApr();
final String BoxPayment = item.getPayment();
// (edited out: setting up EditText fields here with data from above)
// set up button
Button button = (Button) dialog.findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
datasource.updateDebt(Long.valueOf(boxId), BoxName, BoxBalance,
BoxApr, BoxPayment);
values = datasource.getAllDebt();
adapter.notifyDataSetChanged();
dialog.dismiss();
}
});
dialog.show();
}
Simply put nothing happens when I hit update. The dialog dismisses, that it. Nothing in logcat. I have logged out the variables just before the update method inside the updateDebt() method. I have toasted them back and all the variables match up perfectly. The database doesn t change though! Struggling on this for days....