Example usage for android.widget ListView performItemClick

List of usage examples for android.widget ListView performItemClick

Introduction

In this page you can find the example usage for android.widget ListView performItemClick.

Prototype

@Override
    public boolean performItemClick(View view, int position, long id) 

Source Link

Usage

From source file:com.simplealertdialog.test.FragmentSupportActivityTest.java

public void testAdapter() throws Throwable {
    runTestOnUiThread(new Runnable() {
        @Override/* www . j  a  va 2s . c o  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_adapter).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);
    assertTrue(lv.getAdapter() instanceof SweetsAdapter);
    runTestOnUiThread(new Runnable() {
        @Override
        public void run() {
            lv.performItemClick(lv, 0, 0);
        }
    });
}

From source file:com.simplealertdialog.test.FragmentSupportActivityTest.java

public void testItems() throws Throwable {
    runTestOnUiThread(new Runnable() {
        @Override//from  w w  w.j a  v a  2  s  . c  o  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_items).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);
    assertTrue(lv.getAdapter() instanceof ArrayAdapter<?>);
    runTestOnUiThread(new Runnable() {
        @Override
        public void run() {
            lv.performItemClick(lv, 0, 0);
        }
    });
}

From source file:com.simplealertdialog.test.FragmentSupportActivityTest.java

public void testItemsWithIcons() throws Throwable {
    runTestOnUiThread(new Runnable() {
        @Override/*from  w  w w.  ja  v  a2s .c o  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_icon_items).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);
    assertTrue(lv.getAdapter() instanceof ArrayAdapter<?>);
    runTestOnUiThread(new Runnable() {
        @Override
        public void run() {
            lv.performItemClick(lv, 0, 0);
        }
    });
}