小编fiz*_*o07的帖子

如何在对话框外发生单击时触发事件

我想知道如何解决我遇到的问题.

我有一个在活动中弹出的Dialog.对话框不会覆盖整个屏幕,因此活动中的按钮仍会显示.当对话框的边界外有触摸时,我可以轻松关闭对话框dialog.setCanceledOnTouchOutside(true);

但是,如果点击在Dialog的边界之外,我想要做的就是触发一个事件(例如,如果有人触摸主Activity上的按钮,它应该关闭Dialog并同时触发该事件).

android android-dialog

36
推荐指数
2
解决办法
3万
查看次数

打开失败:ENOENT(没有此类文件或目录)错误

我试图通过使用亚马逊S3安卓库来上传使用相机拍照的照片时遇到问题.

保存图片

File _photoFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),   (cal.getTimeInMillis() + ".jpg"));

            try {
                if (_photoFile.exists() == false) {
                    _photoFile.getParentFile().mkdirs();
                    _photoFile.createNewFile();
                }

            } catch (IOException e) {
                // Log.e(TAG, "Could not create file.", e);
            }
            // Log.i(TAG, path);

            filePath = Uri.fromFile(_photoFile);
            Intent cameraIntent = new Intent(
                    android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, filePath);
            startActivityForResult(cameraIntent, 1);
Run Code Online (Sandbox Code Playgroud)

要使用filePath上传图片:

try {
            s3Client.createBucket(Constants.getPictureBucket());

            // Content type is determined by file extension.
            PutObjectRequest por = new PutObjectRequest(
                    Constants.getPictureBucket(), Constants.PICTURE_NAME,
                    new java.io.File(filePath));
            s3Client.putObject(por);
        } catch (Exception exception) {

            result.setErrorMessage(exception.getMessage());
        }
Run Code Online (Sandbox Code Playgroud)

我一直在收到错误 Unable …

camera android amazon-s3

7
推荐指数
1
解决办法
3729
查看次数

Android字符串.equals方法不起作用

我正在学习android开发.我已经能够成功创建一个登录类,我的应用程序检查我的mysql数据库,看看数据库中是否存在用户的详细信息.如果用户的详细信息存在于数据库中或"不正确",则php文件发布"正确"

private void checkResult(){
    if(getResults().equals("correct")){
            //do some stuffs

    }
    else{

        displayDialog(getResults());
    }   
}
Run Code Online (Sandbox Code Playgroud)

getResults()方法返回String(来自服务器的响应).但是,字符串比较似乎不起作用,因为当服务器返回"正确"作为响应时,if条件总是为false.我确认通过使用下面的方法,执行false语句,但alertDialog中的msg是"正确的".请任何人都可以帮忙,似乎无法理解为什么代码行为不端.

    public void displayDialog(String msg){

    AlertDialog alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle("Authetication Failed!");
    alertDialog.setMessage(msg);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            // do something when the user presses OK (place focus on weight input?)
        }
    });
    alertDialog.setIcon(R.drawable.icon);
    alertDialog.show();

}
Run Code Online (Sandbox Code Playgroud)

java string android

2
推荐指数
2
解决办法
6511
查看次数

标签 统计

android ×3

amazon-s3 ×1

android-dialog ×1

camera ×1

java ×1

string ×1