Android Open Source - forklift Mountain Cursor Adapter






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;
/*  www  . ja  va 2s  .  c o m*/
import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.TextView;

public class MountainCursorAdapter extends CursorAdapter {

    public MountainCursorAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        View view = LayoutInflater.from(context).inflate(R.layout.list_item, null);

        ViewHolder viewHolder = new ViewHolder();
        viewHolder.name = (TextView) view.findViewById(R.id.name);
        viewHolder.description = (TextView) view.findViewById(R.id.description);
        view.setTag(viewHolder);

        return view;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        ViewHolder viewHolder = (ViewHolder) view.getTag();
        viewHolder.name.setText(cursor.getString(cursor.getColumnIndex("name")));
        viewHolder.description.setText(context.getString(R.string.mountain_height,
                cursor.getInt(cursor.getColumnIndex("height"))));
    }

    private static class ViewHolder {
        TextView name;
        TextView description;
    }
}




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