Android Express Tracking progress bar

Source: Internet
Author: User

Android Express Tracking progress bar

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;
List<string> data;
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<map<string, object>> GetData () {
list<map<string, object>> list = new arraylist<map<string, object>> ();

map<string, object> map = new hashmap<string, object> ();
Map.put ("Time", "2015-05-20 10:15");
Map.put ("title", "Shenzhen Longhua Collection");
List.add (map);

Map = new hashmap<string, object> ();
Map.put ("Time", "2015-05-21 9:25");
Map.put ("title", "Leave Shenzhen, Send to Shanghai");
List.add (map);

Map = new hashmap<string, object> ();
Map.put ("Time", "2015-05-22 12:55");
Map.put ("title", "Shanghai Pujiang Distribution Center");
List.add (map);

Map = new hashmap<string, object> ();
Map.put ("Time", "2015-05-25 9:30");
Map.put ("title", "received express");
List.add (map);
return list;
}

}

Adapter

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<map<string, object>> List;
Private Layoutinflater Inflater;

Public Timelineadapter (context context, list<map<string, object>> 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;
}
}
Layout File
Activity_main

<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
android:orientation= "Vertical" >

<listview
Android:id= "@+id/listview"
Android:layout_width= "Fill_parent"
android:layout_height= "Wrap_content"/>

</LinearLayout>

Listview_item

<?xml version= "1.0" encoding= "Utf-8"?>
<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Match_parent"
android:layout_height= "Match_parent"
Android:background= "#ffffff"
android:orientation= "Vertical"
android:paddingright= "20DP" >
<!--android:src= "@drawable/timeline_green" dot Pictures-
<imageview
Android:id= "@+id/image"
Android:layout_width= "15DP"
android:layout_height= "15DP"
android:layout_marginleft= "65DP"
android:layout_margintop= "5DP"
Android:layout_marginbottom= "5DP"
Android:scaletype= "Fitcenter"
android:src= "@drawable/timeline_green"/>

<view
Android:id= "@+id/view_2"
Android:layout_width= "1DP"
android:layout_height= "60DP"
android:layout_below= "@+id/image"
android:layout_marginleft= "72DP"
android:background= "#A6A6A6"/>
<!--android:background= "@drawable/timeline_content" right picture--
<relativelayout
Android:id= "@+id/relative"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_margintop= "2DP"
android:layout_torightof= "@+id/image"
android:background= "@drawable/timeline_content"
android:padding= "5DP" >

<textview
Android:id= "@+id/title"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
Android:singleline= "true"
android:layout_marginleft= "5DP"
Android:textsize= "13sp"/>

<textview
Android:id= "@+id/tv_time"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:layout_below= "@id/title"
android:layout_marginleft= "5DP"
Android:textcolor= "#0000ff"
Android:textsize= "9sp"/>

</RelativeLayout>

</RelativeLayout>


Android Express Tracking progress bar

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.