本文实例为大家分享了android快递跟踪进度条展示的具体代码,供大家参考,具体内容如下
activity.class
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import android.app.Activity; import android.os.Bundle; import android.widget.ListView; public class MainActivity extends Activity { private ListView listView; Listdata; private TimelineAdapter timelineAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView = (ListView) this.findViewById(R.id.listview); listView.setDividerHeight(0); timelineAdapter = new TimelineAdapter(this, getData()); listView.setAdapter(timelineAdapter); } private List
适配器
import java.util.List; import java.util.Map; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; public class TimelineAdapter extends BaseAdapter { private List> list; private LayoutInflater inflater; public TimelineAdapter(Context context, List > list) { super(); this.inflater = LayoutInflater.from(context); this.list = list; } @Override public int getCount() { return list.size(); } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder = null; if (cOnvertView== null) { cOnvertView= inflater.inflate(R.layout.listview_item, null); viewHolder = new ViewHolder(); viewHolder.time = (TextView) convertView.findViewById(R.id.tv_time); viewHolder.title = (TextView) convertView.findViewById(R.id.title); convertView.setTag(viewHolder); } else { viewHolder = (ViewHolder) convertView.getTag(); } viewHolder.time.setText(list.get(position).get("time").toString()); viewHolder.title.setText(list.get(position).get("title").toString()); return convertView; } static class ViewHolder { public TextView time; public TextView title; } }
布局文件
activity_main
<&#63;xml version="1.0" encoding="utf-8"&#63;>
listview_item
<&#63;xml version="1.0" encoding="utf-8"&#63;>
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。