Android Open Source - book Book List Adapter






From Project

Back to project page book.

License

The source code is released under:

MIT License

If you think the Android project book 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 book;
/*from w ww.  j  a  v  a2 s.  c o  m*/
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.book.R;



/*
 * 
 *    adapter for listing the books in the booklistview
 *     
 * 
 */

public class BookListAdapter extends ArrayAdapter<Book>{
  private List<Book> books;
  private Context context;
  
      
  public BookListAdapter(Context context, List<Book> books) {
    super(context, R.layout.booklistitem);
    this.context = context;
    this.books = books;
    
    if (books.size() > 0){
      for (Book bk : books){
        this.add(bk);
      }
    }
  }

    @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      LayoutInflater inflater = (LayoutInflater) context
          .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView = inflater.inflate(R.layout.booklistitem, parent, false);
      
      TextView bookname = (TextView) rowView.findViewById(R.id.bookname);     
    TextView wordcount = (TextView) rowView.findViewById(R.id.wordcount);
      
      rowView.setTag(this.books.get(position));      
      bookname.setText(this.books.get(position).getName());
      wordcount.setText(new Integer( this.books.get(position).getCount() ).toString());
      
      return rowView;
  }
}




Java Source Code List

book.BookListAdapter.java
book.Book.java
book.ExpandableListAdapter.java
book.SelectableWordListAdapter.java
com.BookTable.java
com.Db.java
com.TranslationsTable.java
com.WordTable.java
fragments.BookListFragment.java
fragments.BookViewFragment.java
fragments.CameraFragment.java
fragments.EditBookFragment.java
fragments.PageAdapter.java
fragments.PagerActivity.java
translator.TranslateWordTask.java
translator.Translator.java