Example usage for android.app ListFragment setListAdapter

List of usage examples for android.app ListFragment setListAdapter

Introduction

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

Prototype

public void setListAdapter(ListAdapter adapter) 

Source Link

Document

Provide the cursor for the list view.

Usage

From source file:com.cloudbees.gasp.activity.TwitterStreamActivity.java

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

    getActionBar().setDisplayHomeAsUpEnabled(true);

    // Use simple FrameLayout for ListFragment
    setContentView(R.layout.gasp_frame_layout);

    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ListFragment list = new ListFragment();
    ft.add(R.id.fragment_content, list);

    // Use a simple TextView layout for ArrayAdapter constructor
    mAdapter = new ArrayAdapter<String>(this, R.layout.gasp_generic_textview);

    // Map ArrayAdapter to ListFragment
    list.setListAdapter(mAdapter);

    // RESTResponderFragments call setRetainedInstance(true) in onCreate()
    TwitterResponderFragment responder = (TwitterResponderFragment) fm
            .findFragmentByTag(getString(R.string.twitter_responder));
    if (responder == null) {
        responder = new TwitterResponderFragment();

        ft.add(responder, getString(R.string.twitter_responder));
    }/*  w  ww. j  av a  2s .c  o m*/

    ft.commit();
}

From source file:pl.edu.agh.schedule.myschedule.MyScheduleActivity.java

@Override
public void onFragmentViewCreated(ListFragment fragment) {
    int dayIndex = fragment.getArguments().getInt(DAY_INDEX, 0);
    fragment.setListAdapter(mScheduleAdapters[dayIndex]);
    fragment.getListView().setRecyclerListener(mScheduleAdapters[dayIndex]);
}

From source file:com.google.samples.apps.iosched.ui.BaseScheduleActivity.java

@Override
public void onFragmentViewCreated(ListFragment fragment) {
    fragment.getListView()/*from ww  w  .j  a  va  2 s  .c  o  m*/
            .addHeaderView(getLayoutInflater().inflate(R.layout.reserve_action_bar_space_header_view, null));
    int dayIndex = fragment.getArguments().getInt(ARG_CONFERENCE_DAY_INDEX, 0);
    fragment.setListAdapter(mScheduleAdapters[dayIndex]);
    fragment.getListView().setRecyclerListener(mScheduleAdapters[dayIndex]);
}

From source file:com.cloudbees.gasp.activity.GaspRESTLoaderActivity.java

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

    // Set main content view for Gasp! Reviews
    setContentView(R.layout.gasp_review_activity);

    // Use the Fragments API to display review data
    FragmentManager fm = getFragmentManager();
    ListFragment list = (ListFragment) fm.findFragmentById(R.id.gasp_review_content);
    if (list == null) {
        list = new ListFragment();
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.gasp_review_content, list);
        ft.commit();/* w w w .  ja v a  2  s  .  c o m*/
    }

    // Array adapter provides access to the review list data
    mAdapter = new ArrayAdapter<String>(this, R.layout.gasp_review_list);
    list.setListAdapter(mAdapter);

    // Load shared preferences from res/xml/preferences.xml (first time only)
    // Subsequent activations will use the saved shared preferences from the device
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    SharedPreferences gaspSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    Log.i(TAG, "Using Gasp Server URI: " + gaspSharedPreferences.getString("gasp_endpoint_uri", ""));
    Uri gaspReviewsUri = Uri.parse(gaspSharedPreferences.getString("gasp_endpoint_uri", ""));

    // Loader arguments: LoaderManager will maintain the state of our Loaders
    // and reload if necessary. 
    Bundle args = new Bundle();
    Bundle params = new Bundle();
    args.putParcelable(ARGS_URI, gaspReviewsUri);
    args.putParcelable(ARGS_PARAMS, params);

    // Initialize the Loader.
    getLoaderManager().initLoader(LOADER_GASP_REVIEWS, args, this);

    // Use gasp-mongo REST service
    new ReviewsRequest().execute();

    try {
        LocationsRequest locations = new LocationsRequest(
                new SpatialQuery(new Location(-122.1139858, 37.3774655), 0.005));

        List<GeoLocation> locationList = locations.execute().get();
        for (GeoLocation geoLocation : locationList) {
            Log.i(TAG, geoLocation.getName());
            Log.i(TAG, " " + geoLocation.getFormattedAddress());
            Log.i(TAG, " " + String.valueOf(geoLocation.getLocation().getLng()));
            Log.i(TAG, " " + String.valueOf(geoLocation.getLocation().getLat()));
        }
    } catch (Exception e) {
        Log.e(TAG, e.getLocalizedMessage());
    }
}

From source file:com.saarang.samples.apps.iosched.ui.MyScheduleActivity.java

@Override
public void onFragmentViewCreated(ListFragment fragment) {
    fragment.getListView().addHeaderView(getLayoutInflater()
            .inflate(com.saarang.samples.apps.iosched.R.layout.reserve_action_bar_space_header_view, null));
    int dayIndex = fragment.getArguments().getInt(ARG_CONFERENCE_DAY_INDEX, 0);
    fragment.setListAdapter(mScheduleAdapters[dayIndex]);
    fragment.getListView().setRecyclerListener(mScheduleAdapters[dayIndex]);
}

From source file:com.google.samples.apps.iosched.myschedule.MyScheduleActivity.java

@Override
public void onFragmentViewCreated(ListFragment fragment) {
    fragment.getListView()/*from   w w  w  .j  av  a  2 s. c om*/
            .addHeaderView(getLayoutInflater().inflate(R.layout.reserve_action_bar_space_header_view, null));
    int dayIndex = fragment.getArguments().getInt(ARG_CONFERENCE_DAY_INDEX, 0);
    if (dayIndex < 0) {
        fragment.setListAdapter(mDayZeroAdapter);
        fragment.getListView().setRecyclerListener(mDayZeroAdapter);
    } else {
        fragment.setListAdapter(mScheduleAdapters[dayIndex]);
        fragment.getListView().setRecyclerListener(mScheduleAdapters[dayIndex]);
    }
}