SCRUM第二阶段第四天

今天主要任务是订单页面的完善

效果图:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".fragment.DingDanFragment"
    android:orientation="vertical"
    android:background="#FFC0CB">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_weight="0.5"

    >

    <TextView
        android:id="@+id/textView17"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:text="订单明细"
        android:gravity="center"
        android:textSize="20sp"
        android:background="@color/colorPrimary"/>
    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/listView_insubmit"
        android:layout_margin="20dp"
        >

    </ListView>
</LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_weight="0.5">

        <TextView
            android:id="@+id/textView18"
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:text="接单明细"
            android:gravity="center"
            android:textSize="20sp"
            android:background="@color/colorPrimary" />
        <ListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/listView_outsubmit"
            android:layout_margin="20dp"
            >

        </ListView>
    </LinearLayout>
</LinearLayout>
package com.example.runapp.fragment;


import android.content.Intent;
import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import com.example.runapp.PlayOrderActivity;
import com.example.runapp.R;
import com.example.runapp.SubmitOrderActivity;
import com.example.runapp.adapter.AccountItemAdapter;
import com.example.runapp.entity.Order;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class DingDanFragment extends Fragment {
ListView listViewin,listViewout;
View mRootView;
Order order_intent_in=null,order_intent_out=null;


    public DingDanFragment() {
        // Required empty public constructor

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
       mRootView=inflater.inflate(R.layout.fragment_ding_dan, container, false);
       InitView();

       return mRootView;
    }

    private void InitView() {
        refreshinData();
        refresOutData();

    }
    private void refreshinData() {

        listViewin=mRootView.findViewById(R.id.listView_insubmit);
        final List<Order> orderList=getTestDate();
        order_intent_in=(Order) getActivity().getIntent().getSerializableExtra("order2");
        if(order_intent_in!=null)
        {
            orderList.add(order_intent_in);
        }
        AccountItemAdapter adapter=new AccountItemAdapter(orderList,getActivity());
        listViewin.setAdapter(adapter);
        listViewin.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Order order=new Order();
                order=orderList.get(position);
                Intent intent=new Intent();
                intent.putExtra("kind","1");
                intent.setClass(getActivity(),  SubmitOrderActivity.class);
                intent.putExtra("order3", (Serializable) order);
                startActivity(intent);


            }
        });
    }
    private void refresOutData() {
        listViewout=mRootView.findViewById(R.id.listView_outsubmit);

        final List<Order> orderList=getTestDate();
        order_intent_out=(Order) getActivity().getIntent().getSerializableExtra("submitOrder");
        if(order_intent_out!=null)
        {
            orderList.add(order_intent_out);
        }
        AccountItemAdapter adapter=new AccountItemAdapter(orderList,getActivity());
        listViewout.setAdapter(adapter);
        listViewout.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Order order=new Order();
                order=orderList.get(position);
                Intent intent=new Intent();
                intent.setClass(getActivity(), SubmitOrderActivity.class);
                intent.putExtra("kind","1");
                intent.putExtra("order4", (Serializable) order);
                startActivity(intent);


            }
        });
    }
    private List<Order> getTestDate()
    {
        List<Order> result=new ArrayList<Order>();

        Order order1=new Order(1,"外卖","九栋108一份炒面","1","不放辣椒哦","2020-4-28 11:23:11");
        Order order2=new Order(2,"快递","中通快递t082","1","九栋108","2020-4-28 11:33:21");
        result.add(order1);
        result.add(order2);
        return result;
    }

}
原文地址:https://www.cnblogs.com/w669399221/p/13085334.html