마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

다이얼로그 안에서 이미지 불러오기 문제입니다...!!!

0 추천
안녕하세요~!! 초보 앱 개발자 입니다!@@

요즘 질문이 잦아 죄송하네요 ㅜㅜ

오늘 드릴 질문은 다이얼로그 안에서 이미지를 가져오는 것입니다...!!!

제가 다이얼로그에 쓰일 layout에 버튼을 넣고 그리고 이미지 뷰하나를 놓고

버튼을 클릭하면 갤러리 혹은 카메라에서 이미지를 가져와 이미지 뷰에 넣는 기능을 하려고 합니다,

이 기능이 다이얼로그가 아닌 그냥 activity 상에서는 잘 돌아 가는데 다이얼로그 안에서는 왜 안되는지 몰라서

이렇게 질문 드립니다 ㅜㅜ 오늘도 명쾌한 답으로 저를 구제해 주세요....!!!!

소스 코드 첨부 하겠습니다...!!!!

 

--------------------------------------------------------------------------------------------------------------------------------

 

  case DIALOG_1:
       final LinearLayout linear = (LinearLayout)inflater.inflate(R.layout.user_view, null);

       image = (ImageView) findViewById(R.id.activity_main_image);
       button = (Button) findViewById(R.id.button01);
       button.setOnClickListener(buttonListener);
       
       return new AlertDialog.Builder(main_activity.this)
          .setTitle("울라라")
          .setView(linear)
          .setPositiveButton("확인", new DialogInterface.OnClickListener() {
        
        @Override
        public void onClick(DialogInterface dialog, int which) {
         // TODO Auto-generated method stub
         EditText ed_name = (EditText)linear.findViewById(R.id.make_name);
         EditText ed_company = (EditText)linear.findViewById(R.id.make_company);
         EditText ed_phone = (EditText)linear.findViewById(R.id.make_phone);
         EditText ed_address = (EditText)linear.findViewById(R.id.make_address);
         EditText ed_rank = (EditText)linear.findViewById(R.id.make_rank);
         insert_item(ed_name.getText().toString(),ed_company.getText().toString(),ed_rank.getText().toString(), ed_phone.getText().toString(),ed_address.getText().toString());
         reset_list();
         ed_name.requestFocus();
         ed_name.setText("");
         ed_company.setText("");
         ed_phone.setText("");
         ed_address.setText("");
         ed_rank.setText("");
        }
       })
       
       
       .setNegativeButton("취소", new DialogInterface.OnClickListener() {
        
        @Override
        public void onClick(DialogInterface dialog, int which) {
         // TODO Auto-generated method stub
         EditText ed_name = (EditText)linear.findViewById(R.id.make_name);
         EditText ed_company = (EditText)linear.findViewById(R.id.make_company);
         EditText ed_phone = (EditText)linear.findViewById(R.id.make_phone);
         EditText ed_address = (EditText)linear.findViewById(R.id.make_address);
         EditText ed_rank = (EditText)linear.findViewById(R.id.make_rank);
         ed_name.requestFocus();
         ed_name.setText("");
         ed_company.setText("");
         ed_phone.setText("");
         ed_address.setText("");
         ed_rank.setText("");
         
        }
       })
          .create();
       

 

 

 

여기서 다이얼 로그 빠져 나온 뒤에 activity 상에 아래와 같은 소스 넣었습니다.

 

 

 

 

  private View.OnClickListener buttonListener = new View.OnClickListener() {
   @Override
   public void onClick(View v) {
    // Determine Uri of camera image to save.
    FileUtils.createDefaultFolder(main_activity.this);
    final File file = FileUtils.createFile(FileUtils.IMAGE_FILE);
    outputFileUri = Uri.fromFile(file);
  
    // Camera.
    final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
  
    final Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    galleryIntent.setType("image/*");
    // Filesystems
    // galleryIntent.setAction(Intent.ACTION_GET_CONTENT); // To allow file managers or any other app that are not gallery app.
  
    final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Image");
    // Add the camera options.
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { captureIntent });
    startActivityForResult(chooserIntent, YOUR_SELECT_PICTURE_REQUEST_CODE);
   }
  };
익명사용자 님이 2013년 8월 2일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...