Android Open Source - firstcodeandroid My Adapter

From Project

Back to project page firstcodeandroid.


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;


  public int getCount() {
    return lists.size();

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

  public long getItemId(int position) {
    return position;

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

Java Source Code List