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

다이얼 로그에서 버튼을 눌렀을 경우에, 인텐트를 호출하고 싶습니다.

0 추천

 

안녕하세요.

버튼을 눌렀을때, 다이얼로그 부분에서 인텐트가 동작하도록 하고 싶은데 그 방법을 모르겠습니다..

간단하게 Intent it = new Intent(getContext,Register.class);

startActivity(it); 를 했는데, 그게 아래의 Custom_Dialog2 자바파일에서는 동작하지 않아서

어떻게 해줘야 할지 막막합니다 ㅠ ㅠ

 

어떻게 해야 아래의 OnClick 부분이 동작하게 될 경우에 Register.class로 이동을 하게 만들어줄수

있을까요 ㅠ ㅠ 며칠째 이것만 하는데 쉽게 해결되지 않네요..

 

제가 아래와 같이 다이얼로그를 호출을 했습니다.

Custom_Dialog2 Dialog2 = new Custom_Dialog2(Payment.this);
Dialog2.show();

그리고 난 뒤에, Custom_Dialog2는 아래와 같이 구성되어 있습니다.

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;

public class Custom_Dialog2 extends Dialog implements View.OnClickListener{

    Button btn;

    public Custom_Dialog2(Context context) {
        super(context);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_custom__dialog2);

        btn = (Button) findViewById(R.id.Custom_Button2);
        btn.setOnClickListener(this);
    }

    public void onClick(View view) {
        if (view.getId() == R.id.Custom_Button2) {
            if (isShowing()) {

                dismiss();
            }
        }
    }
}

 

공산당 (1,960 포인트) 님이 2016년 12월 4일 질문

1개의 답변

0 추천
public class Custom_Dialog2 extends Dialog implements View.OnClickListener{

    Button btn;
    Context context;
    public Custom_Dialog2(Context context) {
        super(context);
        
        this.context = context;

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_custom__dialog2);

        btn = (Button) findViewById(R.id.Custom_Button2);
        btn.setOnClickListener(this);
    }

    public void onClick(View view) {
        if (view.getId() == R.id.Custom_Button2) {
            if (isShowing()) {
                Intent intent = new Intent(context,test.class);
                context.startActivity(intent);

                dismiss();

            }
        }
    }
}

 

요런식으로 해보시는게
sadeva (21,550 포인트) 님이 2016년 12월 4일 답변
...