欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android快遞物流信息布局開發(fā)

 更新時間:2018年05月16日 15:14:38   作者:tpnet  
這篇文章主要為大家詳細介紹了Android快遞物流信息布局開發(fā),具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Android快遞物流信息布局展示的具體代碼,供大家參考,具體內(nèi)容如下

1. 思路介紹

效果圖:

思路:

就一個ListView,每個item就是一條物流信息。然后每個item,分為左和右兩邊,左邊是一個進度條的風(fēng)格,右邊是物流文字,適配器里面判斷item,position為0 就設(shè)置為綠色,其他position就設(shè)置為灰色就行了。

2. 代碼

item的布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 >

 <!-- 左邊 -->
 <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="match_parent"
  android:orientation="vertical"
  >
  <!-- 上面的豎線 -->
  <View
   android:id="@+id/view_top_line"
   android:layout_width="2dp"
   android:layout_height="15dp"
   android:background="@color/lightgray"
   android:layout_gravity="center_horizontal"
   android:layout_marginTop="-1dp"
   />

  <!-- 圓點 -->
  <ImageView
   android:id="@+id/iv_expres_spot"
   android:layout_width="20dp"
   android:layout_height="20dp"
   android:background="@drawable/express_point_old"
   android:layout_marginBottom="2dp"
   android:layout_marginTop="2dp"
   />

 <!-- 豎線 -->
  <View
   android:layout_width="2dp"
   android:layout_height="wrap_content"
   android:background="@color/lightgray"
   android:layout_gravity="center_horizontal"
   />

 </LinearLayout>

 <!-- 右邊 -->
 <LinearLayout
  android:layout_weight="1"
  android:layout_width="0dp"
  android:layout_height="wrap_content"
  android:orientation="vertical"
  android:layout_marginLeft="10dp"
  android:layout_marginTop="17dp"

  >
  <TextView
   android:id="@+id/tv_express_text"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:text="asdfasdfasd大事發(fā)生的蘇打粉asdfasdfas阿斯蒂芬斯蒂芬阿薩德發(fā)達省份撒旦法"
   android:textColor="@color/gray"
   android:lineSpacingExtra="2dp"
   android:textSize="16sp"
   android:textIsSelectable="true"

   />

  <TextView
   android:id="@+id/tv_express_time"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:textColor="@color/lightgray"
   android:textSize="12sp"
   android:text="2016年4月27日 00:27:45"
   android:layout_marginTop="5dp"
   android:textIsSelectable="true"
   android:paddingBottom="10dp"
   />

 <!-- 底部分割線 -->
  <View
   android:layout_width="match_parent"
   android:background="@color/lightgray"
   android:layout_height="0.5dp"
   />
 </LinearLayout>

</LinearLayout>

適配器代碼

package com.tpnet.hlquery.Express;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.tpnet.hlquery.Express.json.Content;
import com.tpnet.hlquery.R;

import java.util.List;

/**
 * Created by tpnet on 2016/4/27.
 */
public class MessListAdapter extends BaseAdapter {


 //allContent就是所有物流信息的list
 private List<Content> allContent;
 private Context context;
 private LayoutInflater layoutInflater;



 MessListAdapter(Context context,List<Content> allContent){
  this.allContent = allContent;
  this.context = context;
  layoutInflater = LayoutInflater.from(context);
 }

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

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

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

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {

  ViewHolder holder;
  if(convertView == null){
   holder = new ViewHolder();
   convertView = layoutInflater.inflate(R.layout.item_express_data,null);
   holder.viewTopLine = convertView.findViewById(R.id.view_top_line);
   holder.ivExpresSpot = (ImageView) convertView.findViewById(R.id.iv_expres_spot);
   holder.tvExpressText = (TextView) convertView.findViewById(R.id.tv_express_text);
   holder.tvExpressTime = (TextView) convertView.findViewById(R.id.tv_express_time);

   //將ViewHolder與convertView進行綁定
   convertView.setTag(holder);
  }else{
   holder = (ViewHolder)convertView.getTag();
  }

  Content content = allContent.get(position);

  //設(shè)置數(shù)據(jù)顏色,防止view 復(fù)用,必須每個設(shè)置
  if(position == 0 ){ //上頂部背景透明,點是灰色,字體是綠色
   holder.viewTopLine.setBackgroundColor(Color.TRANSPARENT);
   holder.ivExpresSpot.setBackgroundResource(R.drawable.express_point_new);
   holder.tvExpressText.setTextColor(context.getResources().getColor(R.color.mainColor));
   holder.tvExpressTime.setTextColor(context.getResources().getColor(R.color.mainColor));
  }else{
   holder.viewTopLine.setBackgroundColor(context.getResources().getColor(R.color.lightgray));
   holder.ivExpresSpot.setBackgroundResource(R.drawable.express_point_old);
   holder.tvExpressText.setTextColor(context.getResources().getColor(R.color.gray));
   holder.tvExpressTime.setTextColor(context.getResources().getColor(R.color.lightgray));
  }

  holder.tvExpressText.setText(content.getContext());
  holder.tvExpressTime.setText(content.getTime());

  return convertView;
 }

 public class ViewHolder{
  public View viewTopLine;
  private ImageView ivExpresSpot;
  private TextView tvExpressText;
  private TextView tvExpressTime;

 }

}

activity那里就new 上面的Adapter,然后設(shè)置進ListView 就可以了。

注意一點:
listView一定要設(shè)置:android:divider=”@null”
不然每個item直接默認(rèn)是有 間隙的。
就這么簡單了,重要的還是item的布局

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 使用反射機制控制Toast的顯示時間

    使用反射機制控制Toast的顯示時間

    這篇文章主要為大家詳細介紹了使用反射機制控制Toast的顯示時間,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-08-08
  • Android后臺啟動Activity的實現(xiàn)示例

    Android后臺啟動Activity的實現(xiàn)示例

    這篇文章主要介紹了Android后臺啟動Activity的實現(xiàn)示例,幫助大家更好的理解和學(xué)習(xí)使用Android開發(fā),感興趣的朋友可以了解下
    2021-04-04
  • Android 調(diào)用百度地圖API示例

    Android 調(diào)用百度地圖API示例

    在Android開發(fā)中有一個非常重要的應(yīng)用就是實時定位,通過手機在手機地圖上進行實時定位,定位當(dāng)前手機的位置,這篇文章主要介紹了Android 調(diào)用百度地圖API示例,有興趣的可以了解一下。
    2017-01-01
  • Android viewpager 3D畫廊的實現(xiàn)方法

    Android viewpager 3D畫廊的實現(xiàn)方法

    ViewPager在開發(fā)中的使用頻率非常的高,接下來通過本文給大家分享android viewpager 3D畫廊的實現(xiàn)方法,需要的朋友參考下吧
    2017-02-02
  • Android自定義view制作抽獎轉(zhuǎn)盤

    Android自定義view制作抽獎轉(zhuǎn)盤

    這篇文章主要為大家詳細介紹了Android自定義view制作抽獎轉(zhuǎn)盤,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-12-12
  • Android中 service組件詳解

    Android中 service組件詳解

    Service是Android的四大組件之一,以下是我結(jié)合Android Doc和網(wǎng)上資料的學(xué)習(xí)總結(jié),有不準(zhǔn)確的地方請高手指出,互相學(xué)習(xí)嘛。。。
    2016-08-08
  • Android字體相關(guān)知識總結(jié)

    Android字體相關(guān)知識總結(jié)

    最近接到一個需求,大致內(nèi)容是:全局替換當(dāng)前項目中的默認(rèn)字體,并引入 UI 設(shè)計師提供的一些新字體。于是對字體做了些研究,把自己的一些心得分享給大家。注意:本文所展示的系統(tǒng)源碼都是基于Android-30 ,并提取核心部分進行分析
    2021-06-06
  • Android三種常見的圖片壓縮方式

    Android三種常見的圖片壓縮方式

    在開發(fā)中,我們經(jīng)常有這樣一種需求,從相冊選擇圖片,上傳到服務(wù)器。隨著手機像素的不斷提升,照片也是小一點的3,4兆,大一點的多大10多兆。如果直接上傳原圖,會增大服務(wù)器壓力,所以,在上傳之前對圖片壓縮就顯得很必要了。
    2021-05-05
  • Android應(yīng)用讀取Excel文件的方法

    Android應(yīng)用讀取Excel文件的方法

    這篇文章主要介紹了Android應(yīng)用讀取Excel文件的方法,涉及Android針對Excel文件的讀寫保存等相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-12-12
  • Android提高之BLE開發(fā)Android手機搜索iBeacon基站

    Android提高之BLE開發(fā)Android手機搜索iBeacon基站

    這篇文章主要介紹了BLE開發(fā)Android手機搜索iBeacon基站,需要的朋友可以參考下
    2014-08-08

最新評論