Android Open Source - Books Special Cursor Adapter






From Project

Back to project page Books.

License

The source code is released under:

Apache License

If you think the Android project Books 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.contender.books;
/*from  w  w w.ja va  2s. co  m*/
import android.content.Context;
import android.database.Cursor;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleCursorAdapter;


/**
 * Extends SimpleCursorAdapter to alternate the backgroundcolor of rows in a ListView.
 * 
 * @author unknown
 */
public class SpecialCursorAdapter extends SimpleCursorAdapter {
  private int[] colors = new int[] { 0x99FFFFFF, 0x99dddddd };
     
    public SpecialCursorAdapter (Context context, int layout, Cursor c, String[] from, int[] to, int flags)  {
        super(context, layout, c, from, to, flags);
    }
 
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = super.getView(position, convertView, parent);
      int colorPos = position % colors.length;
      view.setBackgroundColor(colors[colorPos]);
      return view;
    }
}




Java Source Code List

com.contender.books.BookActivity.java
com.contender.books.BooksStorage.java
com.contender.books.DatePickerFragment.java
com.contender.books.EditOrDeleteDialogFragment.java
com.contender.books.HistoryActivity.java
com.contender.books.MainView.java
com.contender.books.ScanOrManualDialogFragment.java
com.contender.books.SettingsActivity.java
com.contender.books.SpecialCursorAdapter.java
com.google.zxing.integration.android.IntentIntegrator.java
com.google.zxing.integration.android.IntentResult.java