`

ViewPager、Fragment、ListView组合使用

阅读更多

OrderCenterActivity.java:

 

package com.weijie.user.activity;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.weijie.user.R;

public class OrderCenterActivity extends BaseFragmentActivity{

	private ViewPager viewPager;
	private final int ALL = 0;
	private final int PRE_PAY = 1;
	private final int PRE_SEND = 2;
	private final int AFTER_SEND = 3;
	private final int PRE_ESTIMATE = 4;
	private TextView allText,prePayText,preSendText,afterSendText,preEstimateText;
	private List<Map<String, Object>> mData1,mData2,mData3,mData4,mData5;
	private TextView refund_aftersales_tv;//退款/售后
	private ImageView cursor;// 动画图片
	private int offset = 0;// 动画图片偏移量
	private int currIndex = 0;// 当前页卡编号
	private int bmpW;// 动画图片宽度
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.order_center);
		//mData = getData();
		initTab();
		InitImageView(); 
		viewPager = (ViewPager) findViewById(R.id.viewPager);
		MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager());
		viewPager.setAdapter(adapter);
		viewPager.setOnPageChangeListener(new MyOnPageChangeListener());  
		viewPager.setCurrentItem(ALL);
	}
	
	private void initTab() {
		allText = (TextView) findViewById(R.id.text1);
		prePayText = (TextView) findViewById(R.id.text2);
		preSendText = (TextView) findViewById(R.id.text3);
		afterSendText = (TextView) findViewById(R.id.text4);
		preEstimateText = (TextView) findViewById(R.id.text5);
		refund_aftersales_tv = (TextView) findViewById(R.id.refund_aftersales_tv);
		
		allText.setOnClickListener(new MyOnClickListener(0));
		prePayText.setOnClickListener(new MyOnClickListener(1));
		preSendText.setOnClickListener(new MyOnClickListener(2));
		afterSendText.setOnClickListener(new MyOnClickListener(3));
		preEstimateText.setOnClickListener(new MyOnClickListener(4));
		refund_aftersales_tv.setOnClickListener(new OnClickRefundListener());
	}
	
	//退款/售后
	public class OnClickRefundListener implements OnClickListener {

		@Override
		public void onClick(View view) {
			Intent intent = new Intent(OrderCenterActivity.this,
					OrderRefundingActivity.class);
			startActivity(intent);
		}
	}
	
	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("goods_img", R.drawable.goods_img);
		map.put("product_title", "红玫瑰花束鲜花预定合肥鲜花速递生日鲜花");
		map.put("shop_name", "GXG官方旗舰店");
		map.put("order_number", "2件商品");
		map.put("order_price", "¥98.00");
		list.add(map);

		map = new HashMap<String, Object>();
		map.put("goods_img", R.drawable.goods_img);
		map.put("product_title", "红玫瑰花束鲜花预定合肥鲜花速递生日鲜花");
		map.put("shop_name", "GXG官方旗舰店");
		map.put("order_number", "3件商品");
		map.put("order_price", "¥98.00");
		list.add(map);

		map = new HashMap<String, Object>();
		map.put("goods_img", R.drawable.goods_img);
		map.put("product_title", "红玫瑰花束鲜花预定合肥鲜花速递生日鲜花");
		map.put("shop_name", "GXG官方旗舰店");
		map.put("order_number", "4件商品");
		map.put("order_price", "¥98.00");
		list.add(map);

		return list;
	}
	
	private List<Map<String, Object>> getData2() {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("goods_img", R.drawable.goods_img);
		map.put("product_title", "韩版男式衬衫 休闲 圆领 热销中");
		map.put("shop_name", "GXG官方旗舰店");
		map.put("order_number", "2件商品");
		map.put("order_price", "¥98.00");
		list.add(map);

		map = new HashMap<String, Object>();
		map.put("goods_img", R.drawable.goods_img);
		map.put("product_title", "红玫瑰花束鲜花预定合肥鲜花速递生日鲜花");
		map.put("shop_name", "GXG官方旗舰店");
		map.put("order_number", "4件商品");
		map.put("order_price", "¥98.00");
		list.add(map);

		return list;
	}
	
	private List<Map<String, Object>> getData3() {
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("goods_img", R.drawable.goods_img);
		map.put("product_title", "阿迪达斯 时尚运动鞋 特价 促销中");
		map.put("shop_name", "GXG官方旗舰店");
		map.put("order_number", "2件商品");
		map.put("order_price", "¥98.00");
		list.add(map);

		return list;
	}
	
	/**
	 * 初始化动画
	 */
	private void InitImageView() {
		cursor = (ImageView) findViewById(R.id.cursor);
		Bitmap bitMap = BitmapFactory.decodeResource(getResources(), R.drawable.tab_red_bottom);
		bmpW = bitMap.getWidth();// 获取图片宽度
		DisplayMetrics dm = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(dm);
		int screenW = dm.widthPixels;// 获取分辨率宽度
		offset = (screenW / 5 - bmpW) / 2;// 计算偏移量
		Matrix matrix = new Matrix();
		matrix.postTranslate(0, 0);
		matrix.postScale(((float) (screenW / 5)) / bmpW, bitMap.getHeight());
		cursor.setImageMatrix(matrix);// 设置动画初始位置
	}
	
	/**
	 * 头标点击监听
	 */
	public class MyOnClickListener implements View.OnClickListener {
		private int index = 0;

		public MyOnClickListener(int i) {
			index = i;
		}
		
		@Override
		public void onClick(View v) {
			viewPager.setCurrentItem(index);  
		}
	}
	
	class MyPagerAdapter extends FragmentPagerAdapter{

		public MyPagerAdapter(FragmentManager fm) {
			super(fm);
		}

		@Override
		public Fragment getItem(int position) {
			Fragment fragment = new OrderCenterFragment();
			Bundle args = new Bundle();
			args.putInt(OrderCenterFragment.ARG_SECTION_NUMBER, position);
			fragment.setArguments(args);
			return fragment;
		}

		@Override
		public int getCount() {
			return 5;
		}
    	
    }
	
	@SuppressLint("ValidFragment")
	class OrderCenterFragment extends Fragment{
		public static final String ARG_SECTION_NUMBER = "section_number";
		
		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
				Bundle savedInstanceState) {
			int section = getArguments().getInt(ARG_SECTION_NUMBER);
			ListView listView=null;
			OrderCenterAdapter adapter=null;
			//发送请求加载数据列表
			System.out.println("i==="+section);
			if("0".equals(section+"")){
				mData1 = getData();
				listView = (ListView) inflater.inflate(R.layout.fragment_order_center, container, false);
				adapter = new OrderCenterAdapter(getActivity(),section+"",mData1);
			}else if("1".equals(section+"")){
				mData2 = getData3();
				listView = (ListView) inflater.inflate(R.layout.fragment_order_center, container, false);
				adapter = new OrderCenterAdapter(getActivity(),section+"",mData2);
			}else if("2".equals(section+"")){
				mData3 = getData2();
				listView = (ListView) inflater.inflate(R.layout.fragment_order_center, container, false);
				adapter = new OrderCenterAdapter(getActivity(),section+"",mData3);
			}else if("3".equals(section+"")){
				mData4 = getData3();
				listView = (ListView) inflater.inflate(R.layout.fragment_order_center, container, false);
				adapter = new OrderCenterAdapter(getActivity(),section+"",mData4);
			}else if("4".equals(section+"")){
				mData5 = getData3();
				listView = (ListView) inflater.inflate(R.layout.fragment_order_center, container, false);
				adapter = new OrderCenterAdapter(getActivity(),section+"",mData5);
			}
			
			
			listView.setAdapter(adapter);
			
			return listView;
		}
		
	}
	
	public final class ViewHolder {
		public ImageView goods_img;
		public TextView product_title;
		public TextView shop_name;
		public TextView order_number;
		public TextView order_price;
		public TextView order_tv1;
		public TextView order_tv2;
		
	}
	
	//自定义ListView适配器
	class OrderCenterAdapter extends BaseAdapter{

		private LayoutInflater mInflater;
//		private List<Object> items;
		private String section; 
		private List<Map<String, Object>> mData;
		
		
		public OrderCenterAdapter(Context context,String section,List<Map<String, Object>> mData){
			mInflater = LayoutInflater.from(context);
//			items = new ArrayList<Object>();
			this.section=section;
			this.mData=mData;
		}
		
		public void addItems(List<Object> list){
			if(list != null && list.size() > 0){
//				items.add(list);
				notifyDataSetChanged();
			}
		}
		
		@Override
		public int getCount() {
			return mData.size();
		}

		@Override
		public Object getItem(int position) {
			return null;
//			return items.get(position);
		}

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

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			ViewHolder holder = null;
			if (convertView == null) {

				holder = new ViewHolder();
				convertView = mInflater.inflate(R.layout.order_center_listview,
						null);
				holder.product_title = (TextView) convertView
						.findViewById(R.id.product_title);
				holder.goods_img = (ImageView) convertView
						.findViewById(R.id.goods_img);
				holder.shop_name = (TextView) convertView
						.findViewById(R.id.shop_name);
				holder.order_number = (TextView) convertView
						.findViewById(R.id.order_number);
				holder.order_price = (TextView) convertView
						.findViewById(R.id.order_price);
				holder.order_tv1 = (TextView) convertView
						.findViewById(R.id.order_tv1);
				holder.order_tv2 = (TextView) convertView
						.findViewById(R.id.order_tv2);

				convertView.setTag(holder);
				

			} else {

				holder = (ViewHolder) convertView.getTag();
			}
			
			LinearLayout item_info=(LinearLayout) convertView.findViewById(R.id.item_info);
			item_info.setOnClickListener(new ItemClickListenerImpl((String) mData.get(position).get("order_number")));

			
			holder.goods_img.setBackgroundResource((Integer) mData.get(
					position).get("goods_img"));
			holder.product_title.setText((String) mData.get(position).get(
					"product_title"));
			holder.shop_name.setText((String) mData.get(position).get(
					"shop_name"));
			holder.order_number.setText((String) mData.get(position).get(
					"order_number"));
			holder.order_price.setText((String) mData.get(position).get("order_price"));
			
			//默认隐藏
			holder.order_tv1.setVisibility(View.INVISIBLE); //不显示,但是占位置
			holder.order_tv2.setVisibility(View.INVISIBLE); //不显示,但是占位置
			//全部
			if("0".equals(section)){
				
			}else if("1".equals(section)){//待付款
				holder.order_tv1.setVisibility(View.VISIBLE);
				holder.order_tv1.setText("取消订单");
				holder.order_tv2.setVisibility(View.VISIBLE);
				holder.order_tv2.setText("付  款");
			}else if("2".equals(section)){//待发货
				holder.order_tv1.setVisibility(View.VISIBLE);
				holder.order_tv1.setText("提醒发货");
			}else if("3".equals(section)){//已发货
				holder.order_tv1.setVisibility(View.VISIBLE);
				holder.order_tv1.setText("确认收货");
				holder.order_tv2.setVisibility(View.VISIBLE);
				holder.order_tv2.setText("查看物流");
			}else if("4".equals(section)){//待评价
				holder.order_tv1.setVisibility(View.VISIBLE);
				holder.order_tv1.setText("评  价");
			}
			
//			if(obj.status == "1"){
//				h.buttonLayout.setVisibility(View.VISIBLE);
//			}
//			Object obj = items.get(position);
			return convertView;
		}
		
	}
	
	//自定义ListView的Item监听事件
	private class ItemClickListenerImpl implements OnClickListener {
		private String testInfo;

		public ItemClickListenerImpl(String testInfo){
			this.testInfo=testInfo;
		}
		
		@Override
		public void onClick(View view) {
			Intent it = new Intent(OrderCenterActivity.this, OrderDetailActivity.class);   // 实例化Intent  
            it.putExtra("testInfo", "我的发送信息测试") ; // 设置附加信息  
            OrderCenterActivity.this.startActivityForResult(it, 1);                        // 启动Activity  
		}
	}
	
	/** 
     * 页卡切换监听 
     */  
    public class MyOnPageChangeListener implements OnPageChangeListener {  
  
		int one = offset * 2 + bmpW+2;// 页卡1 -> 页卡2 偏移量
		int two = one * 2;// 页卡1 -> 页卡3 偏移量
		int three = one * 3-1;
		int four = one * 4-2;
  
        @Override  
        public void onPageSelected(int arg0) {  
            Animation animation = null;  
            switch (arg0) {  
    		case 0:
    			if (currIndex == 1) {
    				animation = new TranslateAnimation(one, 0, 0, 0);
    			} else if (currIndex == 2) {
    				animation = new TranslateAnimation(two, 0, 0, 0);
    			} else if (currIndex == 3) {
    				animation = new TranslateAnimation(three, 0, 0, 0);
    			}else if (currIndex == 4) {
    				animation = new TranslateAnimation(four, 0, 0, 0);
    			}else{
    				animation = new TranslateAnimation(0, 0, 0, 0);
    			}
    			break;
    		case 1:
    			if (currIndex == 0) {
    				animation = new TranslateAnimation(offset, one, 0, 0);
    			} else if (currIndex == 2) {
    				animation = new TranslateAnimation(two, one, 0, 0);
    			} else if (currIndex == 3) {
    				animation = new TranslateAnimation(three, one, 0, 0);
    			}else if (currIndex == 4) {
    				animation = new TranslateAnimation(four, one, 0, 0);
    			}else{
    				animation = new TranslateAnimation(one, one, 0, 0);
    			}
    			break;
    		case 2:
    			if (currIndex == 0) {
    				animation = new TranslateAnimation(offset, two, 0, 0);
    			} else if (currIndex == 1) {
    				animation = new TranslateAnimation(one, two, 0, 0);
    			} else if (currIndex == 3) {
    				animation = new TranslateAnimation(three, two, 0, 0);
    			}else if (currIndex == 4) {
    				animation = new TranslateAnimation(four, two, 0, 0);
    			}else{
    				animation = new TranslateAnimation(two, two, 0, 0);
    			}
    			break;
    		case 3:
    			if (currIndex == 0) {
    				animation = new TranslateAnimation(offset, three, 0, 0);
    			} else if (currIndex == 1) {
    				animation = new TranslateAnimation(one, three, 0, 0);
    			} else if (currIndex == 2) {
    				animation = new TranslateAnimation(two, three, 0, 0);
    			}else if (currIndex == 4) {
    				animation = new TranslateAnimation(four, three, 0, 0);
    			}else{
    				animation = new TranslateAnimation(three, three, 0, 0);
    			}
    			break;
    		case 4:
    			if (currIndex == 0) {
    				animation = new TranslateAnimation(offset, four, 0, 0);
    			} else if (currIndex == 1) {
    				animation = new TranslateAnimation(one, four, 0, 0);
    			} else if (currIndex == 2) {
    				animation = new TranslateAnimation(two, four, 0, 0);
    			}else if (currIndex == 3) {
    				animation = new TranslateAnimation(three, four, 0, 0);
    			}else{
    				animation = new TranslateAnimation(four, four, 0, 0);
    			}
    			break;
    		}
              
            currIndex = arg0;  
            animation.setFillAfter(true);// True:图片停在动画结束位置  
            animation.setDuration(300);  
            cursor.startAnimation(animation);  
        }  
  
        @Override  
        public void onPageScrolled(int arg0, float arg1, int arg2) {  
        }  
  
        @Override  
        public void onPageScrollStateChanged(int arg0) {  
        }  
    }  
}

 

 

 

 

 

order_center.xml:

 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ffffff"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="48dp"
            android:background="@drawable/main_header_bg"
            android:gravity="center_vertical"
            android:paddingLeft="10dp"
            android:paddingRight="10dp" >

            <ImageView
                android:id="@+id/header_back"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:src="@drawable/go_back" />
            <!-- 订单中心 -->

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="10dp"
                android:layout_toRightOf="@id/header_back"
                android:text="订单中心"
                android:textColor="@color/white"
                android:textSize="24sp" />

            <TextView
                android:id="@+id/refund_aftersales_tv"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:text="退款/售后"
                android:textColor="@color/white"
                android:textSize="18sp" />
        </RelativeLayout>
        <!-- 搜索信息 -->


        <!-- 搜索框 -->

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#F0EFF4"
            android:paddingBottom="6dp"
            android:paddingTop="8dp" >

            <EditText
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:background="@drawable/edittext_order_center_search"
                android:hint="搜索任务名或店铺名"
                android:paddingLeft="40dp" />
            <!-- 搜索按钮 -->

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:layout_marginLeft="20dp"
                android:src="@drawable/order_center_search" />
        </FrameLayout>
        <!-- tab标签栏 -->

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="fill_parent"
            android:layout_height="40dp"
            android:background="#FFFFFF" >

            <!-- 全部 -->

            <TextView
                android:id="@+id/text1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:gravity="center"
                android:text="全部"
                android:textColor="#000000"
                android:textSize="16sp" />

            <View
                android:layout_width="2dp"
                android:layout_height="30dp"
                android:layout_gravity="center_vertical"
                android:background="#F3F2F6" />

            <!-- 待付款 -->

            <TextView
                android:id="@+id/text2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:gravity="center"
                android:text="待付款"
                android:textColor="#000000"
                android:textSize="16sp" />

            <View
                android:layout_width="2dp"
                android:layout_height="30dp"
                android:layout_gravity="center_vertical"
                android:background="#F3F2F6" />

            <!-- 待取件 -->

            <TextView
                android:id="@+id/text3"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:gravity="center"
                android:text="待取件"
                android:textColor="#000000"
                android:textSize="16sp" />

            <View
                android:layout_width="2dp"
                android:layout_height="30dp"
                android:layout_gravity="center_vertical"
                android:background="#F3F2F6" />

            <!-- 已发货 -->

            <TextView
                android:id="@+id/text4"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:gravity="center"
                android:text="已发货"
                android:textColor="#000000"
                android:textSize="16sp" />

            <View
                android:layout_width="2dp"
                android:layout_height="30dp"
                android:layout_gravity="center_vertical"
                android:background="#F3F2F6" />

            <!-- 待评价 -->

            <TextView
                android:id="@+id/text5"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_weight="1.0"
                android:gravity="center"
                android:text="待评价"
                android:textColor="#000000"
                android:textSize="16sp" />
        </LinearLayout>

        <!-- 左右移动线条 -->

        <ImageView
            android:id="@+id/cursor"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scaleType="matrix"
            android:src="@drawable/tab_red_bottom" />

        <View
            android:layout_width="fill_parent"
            android:layout_height="8dp"
            android:layout_gravity="center_vertical"
            android:background="#F0EFF4" />

         <android.support.v4.view.ViewPager
	        android:layout_width="match_parent"
	        android:layout_height="match_parent"
	        android:id="@+id/viewPager" /> 
        <!--<ListView
            android:id="@+id/list_view"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:divider="#F0EFF4"
            android:dividerHeight="14dp" /> -->
    </LinearLayout>

</RelativeLayout>

 

 

 

 

 

fragment_order_center.xml:

 

<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/list_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:divider="#F0EFF4"
    android:dividerHeight="14dp"
    android:background="@color/white"
    android:orientation="vertical" >

    <!-- <ListView
        android:id="@+id/list_view"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:divider="#F0EFF4"
        android:dividerHeight="14dp" /> -->

</ListView>

 

 

 

 

 

order_center_listview.xml:

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/white"
    android:orientation="vertical" >

    <!-- 店铺名称 -->

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="10dp"
        android:layout_marginTop="10dp"
        android:gravity="center_vertical"
        android:orientation="horizontal" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:src="@drawable/house_black" />

        <TextView
            android:id="@+id/shop_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:textColor="#4A4A4A"
            android:textSize="18sp" />
    </LinearLayout>

    <View
        android:layout_width="fill_parent"
        android:layout_height="2dip"
        android:layout_gravity="center"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:background="#B6B6B6" />

    <LinearLayout
        android:id="@+id/item_info"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <!-- 商品图片 -->

        <ImageView
            android:id="@+id/goods_img"
            android:layout_width="80dip"
            android:layout_height="90dip"
            android:layout_margin="10dp"
            android:scaleType="centerInside"/>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <!-- 商品标题名称 -->

            <TextView
                android:id="@+id/product_title"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginRight="5dp"
                android:text="红玫瑰花束鲜花专卖店     生日鲜花    节日鲜花"
                android:textColor="@color/black"
                android:textSize="18sp" />

            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal" >

                <TextView
                    android:id="@+id/order_number"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textColor="#999999"
                    android:textSize="18sp" />
				
                <!-- 订单价格 -->
                <TextView
                    android:id="@+id/order_price"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_marginRight="10dp"
                    android:textColor="@color/order_price"
                    android:textSize="20sp" />
            </RelativeLayout>

            <!-- 按钮 -->
            <RelativeLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:layout_marginBottom="15dp"
                android:orientation="horizontal" >

                <TextView
                    android:id="@+id/order_tv1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="10dp"
                    android:background="@drawable/textview_style_pay"
                    android:textColor="@color/white"
                    android:textSize="18sp" />

                <TextView
                    android:id="@+id/order_tv2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    android:layout_marginRight="15dp"
                    android:layout_toLeftOf="@id/order_tv1"
                    android:background="@drawable/textview_style_pay"
                    android:textColor="@color/white"
                    android:textSize="18sp" />
            </RelativeLayout>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

 

 

  • 大小: 49.1 KB
分享到:
评论

相关推荐

    Android 仿微信 fragment+viewpager+listview实例

    通过这个实例,开发者不仅可以学习到Fragment、ViewPager和ListView的基本使用,还能了解到如何将它们组合起来,构建出一个具有实际功能的Android应用。同时,对于新人来说,这也是一个很好的练习项目,能够提升对...

    viewpager+listview联动

    在Android开发中,"ViewPager+ListView联动"是一个常见的布局组合,用于实现丰富的用户交互效果,尤其是在展示滚动内容和多层级信息时。标题中的"viewpager+listview联动"指的是在一个ViewPager中嵌套一个或多个...

    最简单的viewpager + listview

    在Android应用开发中,"最简单的viewpager + listview"是一种常见的组合,用于构建具有丰富交互体验的界面。ViewPager和ListView都是Android SDK提供的核心组件,它们可以协同工作,实现上下左右都能滑动的动态效果...

    网易新闻首页效果(ViewPager+Fragment+ListView)

    【标题】:“网易新闻首页效果”是通过使用ViewPager、Fragment和ListView这三种核心组件实现的。这个项目展示了如何在Android应用中构建一个类似网易新闻客户端首页的动态滑动页面。 【描述】:在这个项目中,...

    android ViewPager 和 listview的共存问题

    然而,在实际应用中,有时我们需要将两者结合使用,比如在一个页面中既有ViewPager的滑动效果,又有ListView的数据展示。这种情况下,可能会遇到一些共存问题。本文将深入探讨这些问题及其解决方案。 首先,我们来...

    TabLayout+ViewPager+ListView

    在Android应用开发中,"TabLayout+ViewPager+ListView"是一个常见的组合,用于构建具有多页面切换和列表数据展示的功能。这个组合提供了丰富的用户体验,让用户能够通过左右滑动切换不同的Tab,同时在每个Tab内可以...

    集侧滑、fragment、viewpager、listview横向滑动于一体的demo(+新特性,见描述)

    集侧滑、fragment、viewpager、listview横向滑动于一体的demo 加新特性:fragment跳转fragment,这个问题困扰我好久了,今天总算解决了,f1首页中第一个button,点击之后可以进入f2,欢迎下载,如有不懂私法我,上篇...

    ViewPager+Listview上拉刷新下拉加载

    首先,`ViewPager`与`ListView`的结合通常涉及到`Fragment`,因为`ViewPager`内部通常会包含多个`Fragment`,每个`Fragment`对应一个`ListView`。在处理刷新和加载更多功能时,我们需要一个合适的库来辅助我们,如`...

    ViewPager与listview的横向滚动

    为了将`ListView`集成到`ViewPager`中,我们需要创建一个自定义的`Fragment`,在这个`Fragment`内部包含一个`ListView`。 在`Fragment`中,你需要设置`ListView`的布局文件,并且为其创建一个适配器,这个适配器...

    集侧滑、fragment、viewpager、listview横向滑动于一体的demo

    这个名为"集侧滑、fragment、viewpager、listview横向滑动于一体的demo"的项目,旨在展示如何将这四种核心组件无缝融合,为用户提供丰富的交互体验。下面将详细阐述这些组件的特点以及它们在项目中的应用。 首先,...

    slidingMenu+viewpager+fragment+listView

    在Android应用开发中,"slidingMenu+viewPager+Fragment+listView"是一个常见的组合,用于构建具有侧滑菜单、页面切换、动态内容加载和列表展示功能的复杂用户界面。以下是对这个组合中的各个组件及其相互作用的详细...

    listview与viewpager组合

    将ListView与ViewPager结合使用,可以创建出更丰富的用户界面,比如在列表顶部添加一个可滑动的头部区域。下面我们将详细探讨如何将ViewPager作为ListView的Header来实现这一功能。 首先,我们需要理解ListView的...

    Android viewpager+listview例子

    在Android开发中,`ViewPager`和`ListView`是两种非常重要的组件,它们分别用于实现页面滑动...通过学习和实践这个例子,开发者不仅可以掌握如何使用`ViewPager`和`ListView`,还能深入理解Android应用的性能优化技巧。

    标题RadioButton内容viewpager,fragment,listView组合

    1.标题栏用RadioGroup,RadioButton来实现,下面的展示由viewpager和fragment组合实现,内容为listView。 2.可以点击radiobutton 改变选中状态,进行切换fragment。 3.由于用了viewpager,也可以左右滑动。 4.代码...

    viewpager+listview

    在Android开发中,`ViewPager` 和 `ListView` 是两种非常重要的视图组件,它们结合使用可以构建出丰富多样的交互效果。本项目标题为“viewpager+listview”,描述指出它实现了左右滑动和上下滑动的功能,这通常用于...

    新闻首页效果[仿网易](ViewPager+Fragment+ListView)

    新闻首页效果[仿网易](ViewPager+Fragment+ListView), 1.添加fragment对象到fragment列表 2.添加title到title列表 3.从title列表中取出内容放到tabLayout容器中 4.创建并初始化适配器 5.为viewPager设定适配器 6....

    ViewPager+ListView上拉加载下拉刷新

    结合使用时,可以构建出丰富的用户交互界面,例如在一个`ViewPager`中嵌套多个含有`ListView`的页面。本知识点主要讲解如何实现`ViewPager+ListView`的组合,并加入上拉加载更多和下拉刷新的功能。 首先,`...

    ViewPager嵌套ListVIew实现上拉和下拉刷新

    在Android开发中,有时我们需要在一个页面中展示大量的数据,这时我们可能会选择使用ViewPager结合ListView来构建一个可滑动且分页的视图。标题“ViewPager嵌套ListView实现上拉和下拉刷新”揭示了一个关键的技术点...

    android的viewpager+fragment+listView图片缓存

    在Android开发中,`ViewPager`、`Fragment`和`ListView`是常见的组件,它们结合使用可以构建出丰富多样的用户界面。在这个场景中,我们主要关注如何在`ViewPager`配合`Fragment`展示`ListView`时,高效地处理图片...

    FragmentTabHost+fragment+viewpager listview跟新

    FragmentTabHost+fragment+viewpager为主体框架,登陆为模仿QQ登陆(可以记录每次登陆账号&lt;使用sqlite&gt;+popwindows),含有popWindow封装的弹出选择按钮。有较为复杂的xml界面。优酷跑马灯效果,上拉刷新,下拉加载...

Global site tag (gtag.js) - Google Analytics