Android Open Source - firstcodeandroid My Adapter






From Project

Back to project page firstcodeandroid.

License

The source code is released under:

MIT License

If you think the Android project firstcodeandroid 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.vjia.jokeking;
/*from   ww  w  .j a  v a 2 s  .co  m*/
import java.util.List;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MyAdapter extends BaseAdapter {
  private static String classname = MyAdapter.class.getName();

  private Context context;
  private List<Joke> lists;

  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  public MyAdapter(List<Joke> lists, Context context) {
    // TODO Auto-generated constructor stub
    this.lists = lists;
    this.context = context;
  }

  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  @Override
  public int getCount() {

    {
      // debug
      int size = lists.size();
      Log.d("MyAdapter", "getCount()" + size + "");
    }
    return lists.size();
  }

  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  @Override
  public Object getItem(int position) {
    {
      // debug
      Joke joke = (Joke) lists.get(position);
      Log.d("MyAdapter", "getItem" + position + "=" + joke.toString());
    }

    return lists.get(position);
  }

  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  @Override
  public long getItemId(int position) {
    {
      // debug
      Log.d(classname, "getItemId" + position);
    }
    return position;
  }

  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder holder;
    if (convertView == null) {
      convertView = LayoutInflater.from(context).inflate(R.layout.detail,
          null);
      holder = new ViewHolder();
      holder.contentTV = (TextView) convertView
          .findViewById(R.id.joke_content);
      holder.reviewTV = (TextView) convertView
          .findViewById(R.id.joke_review);
      holder.contentTV.setText(lists.get(position).getContent());
      holder.reviewTV.setText(String.valueOf(lists.get(position)
          .getReview()));
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
      holder.contentTV.setText(lists.get(position).getContent());
      holder.reviewTV.setText(String.valueOf(lists.get(position)
          .getReview()));
    }

    return convertView;
  }

  // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  private static class ViewHolder {
    TextView contentTV;
    TextView reviewTV;
  }

}




Java Source Code List

com.example.activitylifecycletest.DialogActivity.java
com.example.activitylifecycletest.MainActivity.java
com.example.activitylifecycletest.NormalActivity.java
com.example.activitytest.FirstActivity.java
com.example.listviewtest.FruitAdapter.java
com.example.listviewtest.Fruit.java
com.example.listviewtest.MainActivity.java
com.jikexueyuan.counttime.MainActivity.java
com.jikexueyuan.getmyphonenumber.GetNumber.java
com.jikexueyuan.getmyphonenumber.MainActivity.java
com.jikexueyuan.getmyphonenumber.MyAdapter.java
com.jikexueyuan.getmyphonenumber.PhoneInfo.java
com.vjia.bookcollector.MainActivity.java
com.vjia.coolweather.MainActivity.java
com.vjia.coolweather.activity.ChooseAreaActivity.java
com.vjia.coolweather.activity.WeatherActivity.java
com.vjia.coolweather.db.CoolWeatherDB.java
com.vjia.coolweather.db.CoolWeatherOpenHelper.java
com.vjia.coolweather.model.City.java
com.vjia.coolweather.model.County.java
com.vjia.coolweather.model.Province.java
com.vjia.coolweather.util.HttpCallbackListener.java
com.vjia.coolweather.util.HttpUtil.java
com.vjia.coolweather.util.Utility.java
com.vjia.helloandroid.FirstActivity.java
com.vjia.helloandroid.HelloAndroidActivity.java
com.vjia.hellonote.AddContent.java
com.vjia.hellonote.MainActivity.java
com.vjia.hellonote.MyAdapter.java
com.vjia.hellonote.NotesDB.java
com.vjia.hellonote.SelectAct.java
com.vjia.jokeking.GetJoke.java
com.vjia.jokeking.HttpCallbackListener.java
com.vjia.jokeking.HttpUtil.java
com.vjia.jokeking.Joke.java
com.vjia.jokeking.MainActivity.java
com.vjia.jokeking.MyAdapter.java
com.vjia.locationtest.MainActivity.java