Android Okhttp请求查询购物车的实例代码

查询购物车的model层

public class SelectCarModel {
 private String url="http://120.27.23.105/product/getCarts";
 private HashMap<String, String> map = new HashMap<>();
 public void verifySelectCarInfo(int uid, final ISelectCarPresenter iSelectCarPresenter){
  map.put("uid",uid+"");
  OkHttpUtils.getInstance().doPost(url,map, new CallBack() {
   @Override
   public void onFailed(String msg) {
    iSelectCarPresenter.onFailed("请求失败");
   }
   @Override
   public void onSuccess(String request) {
    SelectCarBean selectCarBean = GsonUtils.getInstance().fromJson(request, SelectCarBean.class);
    String code = selectCarBean.getCode();
    if ("0".equals(code)){
     List<SelectCarBean.DataBean> data = selectCarBean.getData();
     iSelectCarPresenter.onSuccess(data);
    }else{
     iSelectCarPresenter.onFailed("请求失败");
    }
   }
  });
 }
}

查询购物车的接口

m层的

public interface ISelectCarPresenter {
 void onFailed(String msg);
 void onSuccess(List<SelectCarBean.DataBean> data);
}

p层的

public interface ISelectCarView {
 void onFailed(String msg);
 void onSuccess(List<SelectCarBean.DataBean> data);
}

查询购物车的presenter层

public class SelectCarPresenter implements ISelectCarPresenter{
 private ISelectCarView iSelectCarView;
 private SelectCarModel selectCarModel;
 public SelectCarPresenter (ISelectCarView iSelectCarView){
  this.iSelectCarView = iSelectCarView;
  selectCarModel = new SelectCarModel();
 }
 //执行集合信息
 public void excuteSelectCarData(int uid){
  //传到model
  selectCarModel.verifySelectCarInfo(uid,this);
 }
 @Override
 public void onFailed(String msg) {
  iSelectCarView.onFailed(msg);
 }
 @Override
 public void onSuccess(List<SelectCarBean.DataBean> data) {
  iSelectCarView.onSuccess(data);
 }
}

查询购物车的view层

public class ShoppingCartActivity extends AppCompatActivity implements ISelectCarView,View.OnClickListener{
 private boolean isLogin;
 private SelectCarPresenter selectCarPresenter;
 private ExpandableListView car_elv;
 private List<Group> glist = new ArrayList<>();
 private List<List<Child>> clist = new ArrayList<>();
 private CarExpandAdapter carExpandAdapter;
 private TextView edit_tv;
 private CheckBox chooseAll;
 private TextView totalPrice;
 private TextView btnAmount;
 private boolean isAll;
 private double p;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_shoppingcar);
  //初始化数据
  init();
  chooseAll.setOnClickListener(this);
  btnAmount.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View view) {
    Intent intent = new Intent(ShoppingCartActivity.this, IndentActivity.class);
    intent.putExtra("price",p+"");
    startActivity(intent);
   }
  });
 }
 /**
  * 查询购物车
  */
 private void selectShoppingCar() {
   selectCarPresenter = new SelectCarPresenter(this);
   selectCarPresenter.excuteSelectCarData(3381);
   carExpandAdapter = new CarExpandAdapter(this,glist,clist,this);
   car_elv.setAdapter(carExpandAdapter);
 }
 /**
  * 初始化属性
  */
 private void init() {
  car_elv = (ExpandableListView) findViewById(R.id.car_elv);
  edit_tv = (TextView) findViewById(R.id.edit_tv);
  chooseAll = (CheckBox) findViewById(R.id.chooseAll);
  totalPrice = (TextView) findViewById(R.id.totalPrice);
  btnAmount = (TextView) findViewById(R.id.btnAmount);
  //登录购物车
  selectShoppingCar();
 }
 @Override
 public void onFailed(String msg) {
 }
 @Override
 public void onSuccess(List<SelectCarBean.DataBean> data) {
  glist.clear();
  clist.clear();
  for(int i = 0;i<data.size();i++){
   glist.add(new Group(false,data.get(i).getSellerName()));
   List<SelectCarBean.DataBean.ListBean> list = data.get(i).getList();
   List<Child> cl = new ArrayList<>();
   for (int j = 0; j< list.size(); j++){
    cl.add(new Child(false, list.get(j).getTitle(),list.get(j).getPrice(), list.get(j).getImages(), list.get(j).getNum(),list.get(j).getSubhead(),list.get(j).getPid()));
   }
   clist.add(cl);
  }
  for(int s = 0; s < carExpandAdapter.getGroupCount(); s++){
   car_elv.expandGroup(s);
  }
  carExpandAdapter.notifyDataSetChanged();
 }
 @Override
 public void onResume() {
  super.onResume();
  init();
 }
 /**
  * 反选
  * @param isAll
  */
 public void getisAll(Boolean isAll) {
  chooseAll.setChecked(isAll);
 }
 /**
  * 全选按钮
  * @param view
  */
 @Override
 public void onClick(View view) {
  isAll = chooseAll.isChecked();
  if (!(isAll==true)) {
   for (int i = 0; i < glist.size(); i++) {
    glist.get(i).setFlag(false);
    Log.e("Song","123");
   }
   for (int i=0 ;i<clist.size();i++){
    for (int j=0;j<clist.get(i).size();j++){
     clist.get(i).get(j).setFlag(false);
    }
   }
   if (isAll==true){
    isAll=false;
   }
   js();
   carExpandAdapter.notifyDataSetChanged();
  } else {
   for (int i = 0; i < glist.size(); i++) {
    glist.get(i).setFlag(true);
   }
   for (int i=0 ;i<clist.size();i++){
    for (int j=0;j<clist.get(i).size();j++){
     clist.get(i).get(j).setFlag(true);
    }
   }
   if (isAll==false){
    isAll=true;
   }
   js();
   carExpandAdapter.notifyDataSetChanged();
  }
 }
 //结算
 public void js(){
  p = 0;
  int s = 0;//选中商品数量
  for(int i=0;i<clist.size();i++){
   for(int j=0;j<clist.get(i).size();j++){
    if(clist.get(i).get(j).isFlag()){
     double price = clist.get(i).get(j).getPrice();
     int num = clist.get(i).get(j).getNum();
     p += price * num;
     s++;
    }
   }
  }
  totalPrice.setText("总价:"+ p +"¥");
  btnAmount.setText("结算:("+s+")");
 }
}

view层布局

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical" android:layout_width="match_parent"
 android:layout_height="match_parent">
 <RelativeLayout
  android:id="@+id/car_title"
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_weight="1"
  android:background="#fff"
  >
  <TextView
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:gravity="center"
   android:text="购物车"
   android:textColor="#000"
   android:textSize="35dp"
   />
  <TextView
   android:id="@+id/edit_tv"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_weight="1.5"
   android:text="编辑"
   android:textSize="20dp"
   android:layout_marginRight="30dp"
   android:layout_centerVertical="true"
   android:layout_alignParentRight="true"
   android:layout_alignParentEnd="true"
   android:layout_marginEnd="30dp" />
 </RelativeLayout>
 <ExpandableListView
  android:id="@+id/car_elv"
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_weight="9"
  android:layout_below="@+id/car_title"></ExpandableListView>
 <LinearLayout
  android:layout_width="match_parent"
  android:layout_height="0dp"
  android:layout_weight="1"
  android:orientation="horizontal"
  android:layout_gravity="bottom"
  >
  <CheckBox
   android:id="@+id/chooseAll"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textSize="25sp"
   android:padding="10dp"
   android:text="全选"/>

  <TextView
   android:id="@+id/totalPrice"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textSize="25sp"
   android:layout_weight="1"
   android:padding="10dp"
   android:gravity="center"
   android:text="合计:0.00 ¥"/>

  <TextView
   android:id="@+id/btnAmount"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="结算 : (0)"
   android:gravity="center"
   android:background="@android:color/holo_orange_light"
   android:textColor="@android:color/black"
   android:textSize="25sp"
   android:padding="10dp"/>
 </LinearLayout>
</LinearLayout>

二级购物车列表的适配器

public class CarExpandAdapter extends BaseExpandableListAdapter{
 private Context context;
 private List<Group> groupList;
 private List<List<Child>> childList;
 private ShoppingCartActivity s;
 public static boolean flog;
 public CarExpandAdapter(Context context, List<Group> groupList, List<List<Child>> childList,ShoppingCartActivity s) {
  this.context = context;
  this.groupList = groupList;
  this.childList = childList;
  this.s = s;
 }
 @Override
 public int getGroupCount() {
  return groupList.size();
 }
 @Override
 public int getChildrenCount(int i) {
  return childList.get(i).size();
 }
 @Override
 public Object getGroup(int i) {
  return groupList.get(i);
 }
 @Override
 public Object getChild(int i, int i1) {
  return childList.get(i).get(i1);
 }
 @Override
 public long getGroupId(int i) {
  return i;
 }
 @Override
 public long getChildId(int i, int i1) {
  return i1;
 }
 @Override
 public boolean hasStableIds() {
  return false;
 }

 //第一级列表viewhodel
 class GroupViewHolder{
  CheckBox group_box;
  TextView group_tv;
 }
 //第二级列表的viewhodel
 class ChildViewHodel{
  CheckBox child_box;
  ImageView child_iv;
  TextView child_tv_name;
  TextView child_tv_attr;
  TextView child_tv_price;
  TextView child_tv_num;
  TextView child_tv_minus;
  TextView child_tv_show_num;
  TextView child_tv_add;
  Button delete;
 }
 @Override
 public View getGroupView(final int i, boolean b, View view, ViewGroup viewGroup) {
  final GroupViewHolder holder;
  if (view==null){
   holder = new GroupViewHolder();
   view = View.inflate(context, R.layout.group_layout,null);
   holder.group_box = view.findViewById(R.id.group_box);
   holder.group_tv = view.findViewById(R.id.group_tv);
   view.setTag(holder);
  }else{
   holder = (GroupViewHolder) view.getTag();
  }
  holder.group_tv.setText(groupList.get(i).getName());
  holder.group_box.setChecked(groupList.get(i).isFlag());
  holder.group_box.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View view) {
    //group布尔值变成选中状态
    groupList.get(i).setFlag(holder.group_box.isChecked());
    //遍历Group的集合
    for (int i=0;i<groupList.size();i++){
     //如果有一个未选中 全选变成FALSE并跳出
     if (!groupList.get(i).isFlag()){
      s.getisAll(false);
      break;
     }else{
      s.getisAll(true);
     }
    }
    //Child集合布尔值为选中的状态
    for (int j=0;j<childList.get(i).size();j++){
     childList.get(i).get(j).setFlag(holder.group_box.isChecked());
    }
    //刷新适配器
    notifyDataSetChanged();
    s.js();
   }
  });
  return view;
 }
 @Override
 public View getChildView(final int i, final int i1, boolean b, View view, ViewGroup viewGroup) {
  final ChildViewHodel hodel;
  if (view == null){
   hodel = new ChildViewHodel();
   view = View.inflate(context,R.layout.child_layout,null);
   hodel.child_box=view.findViewById(R.id.child_box);
   hodel.child_iv = view.findViewById(R.id.child_iv);
   hodel.child_tv_name = view.findViewById(R.id.child_tv_name);
   hodel.child_tv_attr = view.findViewById(R.id.child_tv_attr);
   hodel.child_tv_price = view.findViewById(R.id.child_tv_price);
   hodel.child_tv_minus = view.findViewById(R.id.child_tv_minus);
   hodel.child_tv_show_num = view.findViewById(R.id.child_tv_show_num);
   hodel.child_tv_add = view.findViewById(R.id.child_tv_add);
   hodel.child_tv_num = view.findViewById(R.id.child_tv_num);
   hodel.delete=view.findViewById(R.id.delete);
   view.setTag(hodel);
  }else{
   hodel = (ChildViewHodel) view.getTag();
  }
  hodel.child_tv_name.setText(childList.get(i).get(i1).getTitle());
  hodel.child_tv_show_num.setText(childList.get(i).get(i1).getNum()+"");
  hodel.child_tv_attr.setText(childList.get(i).get(i1).getColor());
  hodel.child_tv_price.setText(childList.get(i).get(i1).getPrice()+"");
  Glide.with(context).load(childList.get(i).get(i1).getImage().split("\\|")[0]).into(hodel.child_iv);
  hodel.child_box.setChecked(childList.get(i).get(i1).isFlag());
  //删除的点击事件,根据接口删除的
  hodel.delete.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View view) {
    DeletePresenter presenter = new DeletePresenter(new DeleteView() {
     @Override
     public void onDeleteFailure(String error) {
      Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
     }
     @Override
     public void onDeleteSuccesss(String code) {
      Toast.makeText(context, "删除成功", Toast.LENGTH_SHORT).show();
     }
    });
    int pid = childList.get(i).get(i1).getPid();
    presenter.verfiy(3381+"",pid+"");
    childList.get(i).remove(i1);
//    if (childList.get(i).size()==0){
//     groupList.remove(i);
//    }
    notifyDataSetChanged();
   }
  });
  hodel.child_box.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View view) {
    //Child布尔值变成选中状态
    childList.get(i).get(i1).setFlag(hodel.child_box.isChecked());
    //遍历Child集合
    for (int i=0;i<childList.size();i++){
     for (int j=0;j<childList.get(i).size();j++){
      //如果有一个未选中  全选与商家按钮变成false并跳出
      if(!childList.get(i).get(j).isFlag()){
       groupList.get(i).setFlag(false);
       s.getisAll(false);
       break;
      }else{//全部选中 全选与商家按钮变成true
       groupList.get(i).setFlag(true);
       s.getisAll(false);
      }
     }
    }
    //二次遍历
    for(int i=0;i<groupList.size();i++){
     boolean flag = groupList.get(i).isFlag();
     if(flag){
      s.getisAll(true);
     }else{
      s.getisAll(false);
      break;
     }
    }
    notifyDataSetChanged();
    //计算加减
    s.js();
   }
  });
  ////
  hodel.child_tv_minus.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View view) {
    String num = hodel.child_tv_show_num.getText().toString();
    int num1 = Integer.parseInt(num);
    num1--;
    childList.get(i).get(i1).setNum(num1);
    hodel.child_tv_show_num.setText(childList.get(i).get(i1).getNum()+"");
    notifyDataSetChanged();
    s.js();
   }
  });
  hodel.child_tv_add.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View view) {
    String num = hodel.child_tv_show_num.getText().toString();
    int num1 = Integer.parseInt(num);
    num1++;
    childList.get(i).get(i1).setNum(num1);
    hodel.child_tv_show_num.setText(childList.get(i).get(i1).getNum()+"");
    notifyDataSetChanged();
    s.js();
   }
  });
  return view;
 }
 @Override
 public boolean isChildSelectable(int i, int i1) {
  return false;
 }
}

适配器的一级布局

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal" android:layout_width="match_parent"
 android:layout_height="match_parent">
 <CheckBox
  android:id="@+id/group_box"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content" />
 <TextView
  android:id="@+id/group_tv"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="商家"
  />
</LinearLayout>

适配器二级布局

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal" android:layout_width="match_parent"
 android:layout_height="wrap_content">
 <CheckBox
  android:id="@+id/child_box"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_centerVertical="true"
  android:layout_marginLeft="5dp"
  android:scaleX="0.6"
  android:scaleY="0.6" />
 <ImageView
  android:id="@+id/child_iv"
  android:layout_width="70dp"
  android:layout_height="80dp"
  android:layout_centerVertical="true"
  android:layout_marginLeft="5dp"
  android:background="@mipmap/ic_launcher"
  android:layout_toRightOf="@id/child_box" />
 <LinearLayout
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_marginLeft="10dp"
  android:layout_marginTop="15dp"
  android:layout_toRightOf="@id/child_iv"
  android:orientation="vertical">
  <TextView
   android:id="@+id/child_tv_name"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="酒红色纯红色纯羊毛西服套装"
   android:textColor="@android:color/black"
   android:textSize="12sp"
   android:textStyle="bold" />
  <LinearLayout
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:orientation="horizontal">
   <TextView
    android:id="@+id/child_tv_attr"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="3dp"
    android:text="属性:粉蓝色"
    android:textSize="12sp"
    android:textColor="@color/colorPrimary" />
  </LinearLayout>
  <LinearLayout
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_marginTop="4dp"
   android:orientation="horizontal">
   <TextView
    android:id="@+id/child_tv_price"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="¥390"
    android:textColor="@android:color/holo_red_dark"
    android:textSize="12sp"
    android:textStyle="bold" />
   <TextView
    android:id="@+id/child_tv_num"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="20dp"
    android:text="x1"
    android:textColor="@android:color/darker_gray" />
   <LinearLayout
    android:id="@+id/rl_edit"
    android:layout_width="120dp"
    android:background="@android:color/holo_orange_light"
    android:layout_height="30dp"
    android:layout_marginLeft="20dp"
    >
    <TextView
     android:id="@+id/child_tv_minus"
     android:layout_width="0dp"
     android:layout_weight="1"
     android:gravity="center"
     android:textColor="@android:color/black"
     android:background="@android:color/white"
     android:layout_margin="1dp"
     android:layout_height="match_parent"
     android:text=" - " />
    <TextView
     android:id="@+id/child_tv_show_num"
     android:layout_width="0dp"
     android:layout_weight="1"
     android:gravity="center"
     android:background="@android:color/white"
     android:layout_margin="1dp"
     android:layout_height="match_parent"
     android:text="1"
     />
    <TextView
     android:id="@+id/child_tv_add"
     android:layout_width="0dp"
     android:layout_weight="1"
     android:gravity="center"
     android:layout_margin="1dp"
     android:background="@android:color/white"
     android:layout_height="match_parent"
     android:text=" + " />
   </LinearLayout>
  </LinearLayout>
 </LinearLayout>
 <Button
 android:id="@+id/delete"
 android:layout_width="30dp"
 android:layout_height="30dp"
 android:layout_alignParentRight="true"
 android:layout_centerVertical="true"
 android:gravity="center"
 android:text="✘"
 android:background="@android:color/holo_blue_light"
 android:textSize="20sp"
 android:textColor="@android:color/holo_green_dark"
 android:layout_margin="5dp"
 android:visibility="visible" />
</RelativeLayout>

bean类Child

public class Child {
 /*
 false,
 list.get(j).getTitle(),
 (float) list.get(j).getPrice(),
 list.get(j).getImages(),
 list.get(j).getNum()
  */
 private boolean flag;
 private String title;
 private double price;
 private String image;
 private int num;
 private String color;
 private int pid;
 public Child(boolean flag, String title, double price, String image, int num,String color,int pid) {
  this.flag = flag;
  this.title = title;
  this.price = price;
  this.image = image;
  this.num = num;
  this.color = color;
  this.pid = pid;
 }
 public boolean isFlag() {
  return flag;
 }
 public void setFlag(boolean flag) {
  this.flag = flag;
 }
 public String getTitle() {
  return title;
 }
 public void setTitle(String title) {
  this.title = title;
 }
 public double getPrice() {
  return price;
 }
 public void setPrice(double price) {
  this.price = price;
 }
 public String getImage() {
  return image;
 }
 public void setImage(String image) {
  this.image = image;
 }
 public int getNum() {
  return num;
 }
 public void setNum(int num) {
  this.num = num;
 }
 public String getColor() {
  return color;
 }
 public void setColor(String color) {
  this.color = color;
 }
 public int getPid() {
  return pid;
 }
 public void setPid(int pid) {
  this.pid = pid;
 }
}

group类

public class Group {
 private boolean flag;
 private String name;
 public Group(boolean flag, String name) {
  this.flag = flag;
  this.name = name;
 }
 public boolean isFlag() {
  return flag;
 }
 public void setFlag(boolean flag) {
  this.flag = flag;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
}

以上这篇Android Okhttp请求查询购物车的实例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持我们。

您可能感兴趣的文章:

  • 详解Android的OkHttp包编写异步HTTP请求调用的方法
  • Android中使用OkHttp包处理HTTP的get和post请求的方法
(0)

相关推荐

  • Android中使用OkHttp包处理HTTP的get和post请求的方法

    概览 http是现在主流应用使用的网络请求方式, 用来交换数据和内容, 有效的使用HTTP可以使你的APP 变的更快和减少流量的使用 OkHttp 是一个很棒HTTP客户端(GitHub主页:https://github.com/square/okhttp): 支持SPDY, 可以合并多个到同一个主机的请求 使用连接池技术减少请求的延迟(如果SPDY是可用的话) 使用GZIP压缩减少传输的数据量 缓存响应避免重复的网络请求 当你的网络出现拥挤的时候,就是OKHttp 大显身手的时候, 它可以避免

  • 详解Android的OkHttp包编写异步HTTP请求调用的方法

    OkHttp 除了支持常用的同步 HTTP 请求之外,还支持异步 HTTP 请求调用.在使用同步调用时,当前线程会被阻塞,直到 HTTP 请求完成.当同时发出多个 HTTP 请求时,同步调用的性能会比较差.这个时候通过异步调用可以提高整体的性能. 在通过 newCall 方法创建一个新的 Call 对象之后,不是通过 execute 方法来同步执行,而是通过 enqueue 方法来添加到执行队列中.在调用 enqueue 方法时需要提供一个 Callback 接口的实现.在 Callback 接

  • Android Okhttp请求查询购物车的实例代码

    查询购物车的model层 public class SelectCarModel { private String url="http://120.27.23.105/product/getCarts"; private HashMap<String, String> map = new HashMap<>(); public void verifySelectCarInfo(int uid, final ISelectCarPresenter iSelectC

  • Android开发疫情查询app(实例代码)

    一丶工作原理: App 通过请求本地tomcat发布的servlet (调用了 HttpURLConnection 方法)获取MySQL数据库当中的数据,获取数据并返回到App 当中,显示给用户.(其中传递的格式为 json) 使用的工具:Android Studio  开发APP  Eclipse 发布Servlet,数据传递 二丶运行代码: Tomcat 发布的Servlet 类: package com.Servlet; import java.io.IOException; import

  • 关于Android高德地图的简单开发实例代码(DEMO)

    废话不多说了,直接给大家上干货了. 以下为初次接触时 ,练手的DEMO import android.app.Activity; import android.app.ProgressDialog; import android.content.ContentValues; import android.database.Cursor; import android.database.SQLException; import android.database.sqlite.SQLiteDatab

  • 运用JSP+ajax实现分类查询功能的实例代码

    本文主要是介绍了运用JSP+ajax实现分类查询功能的实例代码,分享给大家供大家参考,具体如下: 这次是对小学期关于大学毕业生信息管理系统课程设计中遇到的一些问题和解决方法进行记录和分享. 题目要求:提供企业招聘信息(本年度或历年)查询功能: 首先建立一个jsp文件用来显示数据库信息,并在上面加输入条件的文本框和查询按钮,在这个jsp文件中需要完成一个js函数在用于完成查询功能. <%@ page language="java" pageEncoding="UTF-8&

  • Android 百度地图POI搜索功能实例代码

    在没介绍正文之前先给大家说下poi是什么意思. 由于工作的关系,经常在文件中会看到POI这三个字母的缩写,但是一直对POI的概念和含义没有很详细的去研究其背后代表的意思.今天下班之前,又看到了POI这三个字母,决定认认真真的搜索一些POI具体的含义. POI是英文的缩写,原来的单词是point of interest, 直译成中文就是兴趣点的意思.兴趣点这个词最早来自于导航地图厂商.地图厂商为了提供尽可能多的位置信息,花费了很大的精力去寻找诸如加油站,餐馆,酒店,景点等目的地,这些目的地其实都可

  • Android基于HttpUrlConnection类的文件下载实例代码

    废话不多说了,直接给大家贴代码了,具体代码如所示: /** * get方法的文件下载 * <p> * 特别说明 android中的progressBar是google唯一的做了处理的可以在子线程中更新UI的控件 * * @param path */ private void httpDown(final String path) { new Thread() { @Override public void run() { URL url; HttpURLConnection connectio

  • app 请求服务器json数据实例代码

    请求服务器json数据格式代码,详细如下: var url=obj.serUrl; //此处为请求服务器的路径url,放上自己的请求路径: var data = {//date里面携带参数,根据服务器要求填写好参数,看清楚是字符串类型,还是整型. action:'getUser', username:loginInfowode, password:passwordwode }; //以下就是进入ajax请求服务器数据: mui.ajax({ type:"post",//请求格式,分为p

  • Android 8.0安装apk的实例代码

    android 8.0安装apk需要请求未知来源权限 //xml配置 <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/> /** * 检测版本8.0 */ public void checkOreo() { if (SdkVersionUtils.hasOreo()) {//8.0 //判断是否可以直接安装 boolean canInstall = getPackageM

  • Angularjs添加排序查询功能的实例代码

    废话不多说了,直接给大家贴代码了,具体代码如下所示: <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <script type="text/javascript" src="angular-1.3.0.js"></script&g

  • Android常用正则表达式验证工具类(实例代码)

    东西不多,但一般项目够用了. public class RegularUtil { //身份证 public static final String REGEX_ID_CARD = "^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X)$"; //验证邮箱 public static final String REGEX_EMAIL = "^([a-z0-9A-Z]+[-|\\

随机推荐