我现在有一个使用 ListView 和 CustomCursorAdapter 的活动,我希望自动化测试。一切都很好,但是当适配器中没有记录时,屏幕上会显示一个警报对话框,现在问题是我无法访问活动测试(android 测试用例)的警报对话框并且无法处理警报对话框事件关于测试框架,先生,请在这方面帮助我。提前致谢。
对话框创建代码。
@Override
protected Dialog onCreateDialog(int id){
String msg = null;
switch(id){
case CALL_SETTING:
builder = new AlertDialog.Builder(this);
builder.setTitle("CIH - HELP");
msg = "Please Allow me to guide you Configure this fresh CIH-MA.";
builder.setMessage(msg);
builder.setCancelable(true);
builder.setPositiveButton("OK", new settingOnClickListener());
builder.setNegativeButton("Cancel", new cancelOnClickListener());
alDialog = builder.create();
alDialog.show();
break;
case CALL_SITE:
builder = new AlertDialog.Builder(this);
builder.setTitle("CIH - HELP");
msg = "Please press 'Site' button to Add new Site for Monitoring and Controling Device ";
builder.setMessage(msg);
builder.setCancelable(true);
builder.setPositiveButton("OK", new siteOnClickListener());
builder.setNegativeButton("Cancel", new cancelOnClickListener());
alDialog = builder.create();
alDialog.show();
break;
}
return super.onCreateDialog(id);
}
private final class settingOnClickListener implements DialogInterface.OnClickListener{
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
ZigbeeActivity.this.startActivity(new Intent(ZigbeeActivity.this,AboutScreen.class));
}
}
private final class cancelOnClickListener implements DialogInterface.OnClickListener{
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
}
private final class siteOnClickListener implements DialogInterface.OnClickListener{
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Intent LocationIntent = new Intent(ZigbeeActivity.this,SelectLocation.class);
LocationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
ZigbeeActivity.this.startActivity(LocationIntent);
}
}