List of usage examples for android.widget ListView performItemClick
@Override public boolean performItemClick(View view, int position, long id)
From source file:Main.java
public static void performItemClickOnUIThread(final Activity activity, final ListView listView, final View view, final int position) { Runnable click = new Runnable() { public void run() { listView.performItemClick(view, position, 0); }/* w ww . j ava2 s .c o m*/ }; activity.runOnUiThread(click); }
From source file:com.example.awesomedogs.ui.MainActivityTest.java
public void testClickingDogOpensDetails() { // Clicking on any dog should open the details activity ListView listView = getListView(); listView.performItemClick(null, 0, 0); Intent intent = getStartedActivityIntent(); assertNotNull(intent);// w ww . j ava2s. c o m assertEquals(DogDetailActivity.class.getName(), intent.getComponent().getClassName()); assertTrue(intent.hasExtra(DogDetailActivity.EXTRA_DOG_ID)); }
From source file:ca.ualberta.cmput301w14t08.geochan.test.ThreadViewFragmentTest.java
@Override protected void setUp() throws Exception { super.setUp(); this.activity = getActivity(); Comment testComment = new Comment("hello", null, null); //testComment.addChild(new Comment("test", null)); ThreadList.addThread(testComment, "test thread"); //Click the thread to open the fragment activity.runOnUiThread(new Runnable() { @Override/* www. jav a2 s.c o m*/ public void run() { ListView listView = (ListView) activity .findViewById(ca.ualberta.cmput301w14t08.geochan.R.id.thread_list); listView.performItemClick(listView.getAdapter().getView(0, null, null), 0, 0); } }); ThreadViewFragment fragment = (ThreadViewFragment) waitForFragment("thread_view_fragment", 5000); assertNotNull("fragment not initialized", fragment); }
From source file:dev.ronlemire.dialogs.ListViewFragment.java
public void refresh(int index) { mCurCheckPosition = index;//from w w w. j a va 2s . com // Populate list with our static array of titles. ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(parentActivity, R.array.list_titles, android.R.layout.simple_list_item_single_choice); setListAdapter(adapter); ListView lv = getListView(); lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lv.setItemChecked(mCurCheckPosition, true); lv.performItemClick(lv, mCurCheckPosition, lv.getItemIdAtPosition(mCurCheckPosition)); }
From source file:com.zawadz88.realestate.test.MainActivityTest.java
@FlakyTest public void testContentReplacementOnNavigationDrawerListItemClicked() { final int articlesPosition = Section.ARTICLES.getPosition(); final ListView listView = (ListView) solo.getView(com.zawadz88.realestate.R.id.navigation_list); assertEquals(solo.getString(com.zawadz88.realestate.R.string.section_title_ads), getActivity().getActionBarTitle()); getActivity().runOnUiThread(new Runnable() { @Override//from w w w . ja v a2s. c o m public void run() { listView.performItemClick(listView.getAdapter().getView(articlesPosition, null, null), articlesPosition, listView.getAdapter().getItemId(articlesPosition)); } }); Condition titleChangedCondition = new Condition() { @Override public boolean isSatisfied() { return solo.getString(com.zawadz88.realestate.R.string.section_title_articles) .equals(getActivity().getActionBarTitle()); } }; assertTrue(solo.waitForCondition(titleChangedCondition, 2000)); }
From source file:com.simplealertdialog.test.SupportActivityTest.java
public void testItems() throws Throwable { runTestOnUiThread(new Runnable() { @Override/*w ww.j av a 2 s . c om*/ public void run() { activity.findViewById(R.id.btn_items).performClick(); activity.getSupportFragmentManager().executePendingTransactions(); } }); getInstrumentation().waitForIdleSync(); Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog"); assertNotNull(f); Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog(); assertNotNull(d); final ListView lv = (ListView) d.findViewById(R.id.list); assertNotNull(lv); runTestOnUiThread(new Runnable() { @Override public void run() { lv.performItemClick(lv, 0, 0); } }); getInstrumentation().waitForIdleSync(); }
From source file:com.simplealertdialog.test.SupportActivityTest.java
public void testItemsWithIcons() throws Throwable { runTestOnUiThread(new Runnable() { @Override/* www. j a va2 s . c o m*/ public void run() { activity.findViewById(R.id.btn_icon_items).performClick(); activity.getSupportFragmentManager().executePendingTransactions(); } }); getInstrumentation().waitForIdleSync(); Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog"); assertNotNull(f); Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog(); assertNotNull(d); final ListView lv = (ListView) d.findViewById(R.id.list); assertNotNull(lv); runTestOnUiThread(new Runnable() { @Override public void run() { lv.performItemClick(lv, 0, 0); } }); getInstrumentation().waitForIdleSync(); }
From source file:com.simplealertdialog.test.SupportActivityTest.java
public void testSingleChoiceItems() throws Throwable { runTestOnUiThread(new Runnable() { @Override/*from w w w . jav a 2 s . c o m*/ public void run() { activity.findViewById(R.id.btn_single_choice_list).performClick(); activity.getSupportFragmentManager().executePendingTransactions(); } }); getInstrumentation().waitForIdleSync(); Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog"); assertNotNull(f); Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog(); assertNotNull(d); final ListView lv = (ListView) d.findViewById(R.id.list); assertNotNull(lv); runTestOnUiThread(new Runnable() { @Override public void run() { lv.performItemClick(lv, 0, 0); } }); getInstrumentation().waitForIdleSync(); }
From source file:com.simplealertdialog.test.FragmentSupportActivityTest.java
public void testSingleChoiceItems() throws Throwable { runTestOnUiThread(new Runnable() { @Override/*from w w w .jav a 2 s .co m*/ public void run() { Fragment f = activity.getSupportFragmentManager().findFragmentById(R.id.fragment_sample); assertNotNull(f); assertNotNull(f.getView()); f.getView().findViewById(R.id.btn_frag_single_choice_list).performClick(); activity.getFragmentManager().executePendingTransactions(); } }); getInstrumentation().waitForIdleSync(); Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog"); assertNotNull(f); Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog(); assertNotNull(d); final ListView lv = (ListView) d.findViewById(R.id.list); assertNotNull(lv); runTestOnUiThread(new Runnable() { @Override public void run() { lv.performItemClick(lv, 0, 0); } }); }
From source file:com.simplealertdialog.test.SupportActivityTest.java
public void testAdapter() throws Throwable { runTestOnUiThread(new Runnable() { @Override//from w ww . j ava 2 s.c o m public void run() { activity.findViewById(com.simplealertdialog.test.R.id.btn_adapter).performClick(); activity.getSupportFragmentManager().executePendingTransactions(); } }); getInstrumentation().waitForIdleSync(); Fragment f = getActivity().getSupportFragmentManager().findFragmentByTag("dialog"); assertNotNull(f); Dialog d = ((SimpleAlertDialogSupportFragment) f).getDialog(); assertNotNull(d); final ListView lv = (ListView) d.findViewById(R.id.list); assertNotNull(lv); assertTrue(lv.getAdapter() instanceof SweetsAdapter); runTestOnUiThread(new Runnable() { @Override public void run() { lv.performItemClick(lv, 0, 0); } }); getInstrumentation().waitForIdleSync(); }