全部页面的设计和跳转。
package com.example.runapp;//快递页面import androIDx.appcompat.app.AppCompatActivity;import androID.content.Intent;import androID.os.Bundle;import androID.vIEw.VIEw;import androID.Widget.AdapterVIEw;import androID.Widget.ArrayAdapter;import androID.Widget.button;import androID.Widget.ListVIEw;import androID.Widget.Spinner;import com.example.runapp.adapter.AccountItemAdapter;import com.example.runapp.entity.Order;import java.io.Serializable;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date;import java.util.List;public class ShopActivity extends AppCompatActivity {button btn_shop;ListVIEw ListVIEw;Spinner spinner;Order order_intent; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_shop); btn_shop=this.findVIEwByID(R.ID.buttonShop_InsIDe); btn_shop.setonClickListener(new VIEw.OnClickListener() { @OverrIDe public voID onClick(VIEw v) { Intent intent=new Intent(); intent.setClass(ShopActivity.this,AddOrderActivity.class); intent.putExtra("ID","1"); startActivity(intent); } }); //下拉框 SpinnerSet(); //列表 ListVIEwSet(); } private voID SpinnerSet() { spinner=this.findVIEwByID(R.ID.spinner_shop); List<String> List1=new ArrayList<>(); List1.add("按时间"); List1.add("按金额"); final ArrayAdapter<String> adapter=new ArrayAdapter<>(this,androID.R.layout.simple_spinner_item,List1); adapter.setDropDownVIEwResource(androID.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); spinner.setonItemSelectedListener(new Spinner.OnItemSelectedListener(){ public voID onItemSelected(AdapterVIEw<?> arg0, VIEw arg1, int arg2, long arg3) { arg0.setVisibility(VIEw.VISIBLE); } public voID onnothingSelected(AdapterVIEw<?> arg0) { } }); } private voID ListVIEwSet() { //数据库补充 final List<Order> order_List=getTestDate(); ListVIEw=this.findVIEwByID(R.ID.ListVIEw_shop); order_intent=(Order) this.getIntent().getSerializableExtra("order2"); if(order_intent!=null) { order_List.add(order_intent); } AccountItemAdapter adapter=new AccountItemAdapter(order_List, ShopActivity.this); ListVIEw.setAdapter(adapter); ListVIEw.setonItemClickListener(new AdapterVIEw.OnItemClickListener() { @OverrIDe public voID onItemClick(AdapterVIEw<?> parent, VIEw vIEw, int position, long ID) { Order order=new Order(); order=order_List.get(position); Intent intent=new Intent(); intent.setClass(ShopActivity.this,PlayOrderActivity.class); intent.putExtra("order1", (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,"外卖","九栋108一份米线","1","多放辣椒哦","2020-4-28 11:33:21"); result.add(order1); result.add(order2); return result; }}
package com.example.runapp;import androIDx.appcompat.app.AppCompatActivity;import androID.content.Intent;import androID.os.Bundle;import androID.vIEw.VIEw;import androID.Widget.AdapterVIEw;import androID.Widget.ArrayAdapter;import androID.Widget.button;import androID.Widget.ListVIEw;import androID.Widget.Spinner;import com.example.runapp.adapter.AccountItemAdapter;import com.example.runapp.entity.Order;import java.io.Serializable;import java.util.ArrayList;import java.util.List;public class PrintActivity extends AppCompatActivity {button btn_Print;ListVIEw ListVIEw;Spinner spinner;Order order_intent; Order orderFormal=null; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_print); orderFormal=(Order) this.getIntent().getSerializableExtra("order1"); btn_Print=this.findVIEwByID(R.ID.buttonPrint_InsIDe); SpinnerSet(); btn_Print.setonClickListener(new VIEw.OnClickListener() { @OverrIDe public voID onClick(VIEw v) { Intent intent=new Intent(); intent.setClass(PrintActivity.this,AddOrderActivity.class); intent.putExtra("ID","2"); startActivity(intent); } }); ListVIEwSet(); } private voID ListVIEwSet() { //数据库补充 final List<Order> order_List=getTestDate(); ListVIEw=this.findVIEwByID(R.ID.ListVIEw_print); order_intent=(Order) this.getIntent().getSerializableExtra("order2"); if(order_intent!=null) { order_List.add(order_intent); } AccountItemAdapter adapter=new AccountItemAdapter(order_List, PrintActivity.this); ListVIEw.setAdapter(adapter); ListVIEw.setonItemClickListener(new AdapterVIEw.OnItemClickListener() { @OverrIDe public voID onItemClick(AdapterVIEw<?> parent, VIEw vIEw, int position, long ID) { Order order=new Order(); order=order_List.get(position); Intent intent=new Intent(); intent.setClass(PrintActivity.this,PlayOrderActivity.class); intent.putExtra("order1", (Serializable) order); startActivity(intent); } }); } private voID SpinnerSet() { spinner=this.findVIEwByID(R.ID.spinner_Print); List<String> List1=new ArrayList<>(); List1.add("按时间"); List1.add("按金额"); final ArrayAdapter<String> adapter=new ArrayAdapter<>(this,androID.R.layout.simple_spinner_item,List1); adapter.setDropDownVIEwResource(androID.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); if(orderFormal!=null) { for(int i=0;i<List1.size();i++) { if(orderFormal.getMoney().equals(List1.get(i))) { spinner.setSelection(i,true); } } } spinner.setonItemSelectedListener(new Spinner.OnItemSelectedListener(){ public voID onItemSelected(AdapterVIEw<?> arg0, VIEw arg1, int arg2, long arg3) { arg0.setVisibility(VIEw.VISIBLE); } public voID onnothingSelected(AdapterVIEw<?> arg0) { } }); } private List<Order> getTestDate() { List<Order> result=new ArrayList<Order>(); Order order1=new Order(1,"打印","九栋108一份","1","a4纸哦","2020-4-28 11:24:21"); Order order2=new Order(2,"打印","九栋108一份","1","a4纸哦","2020-4-28 11:34:24"); result.add(order1); result.add(order2); return result; }}
总结
以上是内存溢出为你收集整理的十天冲刺第四天全部内容,希望文章能够帮你解决十天冲刺第四天所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)