android DialogInterface强制关闭

时间:2013-12-16 01:20:22

标签: android onclicklistener

我有一个按钮,点击后我想加载一个布局。布局中有可点击的Dice图标。我已经声明了按钮但是在单击时它将不会加载布局。

如果它确实加载了布局并且点击了骰子,则强制关闭,因为用骰子编号加载的新框取代了骰子布局。我不确定我所说的是否有意义,我的代码可能是错误的。

基本上我想要的是,当点击按钮时我想要加载我的xml骰子并且可以点击图像,并且当点击它时返回给定骰子范围内的值。

 private CustomPopupWindow mDiceMenu;

 protected void showDicePopUp(View paramView) {
    this.mDiceMenu = new CustomPopupWindow(paramView);
    View.OnClickListener local3 = new View.OnClickListener() {
        public void onClick(View paramAnonymousView) {
            MainActivity.this.onDiceDialogClick(paramAnonymousView);
        }
    };
    this.mDiceMenu.setContentView(R.layout.dice);
    this.mDiceMenu.findViewById(R.id.dice_4).setOnClickListener(local3);
    this.mDiceMenu.findViewById(R.id.dice_6).setOnClickListener(local3);
    this.mDiceMenu.findViewById(R.id.dice_10).setOnClickListener(local3);
    this.mDiceMenu.findViewById(R.id.dice_20).setOnClickListener(local3);
    this.mDiceMenu.findViewById(R.id.planeswalker_dice).setOnClickListener(
            local3);
    this.mDiceMenu.findViewById(R.id.coin).setOnClickListener(local3);
}

   private void displayDiceResult(int paramInt) {
    int i = 1 + this.mRandom.nextInt(paramInt);
    this.mDiceMenu.dismiss();
    TextView localTextView = new TextView(this);
    localTextView.setText(String.valueOf(i));
    localTextView.setTextSize(52.0F);
    localTextView.setTextColor(-16777216);
    localTextView.setGravity(17);
    localTextView.setBackgroundResource(R.drawable.planeswalker_dice);
    new AlertDialog.Builder(this)
            .setTitle(getString(R.string.dice_roll) + "(D" + paramInt +")")
            .setView(localTextView)
            .setPositiveButton(getText(17039370),
                    new DialogInterface.OnClickListener() {
                        public void onClick(
                                DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
                                  paramAnonymousDialogInterface.dismiss();
                        }
                    }).create().show();
 }

0 个答案:

没有答案
相关问题