我在进行某些操作并显示警告对话框后警告用户但是当可访问性打开时,它不会读取完整警报dailog标题和正文。它只读取标题。我在三星galaxy s5中发现了这个问题。 请帮我解决这个问题。
public class TransactionDialog extends DialogFragment {
private int _state = -1;
private final String TITLE = "TITLE";
private final String MESSAGE = "MESSAGE";
private final String POS_TEXT = "POS_TEXT";
private final String STATE = "STATE";
private int _title = 0;
private int _message = 0;
private int _positiveText = 0;
private NoticeDialogListener mListener;
Logger logger = Logger.getNewLogger("com.ui.TransactionDialog");
boolean actionPerformed = false;
AlertDialog dialog = null;
public TransactionDialog() {
}
public void setListener(NoticeDialogListener listener) {
this.mListener = listener;
}
public TransactionDialog(int title, int message, int positiveText, int state) {
this._title = title;
this._message = message;
this._positiveText = positiveText;
this._state = state;
}
public int getState() {
return _state;
}
@Override
public void onSaveInstanceState(Bundle outState) {
// TODO Auto-generated method stub
super.onSaveInstanceState(outState);
outState.putInt(TITLE, this._title);
outState.putInt(MESSAGE, this._message);
outState.putInt(POS_TEXT, this._positiveText);
outState.putInt(STATE, this._state);
}
@Override
public void onResume() {
super.onResume();
logger.debug("TITLE:" + this._title);
logger.debug("_message:" + this._message);
logger.debug("_positiveText:" + this._positiveText);
logger.debug("_state:" + this._state);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
logger.debug("Created");
}
@Override
public void onDismiss(DialogInterface dialog) {
// TODO Auto-generated method stub
super.onDismiss(dialog);
mListener.onDialogDismissed();
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
logger.debug("ON CREATE");
if (savedInstanceState != null) {
this._title = savedInstanceState.getInt(TITLE);
this._message = savedInstanceState.getInt(MESSAGE);
this._positiveText = savedInstanceState.getInt(POS_TEXT);
this._state = savedInstanceState.getInt(STATE);
}
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(getResources().getString(this._title))
.setMessage(getResources().getString(_message))
.setPositiveButton(getResources().getString(_positiveText), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if(actionPerformed)
return;
actionPerformed = true;
mListener.onDialogPositiveClick(TransactionDialog.this);
}
});
dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.show();
dialog.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode == KeyEvent.KEYCODE_BACK) {
mListener.onDialogPositiveClick(TransactionDialog.this);
}
return false;
}
});
return dialog;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
// Verify that the host activity implements the callback interface
try {
// Instantiate the NoticeDialogListener so we can send events to the
// host
mListener = (NoticeDialogListener) activity;
} catch (ClassCastException e) {
// The activity doesn't implement the interface, throw exception
throw new ClassCastException(activity.toString()
+ " must implement NoticeDialogListener");
}
}
public interface NoticeDialogListener {
public void onDialogPositiveClick(DialogFragment dialog);
public void onDialogDismissed();
}}
这里我使用txndialog类来创建警告对话框。
private TransactionDialog transactionDialog;
transactionDialog = (TransactionDialog) newTransactionFrgment;
transactionDialog.setListener(this);
transactionDialog = new TransactionDialog(R.string.transaction_complete_header, R.string.transaction_complete_message,
R.string.transaction_complete_positive_button, STATE_SET_TRANSACION);
transactionDialog.show(getFragmentManager(), TRANSACTION_DIALOG_TAG);