Example usage for android.support.v4.app ListFragment setListAdapter

List of usage examples for android.support.v4.app ListFragment setListAdapter

Introduction

In this page you can find the example usage for android.support.v4.app ListFragment setListAdapter.

Prototype

public void setListAdapter(ListAdapter adapter) 

Source Link

Document

Provide the cursor for the list view.

Usage

From source file:org.solovyev.android.list.ListItemAdapter.java

public static <LI extends ListItem> void attach(@Nonnull ListFragment listFragment,
        @Nonnull ListItemAdapter<? extends LI> adapter) {
    listFragment.setListAdapter(adapter);

    fillListView(listFragment.getListView(), adapter, listFragment.getActivity());
}

From source file:org.solovyev.android.list.ListItemAdapter.java

public static <LI extends ListItem> void attach(@Nonnull android.app.ListFragment listFragment,
        @Nonnull ListItemAdapter<? extends LI> adapter) {
    listFragment.setListAdapter(adapter);

    fillListView(listFragment.getListView(), adapter, listFragment.getActivity());
}

From source file:com.android.test.uibench.listview.CompatListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentById(android.R.id.content) == null) {
        ListFragment listFragment = new ListFragment();
        listFragment.setListAdapter(createListAdapter());
        fm.beginTransaction().add(android.R.id.content, listFragment).commit();
    }//from w w w  . j  av  a  2 s. c o m
}

From source file:com.android.test.uibench.ShadowGridActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentById(android.R.id.content) == null) {
        ListFragment listFragment = new ListFragment() {
            @Override/*from w  ww .  j a v a 2 s. c  o m*/
            public void onViewCreated(View view, Bundle savedInstanceState) {
                super.onViewCreated(view, savedInstanceState);
                getListView().setDivider(null);
            }
        };

        listFragment.setListAdapter(
                new ArrayAdapter<>(this, R.layout.card_row, R.id.card_text, TextUtils.buildSimpleStringList()));
        fm.beginTransaction().add(android.R.id.content, listFragment).commit();
    }
}

From source file:universe.constellation.orion.viewer.OrionFileManagerActivity.java

private void createRecentView(ListFragment list) {
    ListView recent = list.getListView();
    if (showRecentsAndSavePath()) {
        recent.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                GlobalOptions.RecentEntry entry = (GlobalOptions.RecentEntry) parent
                        .getItemAtPosition(position);
                File file = new File(entry.getPath());
                if (file.exists()) {
                    openFile(file);/*  ww  w.  jav a2s  . c o m*/
                }
            }
        });

        list.setListAdapter(new FileChooser(this, globalOptions.getRecentFiles()));
    } else {
        recent.setVisibility(View.GONE);
    }
}

From source file:com.android.test.uibench.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();/*from   ww w .java2  s  .c  o m*/
    String path = intent.getStringExtra(EXTRA_PATH);

    if (path == null) {
        path = "";
    } else {
        // not root level, display where we are in the hierarchy
        setTitle(path);
    }

    FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentById(android.R.id.content) == null) {
        ListFragment listFragment = new ListFragment() {
            @Override
            @SuppressWarnings("unchecked")
            public void onListItemClick(ListView l, View v, int position, long id) {
                Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position);

                Intent intent = (Intent) map.get("intent");
                startActivity(intent);
            }

            @Override
            public void onViewCreated(View view, Bundle savedInstanceState) {
                super.onViewCreated(view, savedInstanceState);
                getListView().setTextFilterEnabled(true);
            }
        };
        listFragment.setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1,
                new String[] { "title" }, new int[] { android.R.id.text1 }));
        fm.beginTransaction().add(android.R.id.content, listFragment).commit();
    }
}

From source file:universe.constellation.orion.viewer.OrionFileManagerActivity.java

private void createFileView(ListFragment list) {
    ListView view = list.getListView();
    view.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            File file = (File) parent.getItemAtPosition(position);
            if (file.isDirectory()) {
                File newFolder = ((FileChooser) parent.getAdapter()).changeFolder(file);
                updatePathTextView(newFolder.getAbsolutePath());
            } else {
                if (showRecentsAndSavePath()) {
                    SharedPreferences.Editor editor = prefs.edit();
                    editor.putString(Common.LAST_OPENED_DIRECTORY, file.getParentFile().getAbsolutePath());
                    editor.commit();//w ww.  jav  a  2  s .  c  o m
                }
                openFile(file);
            }
        }
    });

    list.setListAdapter(new FileChooser(this, getStartFolder(), getFileNameFilter()));
}