开发者

How to add another layout to display in OnActivityResult()?

I have an app that has a user take a picture and have it uploaded to a website.

I have this code right now:

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

        if (requestCode == CAMERA_PIC_REQUESTED) {
            if(resultCode == RESULT_OK) {   
                // Maybe add the additional code here?          

                picture = convertImageUriToFile(imageUri, this);


                Thread thread = new Thread(null, uploader, "MagentoBackground");
                thread.start();
                m_ProgressDialog = ProgressDialog.show(pictures.this, "Please wait...", "Uploading data ...", true, true);

            }
        } else if (requestCode == EXPERIMENT_CODE) {
            if (resultCode == Activity.RESULT_OK) {
                experimentInput.setText("" + data.getExtras().getInt("edu.cs.h.exp_id"));
            }
        }
    }

However, before the image is downloaded, I want to add a layout that brings up a 开发者_StackOverflowSpinner (drop down menu) with a list of items that a user can choose from to describe the picture.

What should I add to the code so that before the picture is uploaded, a new layout is displayed, a user makes a selection and hits the OK button on that layout, and then returns back to this piece of code to continue the upload process?


static final int _MY_DIALOG_ = 11;

if(resultCode == RESULT_OK) {   
    showDialog(_MY_DIALOG_);
}

@Override
protected Dialog onCreateDialog(int id) {
    if(id==_MY_DIALOG_){
        CharSequence[] shush = new CharSequence[10];
        //initialize shush
        Dialog dialog = new AlertDialog.Builder(this).setTitle("Select Animation")
            .setSingleChoiceItems(shush, 0,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    //the user has selected which!!!
                    dialog.dismiss();
                }
            }).create();
        dialog.setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface arg0) {
                //do what you want now since the user selected!
                picture = convertImageUriToFile(imageUri, this);
                Thread thread = new Thread(null, uploader, "MagentoBackground");
                thread.start();
                m_ProgressDialog = ProgressDialog.show(pictures.this, "Please wait...", "Uploading data ...", true, true);
            }
        });
        return dialog;
    }
    return null;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜