¿Cómo hacer clic en un botón, que se indexa en la posición 10 en ListView – robótica automatización?

Supongamos que tengo un ListView, que contiene 20 ListItems. Cada elemento es tener un botón, ahora quiero hacer clic en un botón que se encuentra en la posición 10 en ListView. ¿Cómo puedo automatizarlo vía robotium?

Trate de hacer ti como este (no está seguro de si funciona)

 //get the list view ListView myList = (ListView)solo.getView(R.id.list); //get the list element at the position you want View listElement = myList.getChildAt(10);// myList is local var //click on imageView inside that list element solo.clickOnView(solo.getView(listElement.findViewById(R.id.my_button)));// not double eE 

Espero que esto ayude !

Intente usar el solo.clickInList (línea int, int index)

Algo como:

 solo.clickInList(10,0) 

¡Espero que esto ayude!

http://www.jarvana.com/jarvana/view/com/jayway/android/robotium/robotium-solo/2.0.1/robotium-solo-2.0.1-javadoc.jar!/com/jayway/android/robotium /solo/Solo.html#clickInList(int,%20int)

No estoy seguro de exactamente lo que está tratando de hacer, mi suposición es que usted tiene una vista de lista con demasiados elementos para caber en la pantalla y desea hacer clic en el botón que está en la 10 ª posición o algo para ese efecto? Estoy bien

Si es así he producido previamente algunas funciones auxiliares listview para obtener la vista en un índice dado en la vista de lista:

 public View getViewAtIndex(final ListView listElement, final int indexInList, Instrumentation instrumentation) { ListView parent = listElement; if (parent != null) { if (indexInList <= parent.getAdapter().getCount()) { scrollListTo(parent, indexInList, instrumentation); int indexToUse = indexInList - parent.getFirstVisiblePosition(); return parent.getChildAt(indexToUse); } } return null; } public <T extends AbsListView> void scrollListTo(final T listView, final int index, Instrumentation instrumentation) { instrumentation.runOnMainSync(new Runnable() { @Override public void run() { listView.setSelection(index); } }); instrumentation.waitForIdleSync(); } 
  //First get the List View ListView list = (ListView) solo.getView(R.id.list_view); /* View viewElement = list.getChildAt(10); This might return null as this item view will not be created if the 10th element is not in the screen. (ie the getView would have not been called for this view). Suppose for single item list_item.xml is used then Get the 10th button item view as follows:*/ int i = 10 ; View buttonItem = list.getAdapter().getView(i,getActivity().findViewById(R.layout.list_item),list); solo.clickOnView(buttonItem); 
FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.