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.jikexueyuan.getmyphonenumber;
//from  w w  w  .j a  v  a  2s  . 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.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MyAdapter extends BaseAdapter{
  
  private List<PhoneInfo> lists;
  private Context context;
  private LinearLayout layout;
  
  public MyAdapter(List<PhoneInfo> lists,Context context) {
    this.lists = lists;
    this.context = context;

  }

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

  @Override
  public Object getItem(int position) {
    return lists.get(position);
  }

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

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
//    LayoutInflater inflater = LayoutInflater.from(context);
//    layout = (LinearLayout) inflater.inflate(R.layout.call, null);
//    TextView nametv = (TextView) layout.findViewById(R.id.name);
//    TextView numbertv = (TextView) layout.findViewById(R.id.number);
//    nametv.setText(lists.get(position).getName());
//    numbertv.setText(lists.get(position).getNumber());
    ViewHolder holder;
    if (convertView == null) {
      convertView = LayoutInflater.from(context).inflate(R.layout.call, null);
      holder = new ViewHolder();
      holder.nametv = (TextView) convertView.findViewById(R.id.name);
      holder.numbertv = (TextView) convertView.findViewById(R.id.number);
      holder.nametv.setText(lists.get(position).getName());
      holder.numbertv.setText(lists.get(position).getNumber());
      convertView.setTag(holder);
    }else{
      holder = (ViewHolder) convertView.getTag();
      holder.nametv.setText(lists.get(position).getName());
      holder.numbertv.setText(lists.get(position).getNumber());
    }
    return convertView;
  }
  private static class ViewHolder{
    TextView nametv;
    TextView numbertv;
  }
  
}




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