Android Open Source - Bucky Dataset Cursor Adapter






From Project

Back to project page Bucky.

License

The source code is released under:

GNU General Public License

If you think the Android project Bucky 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 net.tedstein.Bucky.util;
// w w w  . ja  v  a 2  s  . com
import java.util.Date;

import net.tedstein.Bucky.BuckyProvider;
import net.tedstein.Bucky.R;
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;

/*
 * This class will produce a list that shows both the name and the createdAt time of each set. To
 * display only the name, check out SimpleDatasetCursorAdapter.
 */
public class DatasetCursorAdapter extends CursorAdapter {
    private int layout;

    public DatasetCursorAdapter(Context context, Cursor c, int layout) {
        super(context, c);
        this.layout = layout;
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {
        LayoutInflater infl = LayoutInflater.from(context);
        View set_view = infl.inflate(layout, parent, false);
        return set_view;
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        TextView name = (TextView)view.findViewById(R.id.OverviewItemName);
        TextView date = (TextView)view.findViewById(R.id.OverviewItemDate);

        int id_index = cursor.getColumnIndex(BuckyProvider.DS_ID);
        int name_index = cursor.getColumnIndex(BuckyProvider.DS_NAME);
        int date_index = cursor.getColumnIndex(BuckyProvider.DS_WHENCREATED);

        name.setText(cursor.getString(name_index));
        date.setText(new Date(cursor.getLong(date_index)).toString());

        // Store an Integer with the set's ID as view's tag for later retrieval.
        view.setTag(new Integer(cursor.getInt(id_index)));
    }
}




Java Source Code List

net.tedstein.Bucky.BuckyProvider.java
net.tedstein.Bucky.CreateSet.java
net.tedstein.Bucky.Overview.java
net.tedstein.Bucky.SetDetail.java
net.tedstein.Bucky.util.DatapointAdder.java
net.tedstein.Bucky.util.DatapointCursorAdapter.java
net.tedstein.Bucky.util.DatasetCursorAdapter.java
net.tedstein.Bucky.util.SetChoiceHandler.java
net.tedstein.Bucky.util.SetChooser.java
net.tedstein.Bucky.util.SimpleDatasetCursorAdapter.java