1
Ich baue eine AlertDialog
Box mitwie MultiChoiceItems android Dialogfeld
public class ConstantDialogFragment extends DialogFragment {
private AlertDialog.Builder builder;
private AlertDialog alertDialog;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final int[] constantProtocol = {0};
builder = new AlertDialog.Builder(getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
builder.setTitle(getResources().getString(R.string.some_message))
.setMultiChoiceItems(R.array.some_choice, null,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which,
boolean isChecked) {
// some method
}
})
.setPositiveButton(getResources().getString(R.string.ok_dialog), new DialogInterface.OnClickListener() {
class LoadConfigTask {
private ProgressDialog dialog;
private Activity activity;
public LoadConfigTask(Activity activity) {
this.activity = activity;
dialog = new ProgressDialog(activity, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
}
public void execute() {
try {
// some method
} catch (Exception e) {
// some method
}
}
}
@Override
public void onClick(DialogInterface dialog, int id) {
// some method
}
})
.setNegativeButton(getResources().getString(R.string.cancel_dialog), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// some thing
}
});
builder.create();
alertDialog = builder.show();
return alertDialog;
}
public AlertDialog getAlertDialog(){
return alertDialog;
}
Dann habe ich versucht, diese espresso
Implementierung testen:
onView(withText("my first choice")).
perform(click());
und ich
NoMatchingViewException: No views in hierarchy found matching: with text: is my string"
Wie kann ich repariere das ?
Was hat das alles mit Ihrer Dialogbox zu tun? – greenapps
@greenapps Ich verstehe deine Frage nicht wirklich. Ich baue ein Multi-Item-Dialogfeld und ich muss das Verhalten testen, nachdem ich auf eines der Kontrollkästchen geklickt habe – Newben
Wo befindet sich dieses OnView? Warum postest du nicht den kompletten Code? Beginnen Sie mit dem Listener-Code. – greenapps