I have a dialog with a list with elements where each one is supplied with an ArrayAdapter:
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
ArrayList<String> names = getArguments().getStringArrayList(INTENT_OPTIONS);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
getActivity(), android.R.layout.simple_list_item_1, names);
DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which){
if (mListener != null){
mListener.onSelectedElement(which);
}
}
};
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.loginActivity_selectVACenter)
.setCancelable(true)
.setAdapter(adapter, listener)
.create();
}
Before implementing the appcompat v7 library to incorporate material features, I selected each element in Espresso with the following sentence:
onView(withText("text of the entry"))
.perform(click());
But after adding this library, this sentence does not work anymore, Espresso cannot find the view and throws a NoMatchingViewException.
Is there any other way to access the dialog options?