Android Open Source - Bucky Datapoint 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 a2 s.  c om*/
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;

public class DatapointCursorAdapter extends CursorAdapter {
    private int layout;

    public DatapointCursorAdapter(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 value= (TextView)view.findViewById(R.id.SetDetailItemValue);
        TextView date = (TextView)view.findViewById(R.id.SetDetailItemDate);

        int id_index = cursor.getColumnIndex(BuckyProvider.DP_ID);
        int value_index = cursor.getColumnIndex(BuckyProvider.DP_VALUE);
        int date_index = cursor.getColumnIndex(BuckyProvider.DP_WHENCREATED);

        value.setText(cursor.getString(value_index));
        date.setText(new Date(cursor.getLong(date_index)).toString());

        // Store an Integer with the point'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