0

我有一个应用程序让用户拍照并将其上传到网站。

我现在有这个代码:

@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"));
            }
        }
    }

但是,在下载图像之前,我想添加一个布局,该布局会显示一个 Spinner(下拉菜单),其中包含用户可以从中选择来描述图片的项目列表。

我应该在代码中添加什么,以便在图片上传之前显示一个新布局,用户进行选择并点击该OK布局上的按钮,然后返回到这段代码继续上传过程?

4

1 回答 1

2
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;
}
于 2011-09-23T15:21:53.587 回答