Android實(shí)現(xiàn)快遞物流時(shí)間軸效果
本文實(shí)例為大家分享了Android實(shí)現(xiàn)快遞物流時(shí)間軸效果展示的具體代碼,供大家參考,具體內(nèi)容如下
首先,這篇參考了別人的代碼。根據(jù)自己的項(xiàng)目需求簡(jiǎn)單改造了一下,效果圖如下

xml:代碼
<?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/lv_list" android:layout_width="match_parent" android:layout_height="wrap_content" android:cacheColorHint="@null" android:divider="@null" > </ListView> </LinearLayout>
接下來是Activity,準(zhǔn)備數(shù)據(jù)就好了
public class TimeLineTextActivity extends Activity{
private ListView listView;
private TimeLineAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
listView=(ListView) findViewById(R.id.lv_list);
listView.setDividerHeight(0);
adapter = new TimeLineAdapter(this, initData());
listView.setAdapter(adapter);
}
private List<Map<String, Object>> initData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("title", "提交已完成......");
map.put("time", "2015-10-22 14:00:00");
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "正在審核中......");
map.put("time", "2015-10-22 15:00:00");
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "客服將會(huì)給您打電話......");
map.put("time", "2015-10-22 16:00:00");
list.add(map);
map = new HashMap<String, Object>();
map.put("title", "訂單已完成");
map.put("time", "2015-10-22 17:00:00");
list.add(map);
return list;
}
}
Adapter:
public class TimeLineAdapter extends BaseAdapter {
private Context context;
private List<Map<String,Object>> list;
private LayoutInflater inflater;
public TimeLineAdapter(Context context, List<Map<String, Object>> list) {
super();
this.context = context;
this.list = list;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
TimeLineHolder viewHolder = null;
if (convertView == null) {
inflater = LayoutInflater.from(parent.getContext());
convertView = inflater.inflate(R.layout.itemtimeline2, null);
viewHolder = new TimeLineHolder();
viewHolder.title = (TextView) convertView.findViewById(R.id.title);
viewHolder.time = (TextView) convertView.findViewById(R.id.time);
convertView.setTag(viewHolder);
} else {
viewHolder = (TimeLineHolder) convertView.getTag();
}
String titleStr = list.get(position).get("title").toString();
viewHolder.title.setText(titleStr);
return convertView;
}
static class TimeLineHolder{
private TextView title,time;
}
}
每一個(gè)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:orientation="vertical" > <View android:id="@+id/view_0" android:layout_width="1dp" android:layout_height="25dp" android:layout_below="@+id/layout_1" android:layout_marginLeft="40dp" android:background="#A6A6A6" /> <ImageView android:id="@+id/image" android:layout_width="15dp" android:layout_height="15dp" android:layout_below="@+id/view_0" android:layout_marginLeft="33dp" android:src="@drawable/timeline_green" /> <View android:id="@+id/view_2" android:layout_width="1dp" android:layout_height="50dp" android:layout_below="@+id/image" android:layout_marginLeft="40dp" android:background="#A6A6A6" /> <View android:id="@+id/view_4" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignBottom="@+id/view_2" android:layout_marginLeft="55dp" android:layout_marginRight="15dp" android:background="#A6A6A6" /> <RelativeLayout android:id="@+id/relative" android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_margin="10dp" android:layout_toRightOf="@+id/view_0" android:layout_alignBottom="@+id/view_4" android:padding="5dp" android:orientation="vertical" > <TextView android:id="@+id/title" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:layout_marginTop="8dp" android:maxEms="7" android:paddingLeft="5dp" android:singleLine="true" android:text="需求提交成功" android:textSize="16sp" /> <TextView android:id="@+id/time" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="end" android:layout_below="@+id/title" android:layout_marginTop="15dp" android:maxEms="7" android:paddingLeft="5dp" android:singleLine="true" android:text="2015-9-28" android:textSize="14sp" /> </RelativeLayout> </RelativeLayout>
其實(shí)這個(gè)東西看起來復(fù)雜,實(shí)際上挺簡(jiǎn)單的,就是一個(gè)ListView,希望對(duì)大家有幫助!
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android快遞物流信息布局開發(fā)
- Android實(shí)現(xiàn)快遞單號(hào)查詢快遞狀態(tài)信息
- Android自定義view仿淘寶快遞物流信息時(shí)間軸
- android實(shí)現(xiàn)快遞跟蹤進(jìn)度條
- Android實(shí)現(xiàn)仿美團(tuán)、順豐快遞數(shù)據(jù)加載效果
- Android實(shí)現(xiàn)快遞物流跟蹤布局效果
- Android使用http請(qǐng)求手機(jī)號(hào)碼歸屬地查詢代碼分享
- Android編程實(shí)現(xiàn)號(hào)碼歸屬地查詢的方法
- kotlin實(shí)現(xiàn)快遞與號(hào)碼歸屬地查詢案例詳解
相關(guān)文章
Flutter 用自定義轉(zhuǎn)場(chǎng)動(dòng)畫實(shí)現(xiàn)頁面切換
本篇介紹了 fluro 導(dǎo)航到其他頁面的自定義轉(zhuǎn)場(chǎng)動(dòng)畫實(shí)現(xiàn),F(xiàn)lutter本身提供了不少預(yù)定義的轉(zhuǎn)場(chǎng)動(dòng)畫,可以通過 transitionBuilder 參數(shù)設(shè)計(jì)多種多樣的轉(zhuǎn)場(chǎng)動(dòng)畫,也可以通過自定義的 AnimatedWidget實(shí)現(xiàn)個(gè)性化的轉(zhuǎn)場(chǎng)動(dòng)畫效果。2021-06-06
android ListView和GridView拖拽移位實(shí)現(xiàn)代碼
有些朋友對(duì)android中ListView和GridView拖拽移位功能的實(shí)現(xiàn)不是很了解,接下來將詳細(xì)介紹,需要了解的朋友可以參考下2012-12-12
Android關(guān)于Button背景或樣式失效問題解決方法
大家好,本篇文章主要講的是Android關(guān)于Button背景或樣式失效問題解決方法,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下2022-01-01
Android Activity之間相互調(diào)用與傳遞參數(shù)的原理與用法分析
這篇文章主要介紹了Android Activity之間相互調(diào)用與傳遞參數(shù)的原理與用法,較為詳細(xì)的分析了Android組件的構(gòu)成以及Activity的創(chuàng)建、調(diào)用、切換等相關(guān)操作技巧,需要的朋友可以參考下2016-08-08
Android自定義View實(shí)現(xiàn)圓形環(huán)繞效果
這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)圓形環(huán)繞效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-01-01
Android使用TextInputLayout創(chuàng)建登陸頁面
這篇文章主要為大家詳細(xì)介紹了Android使用TextInputLayout創(chuàng)建登陸頁面,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10
android 上傳aar到私有maven服務(wù)器的示例
這篇文章主要介紹了android 上傳aar到私有maven服務(wù)器,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-11-11

