我们有 3 个类 A、B、C。A 类调用 B 类startActivityForResult
以从中获取数据。它返回后取决于从B类中检索到的数据,我们是否会去C类获取数据给A类。这将在一个onListItemClick
方法中完成。下面的代码不起作用,任何人都可以说出问题所在吗?
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Cursor note = mDbHelper.fetchNote(id);
startManagingCursor(note);
mpass= note.getString(note.getColumnIndexOrThrow(NotesDbAdapter.KEY_PASS));
theid = id
if(mpass !=null) {
Intent ps = new Intent(this, EnterPass.class);
startActivityForResult(ps,2);
}
else {
Intent i = new Intent(this, NoteEdit.class);
i.putExtra(NotesDbAdapter.KEY_ROWID, id);
startActivityForResult(i, 1);}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
if(requestCode==2) {
if(null!=intent) {
message=intent.getStringExtra("MESSAGE");
if (mpass == message) {
Intent i = new Intent(this, NoteEdit.class);
i.putExtra(NotesDbAdapter.KEY_ROWID, theid);
startActivityForResult(i, 1);
}
}
else
}
if(requestCode==1) {
if (resultCode == RESULT_OK)
fillData();
}