当我关闭对话框时,为什么我的dismissListener
不想触发,我有一个小问题。我不知道为什么。我尝试调试,但我不知道我设置错误:)请帮帮我
调用ChooseDialog,但此功能在解雇时不会触发:
cd = new ChooseDialog(getApplicationContext());
cd.setOnDismissListener(new Dialog.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
// TODO Auto-generated method stub
if (click != -1) {
Button b = (Button) findViewById(PositionButtons.click);
b.setText(keypadButton.getText());
PositionButtons.click = -1;
}
}
});
ChoseDialog :
package com.calculator.position;
import com.calculator.mycalculator.Calculator;
import com.calculator.mycalculator.CalculatorGUI;
import com.calculator.mycalculator.KeypadButton;
import com.calculator.mycalculator.R;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.GridView;
public class ChooseDialog extends Dialog {
public ChooseDialog(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
KeypadAdapter mKeypadAdapter;
GridView mKeypadGrid;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.grid);
// Get reference to the keypad button GridView
mKeypadGrid = (GridView) findViewById(R.id.grdButtons);
// Create Keypad Adapter
mKeypadAdapter = new KeypadAdapter(getContext());
// Set adapter of the keypad grid
mKeypadGrid.setAdapter(mKeypadAdapter);
// Set button click listener of the keypad adapter
mKeypadAdapter.setOnButtonClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Button btn = (Button) v;
KeypadButton keypadButton = (KeypadButton) btn.getTag();
Log.e(keypadButton.getText(), keypadButton.getText());
PositionButtons.keypadButton = keypadButton;
CalculatorGUI.button.put(PositionButtons.click, keypadButton);
dismiss();
}
});
}
}