Android Open Source - forklift Mountain List Fragment






From Project

Back to project page forklift.

License

The source code is released under:

Apache License

If you think the Android project forklift listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.example.forklift;
/* w  w  w.j  a  va2s. c o  m*/
import android.app.ListFragment;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteQueryBuilder;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class MountainListFragment extends ListFragment {
    private MountainCursorAdapter adapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        adapter = new MountainCursorAdapter(getActivity(), null, 0);
        setListAdapter(adapter);

        return inflater.inflate(R.layout.list, null);
    }

    @Override
    public void onResume() {
        super.onResume();

        new LoadDataTask().execute();
    }

    private class LoadDataTask extends AsyncTask<Void, Void, Cursor> {

        @Override
        protected Cursor doInBackground(Void... params) {
            MountainsResourceSqliteOpenHelper helper = new MountainsResourceSqliteOpenHelper(getActivity());
            SQLiteDatabase db = helper.getDatabase();

            SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
            builder.setTables("mountains");
            return builder.query(db, null, null, null, null, null, "height desc");
        }

        @Override
        protected void onPostExecute(Cursor cursor) {
            adapter.changeCursor(cursor);
        }
    }
}




Java Source Code List

ch.gluecode.forklift.AbstractAssetSqliteOpenHelper.java
ch.gluecode.forklift.AbstractBundledSqliteOpenHelper.java
ch.gluecode.forklift.AbstractResourceSqliteOpenHelper.java
ch.gluecode.forklift.BundledSqliteOpenHelperException.java
com.example.forklift.CantonListFragment.java
com.example.forklift.CantonsAssetSqliteOpenHelper.java
com.example.forklift.MountainCursorAdapter.java
com.example.forklift.MountainListFragment.java
com.example.forklift.MountainsResourceSqliteOpenHelper.java
com.example.forklift.SampleActivity.java