Android ListFragment - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ListFragment class.

This code example shows how to use the following methods:
 
import static android.support.v4.app.Watson.OnCreateOptionsMenuListener; 
import static android.support.v4.app.Watson.OnOptionsItemSelectedListener; 
import static android.support.v4.app.Watson.OnPrepareOptionsMenuListener; 
 
public class SherlockListFragment extends ListFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
    private SherlockFragmentActivity mActivity;
 
    public SherlockFragmentActivity getSherlockActivity() { 
        return mActivity;
    } 
 
    @Override 
    public void onAttach(Activity activity) {
        if (!(activity instanceof SherlockFragmentActivity)) {
            throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
        } 
        mActivity = (SherlockFragmentActivity)activity;
 
        super.onAttach(activity);
10
CodeRank
This code example shows how to use the following methods:getListView, getActivity, getArguments, getFragmentManager
	public static int[] color = {Color.BLUE,Color.GRAY,Color.CYAN,Color.RED,Color.GREEN,Color.YELLOW,Color.GRAY,Color.CYAN,Color.RED,Color.BLUE,Color.GRAY};
	public static int numberOfCardOnDeck;
	 
	 
 
	public DataViewFragment() { 
 
	} 
 
	/** 
	 * Create a new instance of DetailsFragment. 
	 */ 
	public static DataViewFragment newInstance(int index, int previousFragmentId) {
		DataViewFragment f = new DataViewFragment();
		// Supply index input as an argument. 
		Bundle args = new Bundle();
		args.putInt("index", index);
		args.putInt("prevFragmentId", previousFragmentId);
		f.setArguments(args);
		args = null;

9
CodeRank
This code example shows how to use the following methods:
import android.os.Bundle; 
import android.support.v4.app.ListFragment; 
import android.view.View; 
import android.widget.ListView; 
 
public class PersistentListFragment extends ListFragment {
  static public final String STATE_CHECKED="com.commonsware.android.feedfrags.STATE_CHECKED";
 
  @Override 
  public void onListItemClick(ListView l, View v, int position,
                              long id) {
    l.setItemChecked(position, true);
  } 
   
  @Override 
  public void onSaveInstanceState(Bundle state) {
    state.putInt(STATE_CHECKED,
                  getListView().getCheckedItemPosition());
  } 
   
9
CodeRank
This code example shows how to use the following methods:
 
import static android.support.v4.app.Watson.OnCreateOptionsMenuListener; 
import static android.support.v4.app.Watson.OnOptionsItemSelectedListener; 
import static android.support.v4.app.Watson.OnPrepareOptionsMenuListener; 
 
public class SherlockListFragment extends ListFragment implements OnCreateOptionsMenuListener, OnPrepareOptionsMenuListener, OnOptionsItemSelectedListener {
    private SherlockFragmentActivity mActivity;
 
    public SherlockFragmentActivity getSherlockActivity() { 
        return mActivity;
    } 
 
    @Override 
    public void onAttach(Activity activity) {
        if (!(activity instanceof SherlockFragmentActivity)) {
            throw new IllegalStateException(getClass().getSimpleName() + " must be attached to a SherlockFragmentActivity.");
        } 
        mActivity = (SherlockFragmentActivity)activity;
 
        super.onAttach(activity);
9
CodeRank
This code example shows how to use the following methods:setEmptyText, setListAdapter, setListShown, getActivity, getLoaderManager
 
        // Task we have running to populate the database. 
        AsyncTask<Void, Void, Void> mPopulatingTask;
 
        @Override public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
 
            setEmptyText("No data.  Select 'Populate' to fill with data from Z to A at a rate of 4 per second.");
            setHasOptionsMenu(true);
 
            // Create an empty adapter we will use to display the loaded data. 
            mAdapter = new SimpleCursorAdapter(getActivity(),
                    android.R.layout.simple_list_item_1, null,
                    new String[] { MainTable.COLUMN_NAME_DATA },
                    new int[] { android.R.id.text1 }, 0);
            setListAdapter(mAdapter);
 
            // Start out with a progress indicator. 
            setListShown(false);
 

8
CodeRank
This code example shows how to use the following methods:getActivity, getParentFragment, onDetach
		mActivityFirstCreated = true;
	} 
 
	@Override 
	public void onDetach() { 
		super.onDetach(); 
		final Activity activity = getActivity();
		if (activity instanceof SupportFragmentCallback) {
			((SupportFragmentCallback) activity).onDetachFragment(this);
		} 
		final Fragment fragment = getParentFragment();
		if (fragment instanceof SupportFragmentCallback) {
			((SupportFragmentCallback) fragment).onDetachFragment(this);
		} 
	} 
 
	public void onPostStart() { 
	} 
 
	@Override 
7
CodeRank
This code example shows how to use the following methods:
package com.korovyansk.android.sample.slideout; 
 
import android.os.Bundle; 
import android.support.v4.app.ListFragment; 
import android.view.View; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 
 
public class MenuFragment extends ListFragment {
 
	@Override 
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		setListAdapter(new ArrayAdapter<String>(getActivity(),
				android.R.layout.simple_list_item_1, new String[] { " First", " Second", " Third", " Fourth", " Fifth", " Sixth"}));
		getListView().setCacheColorHint(0);
	} 
 
	@Override 
	public void onListItemClick(ListView l, View v, int position, long id) {

9
CodeRank
This code example shows how to use the following methods:getActivity
			switchFragment(newContent);
	} 
	 
	// the meat of switching the above fragment 
	private void switchFragment(Fragment fragment) {
		if (getActivity() == null)
			return; 
 
		if (getActivity() instanceof ResponsiveUIActivity) {
			ResponsiveUIActivity ra = (ResponsiveUIActivity) getActivity();
			ra.switchContent(fragment);
		} 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:onCreateView, setListAdapter, getActivity
    public View onCreateView(
        LayoutInflater inflater,
        ViewGroup container,
        Bundle b)
    { 
        View view = super.onCreateView(inflater, container, b);
 
        installListAdapter(getActivity());
 
        return view;
    } 
 
    /** 
     * @see android.support.v4.app.ListFragment#onListItemClick(android.widget.ListView, android.view.View, int, long) 
     */ 
    @Override 
    public void onListItemClick(ListView l, View v, int pos, long row){
        Cursor cursor = (Cursor) getListAdapter().getItem(pos);
        Log.d("####", "Got click at: " + pos);
 

7
CodeRank
This code example shows how to use the following methods:setListAdapter, getActivity, getLoaderManager, onCreate
 
	private Map<String, String> items;
 
	@Override 
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
 
		ListAdapter adapter = new ArrayAdapter<String>(getActivity(),
				android.R.layout.simple_list_item_1, new String[0]);
		setListAdapter(adapter);
 
		getLoaderManager().initLoader(0, null, this);
	} 
 
	@Override 
	public void onStart() { 
		super.onStart(); 
 
		setEmptyText(getActivity().getString(R.string.list_searching_documents));
	} 
7
CodeRank
See Code Examples for Android ListFragment Methods: