0

レイアウトにイメージボタンがあります。これをカスタムダイアログのランチャーとして使いたいです。しかし、それをクリックするとプログラムがクラッシュします。使用しているコードは以下のとおりです。

ImageButton bt = (ImageButton) findViewById(R.id.print_button);

    bt.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Dialog dialog = new Dialog(Details.this);
            dialog.setContentView(R.layout.sharepopup);
            dialog.setTitle("");
            dialog.setCancelable(true);
            dialog.show();
          }
    }

それの何がいけないの?前もって感謝します。

4

1 に答える 1

0
LayoutInflater newProject = LayoutInflater.from(Details.this);
View projectView =newProject.inflate(R.layout.sharepopup, null);

Dialog dialog= new Dialog(Details.this);
dialog.setContentView(projectView);
....

これを試して...

于 2011-11-21T12:31:03.040 に答える