1
是否有可能在edittext中更新已設置的文本?我已經用我的列表視圖中的姓名和電話號碼填充了我的edittext,並且我希望用戶編輯這些詳細信息。當我試圖輸入例如姓氏並單擊更新按鈕時,它不能保存我的輸入並仍保存我從我的列表視圖傳來的信息。更新android中的edittext
EditText sqlName = (EditText)findViewById(R.id.editName);
EditText sqlNumber = (EditText)findViewById(R.id.editNumber);
name = CustomListView.name;
num = CustomListView.number;
Button bUpdate = (Button)findViewById(R.id.editUpdate);
Button bView = (Button)findViewById(R.id.editView);
sqlName.setText(name);
sqlNumber.setText(num);
nameChanged = sqlName.getText().toString();
numChanged = sqlNumber.getText().toString();
bUpdate.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
GroupDb info = new GroupDb(EditDetails.this);
info.open();
long rowid = info.getRowId(name, num);
Toast.makeText(getApplicationContext(), nameChanged+" "+numChanged+" ", Toast.LENGTH_LONG).show();
info.updateNameNumber(rowid, nameChanged, numChanged);
Toast.makeText(getApplicationContext(), "Update Successful!", Toast.LENGTH_LONG).show();
info.close();
}
});