后退按钮问题

时间:2009-12-11 11:40:17

标签: android

我正在创建一个小应用程序。在View Page中,我正在从数据库执行更新和删除操作,并在顶部显示数据(前10条记录)。在底部我有2个按钮,编辑和删除。如果用户单击“编辑”按钮,则会重定向到“编辑”页面。在编辑页面我显示内容进行编辑也有2个按钮更新和取消。如果用户再次单击更新,我将重定向(使用开始活动)查看页面。它没有显示新记录。我回到主页然后点击了查看页面,现在它已更新如何解决这个问题?另一个问题是,如果用户单击后退按钮,它将进入我去过的所有页面(通过重定向页面)。

例如,首先我从主页面点击查看页面。在视图页面中我正在进行编辑和删除操作。完成此操作后,它将进入查看页面。在这里,我点击后退按钮,它是前一页,即我最后执行的编辑或删除页面。我需要从视图进入主页(执行编辑或删除操作后)如何执行此操作?

1 个答案:

答案 0 :(得分:0)

对于用户编辑数据的问题并且未显示结果,请确保使用新数据填充它。有关详细信息,请参阅this

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState); 
    mDbHelper = new NotesDbAdapter(this);
    mDbHelper.open();

    setContentView(R.layout.note_edit);

    mTitleText = (EditText) findViewById(R.id.title);
    mBodyText = (EditText) findViewById(R.id.body);

    Button confirmButton = (Button) findViewById(R.id.confirm);

    mRowId = savedInstanceState != null ? savedInstanceState.getLong(NotesDbAdapter.KEY_ROWID) : null;
    if (mRowId == null) {
        Bundle extras = getIntent().getExtras();
        mRowId = extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null;
}

private void populateFields() {
    if (mRowId != null) {
        Cursor note = mDbHelper.fetchNote(mRowId);
        startManagingCursor(note);
        mTitleText.setText(note.getString(
                note.getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE)));
        mBodyText.setText(note.getString(
                note.getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY)));
    }
}
相关问题