Android:onActivityResult之后的多个方法调用?

时间:2011-10-11 17:55:32

标签: android android-intent bundle

我的onActivityResult-onActivityResult有点问题。我想用它执行2个方法来恢复两个微调器。但只有第一个有效,第二个被忽略。

这是我的代码:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);
    iBreak = 1;
    if (resultCode == RESULT_OK && requestCode == REQUEST_CODE) {

        recoverMainFrame(data);
        recoverMainFrameVariant(data);
    }
}

private void recoverMainFrame(Intent data) {

    dbhMy.openDataBase();

    Log.e("mainframe: ", data.getExtras().getString("mainframe"));
    String[] sColumns = { "name", "_id" };
    String[] sColumn = { "_id" };

    Cursor c1 = dbhMy.getData(sColumns, "mainframe");
    startManagingCursor(c1);

    int[] to = new int[] { android.R.id.text1 };

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
            android.R.layout.simple_spinner_item, c1, sColumns, to);
    adapter
            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spMainModel.setAdapter(adapter);
    spMainModel.setSelection(data.getExtras().getInt("iPosMain"));
    dbhMy.close();
    recoverMainFrameVariant(data);

}

private void recoverMainFrameVariant(Intent data) {

    dbhMy.openDataBase();

    String[] sColumns = { "name", "_id" };
    Log.e("Variant: ", data.getExtras().getString("mainframe_variant"));
    Cursor c2 = dbhMy.getData("name", "'"
            + data.getExtras().getString("mainframe_variant") + "'",
            sColumns, "mainframe_variant");
    startManagingCursor(c2);

    int[] to = new int[] { android.R.id.text1 };

    SimpleCursorAdapter adapter1 = new SimpleCursorAdapter(this,
            android.R.layout.simple_spinner_item, c2, sColumns, to);
    adapter1
            .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    Toast.makeText(
            this,
            "Variant ist: "
                    + data.getExtras().getString("mainframe_variant"),
            Toast.LENGTH_SHORT).show();
    spMainModelSub.setAdapter(adapter1);
    //spMainModelSub.setSelection(data.getExtras().getInt("iPosVar"));
    dbhMy.close();

}

有什么建议吗? :(

由于 彼得

0 个答案:

没有答案