Android Open Source - budget-envelopes Simple Envelopes Adapter

From Project

Back to project page budget-envelopes.


The source code is released under:

GNU General Public License

If you think the Android project budget-envelopes 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

 * This file is a part of Budget with Envelopes.
 * Copyright 2013 Michael Howell <>
 *//ww w .j a v  a  2 s.c  o m
 * Budget is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * Budget is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with Budget. If not, see <>.

package com.notriddle.budget;

import android.content.Context;
import android.database.Cursor;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;

public class SimpleEnvelopesAdapter extends SimpleCursorAdapter {
    private int sdkVersion = android.os.Build.VERSION.SDK_INT;

    boolean mExpanded;
    static final String[] FROM = new String[] {
    static final int[] TO = new int[] {
    public SimpleEnvelopesAdapter(Context cntx, Cursor csr) {
        super(cntx, android.R.layout.simple_list_item_1, csr, FROM, TO, 0);
        mExpanded = false;
    public SimpleEnvelopesAdapter(Context cntx, Cursor csr, int layout) {
        super(cntx, layout, csr, FROM, TO, 0);
        mExpanded = false;
    public void setExpanded(boolean expanded) {
        mExpanded = expanded;
    @Override public View getView(int pos, View conv, ViewGroup par) {
        View retVal = super.getView(pos, conv, par);
        if (mExpanded) {
            changeColor(pos, retVal);
        return retVal;
    @Override public View getDropDownView(int pos, View conv, ViewGroup par) {
        View retVal = super.getDropDownView(pos, conv, par);
        changeColor(pos, retVal);
        return retVal;
    @Override public View newDropDownView(Context cntx, Cursor csr,
                                          ViewGroup parent) {
        View retVal = LayoutInflater.from(cntx).inflate(
        bindView(retVal, cntx, csr);
        return retVal;
    private void changeColor(int pos, View change) {
        Cursor csr = getCursor();
        int color = csr.getInt(csr.getColumnIndexOrThrow("color"));
        if(sdkVersion < android.os.Build.VERSION_CODES.JELLY_BEAN) {
        } else {

Java Source Code List