Android Open Source - journal Category Spinner Adapter






From Project

Back to project page journal.

License

The source code is released under:

MIT License

If you think the Android project journal 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 cochrane343.journal.dialogs;
//from www.jav  a 2  s. c o m
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import cochrane343.journal.R;
import cochrane343.journal.TranslationHelper;
import cochrane343.journal.contentprovider.JournalContract.Category;

/**
 * The {@link CursorAdapter} used to populate the category spinner of the {@link ExpenseDialogFragment}.
 * 
 * @author cochrane343
 * @version 1.0
 */
public class CategorySpinnerAdapter extends CursorAdapter {  
    
    public CategorySpinnerAdapter(final Context context, final Cursor cursor) {
        super(context, cursor, false);
    }

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

    @Override
    public void bindView(final View view, final Context context, final Cursor cursor) {
        final int categoryNameIndex =  cursor.getColumnIndex(Category._NAME);
        final String categoryName = cursor.getString(categoryNameIndex);
        final String translatedCategoryName = TranslationHelper.translate(categoryName, context);
        final TextView categoryNameTextView = (TextView) view.findViewById(R.id.dropdown_category_name);
        
        categoryNameTextView.setText(translatedCategoryName);
    }
}




Java Source Code List

cochrane343.journal.Constants.java
cochrane343.journal.CurrencyHelper.java
cochrane343.journal.DateTimeHelper.java
cochrane343.journal.ExpenseEditListener.java
cochrane343.journal.ExpensesListAdapter.java
cochrane343.journal.MainActivity.java
cochrane343.journal.MonthlyExpensesFragment.java
cochrane343.journal.MonthlyExpensesPagerAdapter.java
cochrane343.journal.SettingsActivity.java
cochrane343.journal.TranslationHelper.java
cochrane343.journal.contentprovider.JournalContentProvider.java
cochrane343.journal.contentprovider.JournalContract.java
cochrane343.journal.contentprovider.JournalDatabaseHelper.java
cochrane343.journal.dialogs.CategorySpinnerAdapter.java
cochrane343.journal.dialogs.ExpenseDialogFragment.java
cochrane343.journal.dialogs.ExpenseDialogListener.java
cochrane343.journal.exceptions.IllegalDisplayModeException.java
cochrane343.journal.exceptions.IllegalLoaderIdException.java
cochrane343.journal.exceptions.IllegalUriException.java
cochrane343.journal.exceptions.MissingFragmentArgumentException.java