Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中读取警报对话框的内容描述_Android_Accessibility_Android Alertdialog - Fatal编程技术网

如何在android中读取警报对话框的内容描述

如何在android中读取警报对话框的内容描述,android,accessibility,android-alertdialog,Android,Accessibility,Android Alertdialog,我在某些操作后向用户发出警报并显示警报对话框,但当可访问性打开时,它不会读取完整的警报日志标题和正文。它是只读标题。我在三星galaxy s5中发现了这个问题。 请帮我解决这个问题 public class TransactionDialog extends DialogFragment { private int _state = -1; private final String TITLE = "TITLE"; private final String MESSAGE = "MESSAGE

我在某些操作后向用户发出警报并显示警报对话框,但当可访问性打开时,它不会读取完整的警报日志标题和正文。它是只读标题。我在三星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);

发布一些代码。它在其他设备上运行正常吗?到目前为止您尝试了什么?发布您的代码
它没有读取完整的警报日志标题和正文
。您的意思是没有显示完整的对话框,即缺少某些部分?请详细说明并最好使用屏幕截图更新您的问题。警报对话框正确显示,但当可访问性打开时,它不是读取警报对话框正文,而是仅读取警报对话框的标题。我的问题是如何设置警报对话框的内容描述。@Sufian我发现这个问题与棒棒糖设备有关,因为对讲(可访问性)在操作系统版本4.3中运行良好。