Android Open Source - Abidan Word Adapter






From Project

Back to project page Abidan.

License

The source code is released under:

Apache License

If you think the Android project Abidan 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.poepoemyintswe.abidan.adapter;
//from w  w  w.ja va 2 s .  com
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.InjectView;
import com.poepoemyintswe.abidan.R;
import com.poepoemyintswe.abidan.models.Word;
import java.util.ArrayList;

/**
 * Created by poepoe on 12/8/14.
 */
public class WordAdapter extends BaseAdapter {

  Context mContext;
  ArrayList<Word> wordArrayList;

  public WordAdapter(Context mContext, ArrayList<Word> wordArrayList) {
    this.mContext = mContext;
    this.wordArrayList = wordArrayList;
  }

  @Override public int getCount() {
    return wordArrayList.size();
  }

  @Override public Word getItem(int i) {
    return wordArrayList.get(i);
  }

  @Override public long getItemId(int i) {
    return i;
  }

  @Override public View getView(int i, View convertView, ViewGroup viewGroup) {
    final ViewHolder holder;
    View view = convertView;
    if (view != null) {
      holder = (ViewHolder) view.getTag();
    } else {
      LayoutInflater inflater =
          (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      view = inflater.inflate(R.layout.row_word, null, false);
      holder = new ViewHolder(view);
      view.setTag(holder);
    }

    final Word word = getItem(i);
    holder.word.setText(word.word);
    holder.type.setText(word.type);
    holder.def.setText(word.def);
    return view;
  }

  public static class ViewHolder {
    @InjectView(R.id.word) TextView word;
    @InjectView(R.id.type) TextView type;
    @InjectView(R.id.def) TextView def;

    public ViewHolder(View view) {
      ButterKnife.inject(this, view);
    }
  }
}




Java Source Code List

com.poepoemyintswe.abidan.ApplicationTest.java
com.poepoemyintswe.abidan.Config.java
com.poepoemyintswe.abidan.SearchActivity.java
com.poepoemyintswe.abidan.adapter.WordAdapter.java
com.poepoemyintswe.abidan.async.WordAsync.java
com.poepoemyintswe.abidan.db.DBHelper.java
com.poepoemyintswe.abidan.models.Word.java
com.poepoemyintswe.abidan.utils.SharePref.java