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

안드로이드 radio button dlg.setView

0 추천

제목과 같이 라디오 버튼을 누르면 사진이 보이고 밑에는 글이 나오게 하고싶은데요.

dlg로 이용해서 dlg.setView(R.drawable.아이디)를했는데 r부터 빨간줄이 뜨면서 오류가나요;

사진을 불러오게하려면 다른 코드를 넣어야하나요?

java소스입니다

package com.example.bjhlyj;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class MainActivity extends Activity {
   
    RadioButton yong, smart, ebis;
    Button button1;
    RadioGroup rGroup1;
    ImageView smart2, yong3, ebis4;

   
    @Override
    protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
       setTitle("과 사진보기");
      
       yong = (RadioButton) findViewById(R.id.yong);
       smart = (RadioButton) findViewById(R.id.smart);
       ebis = (RadioButton) findViewById(R.id.ebis);
       rGroup1 = (RadioGroup) findViewById(R.id.rGroup1);

      
      
       button1 = (Button) findViewById(R.id.button1);
   
    button1.setOnClickListener(new View.OnClickListener(){
       public void onClick(View arg0){
          switch(rGroup1.getCheckedRadioButtonId()){
          case R.id.yong:
             AlertDialog.Builder dlg = new AlertDialog.Builder(MainActivity.this);
             dlg.setTitle("영상방송학과");
             dlg.setMessage("영상제작,디지털 방송영상편집등에 이르는 디지털영상전문가를 양성하는것");
             dlg.setPositiveButton("닫기", null);
             dlg.show();
             break;
          case R.id.smart:
              AlertDialog.Builder dlf = new AlertDialog.Builder(MainActivity.this);
              dlf.setTitle("스마트미디어학과");
              dlf.setMessage("IT기업이 필요로 하는 인재를 교육하는 학과");
              dlf.setPositiveButton("닫기", null);
              dlf.show();
              break;
          case R.id.ebis:
              AlertDialog.Builder dld = new AlertDialog.Builder(MainActivity.this);
              dld.setTitle("e-비즈니스학과");
              dld.setMessage("e-비즈니스 산업의 활성화에 따른 취업 맞춤형 전문인재양성을 목표로하는학과");
              dld.setPositiveButton("닫기", null);
              dld.show();
              break;
          }
       }
    });
 }
 }

 

xml소스입니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <RadioGroup
        android:id="@+id/rGroup1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <RadioButton
            android:id="@+id/smart"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="스마트미디어과" />

        <RadioButton
            android:id="@+id/ebis"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="e-비즈니스과" />

        <RadioButton
            android:id="@+id/yong"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="영상방송과" />
    </RadioGroup>

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="그림보기" />

</LinearLayout>

 

 

익명사용자 님이 2015년 5월 13일 질문
...