android - 带有从相册或相机中选择的界面的相机代码

标签 android

有没有人实现了一个用户界面,您可以在其中选择相册或相机,然后打开相机,您可以单击然后单击使用按钮来使用它。请给出任何建议或引用项目链接

谢谢 最大

最佳答案

使用下面的代码调用UI来选择相机或画廊,

private void openAddPhoto() {

            String[] addPhoto=new String[]{ "Camera" , "Gallery" };
            AlertDialog.Builder dialog=new AlertDialog.Builder(this);
            dialog.setTitle(getResources().getString(R.string.method));

            dialog.setItems(addPhoto,new DialogInterface.OnClickListener(){
                @Override
                public void onClick(DialogInterface dialog, int id) {

                    if(id==0){
                        // Call camera Intent
                    }
                    if(id==1){
                        //call gallery
                    }
                }
            });     

            dialog.setNeutralButton("cancel",new android.content.DialogInterface.OnClickListener(){
                @Override
                public void onClick(DialogInterface dialog, int which) {

                    dialog.dismiss();               
                }});
            dialog.show();
        }

关于android - 带有从相册或相机中选择的界面的相机代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7088335/

相关文章:

ListView中的Android备用行颜色

android - 我用 cordova 开发了一个 android 应用程序,我也想将它转换为 iOS

android - 我可以在 android 中读取硬件计数器吗?

android - 如何列出符合 Intent 的 Activity ?

android - 如何让 LibGDX gradled eclipse 项目在 AIDE(Android IDE 应用程序)上工作

Android buildTypes for Alpha/Beta/Production apk

android - 如何正确调用上下文来启动 Activity

android - 触摸 TextView 时无法滚动 ViewPager(使用 android :gravity ="center") in it

android - 如何将 Android 模拟器连接到本地主机服务器?

android - 如何在 android studio 中启用 neon 构建和调试 native 代码 (c)?