List of usage examples for android.widget AdapterView post
public boolean post(Runnable action)
Causes the Runnable to be added to the message queue.
From source file:org.mozilla.gecko.tests.BaseTest.java
/** * Gets the view in the tabs panel at the specified index. * * @return View at index//ww w . j av a 2 s.c o m */ private View getTabViewAt(final int index) { final View[] childView = { null }; final AdapterView<ListAdapter> view = getTabsLayout(); runOnUiThreadSync(new Runnable() { @Override public void run() { view.setSelection(index); // The selection isn't updated synchronously; posting a // runnable to the view's queue guarantees we'll run after the // layout pass. view.post(new Runnable() { @Override public void run() { // getChildAt() is relative to the list of visible // views, but our index is relative to all views in the // list. Subtract the first visible list position for // the correct offset. childView[0] = view.getChildAt(index - view.getFirstVisiblePosition()); } }); } }); boolean result = waitForCondition(new Condition() { @Override public boolean isSatisfied() { return childView[0] != null; } }, MAX_WAIT_MS); mAsserter.ok(result, "list item at index " + index + " exists", null); return childView[0]; }