| @ -0,0 +1,50 @@ | |||||
| package com.qhclh.ytzh.bean; | |||||
| /** | |||||
| * Created by 青花瓷 on 2017/11/29. | |||||
| */ | |||||
| public class CarsBean { | |||||
| private int id; | |||||
| private String carsname; | |||||
| private String time; | |||||
| public CarsBean(int id, String carsname, String time) { | |||||
| this.id = id; | |||||
| this.carsname = carsname; | |||||
| this.time = time; | |||||
| } | |||||
| public int getId() { | |||||
| return id; | |||||
| } | |||||
| public void setId(int id) { | |||||
| this.id = id; | |||||
| } | |||||
| public String getCarsname() { | |||||
| return carsname; | |||||
| } | |||||
| public void setCarsname(String carsname) { | |||||
| this.carsname = carsname; | |||||
| } | |||||
| public String getTime() { | |||||
| return time; | |||||
| } | |||||
| public void setTime(String time) { | |||||
| this.time = time; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return "CarsBean{" + | |||||
| "id=" + id + | |||||
| ", carsname='" + carsname + '\'' + | |||||
| ", time='" + time + '\'' + | |||||
| '}'; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,48 @@ | |||||
| package com.qhclh.ytzh.index.planorder; | |||||
| import android.widget.GridView; | |||||
| import android.widget.LinearLayout; | |||||
| import com.qhclh.ytzh.R; | |||||
| import com.qhclh.ytzh.base.BaseActivity; | |||||
| import com.qhclh.ytzh.bean.CarsBean; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import butterknife.BindView; | |||||
| /** | |||||
| * Created by 青花瓷 on 2017/11/29. | |||||
| */ | |||||
| public class CarsActivity extends BaseActivity { | |||||
| @BindView(R.id.gv_cars) | |||||
| GridView gv_cars; | |||||
| private List<CarsBean> carsBeanList; | |||||
| private CarsAdapter carsAdapter; | |||||
| @Override | |||||
| protected int setLayoutId() { | |||||
| return R.layout.act_cars; | |||||
| } | |||||
| @Override | |||||
| protected void initView() { | |||||
| } | |||||
| @Override | |||||
| protected void initData() { | |||||
| carsBeanList = new ArrayList<>(); | |||||
| for (int i=0;i<10;i++){ | |||||
| carsBeanList.add(new CarsBean(i,"aa"+i,"bb"+i)); | |||||
| } | |||||
| carsAdapter = new CarsAdapter(this,carsBeanList); | |||||
| gv_cars.setAdapter(carsAdapter); | |||||
| } | |||||
| @Override | |||||
| protected void initOper() { | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,67 @@ | |||||
| package com.qhclh.ytzh.index.planorder; | |||||
| import android.content.Context; | |||||
| import android.view.LayoutInflater; | |||||
| import android.view.View; | |||||
| import android.view.ViewGroup; | |||||
| import android.widget.BaseAdapter; | |||||
| import android.widget.Button; | |||||
| import android.widget.TextView; | |||||
| import com.qhclh.ytzh.R; | |||||
| import com.qhclh.ytzh.bean.CarsBean; | |||||
| import java.util.List; | |||||
| /** | |||||
| * Created by 青花瓷 on 2017/11/29. | |||||
| */ | |||||
| public class CarsAdapter extends BaseAdapter { | |||||
| private Context context; | |||||
| private List<CarsBean> carsBeen; | |||||
| public CarsAdapter(Context context, List<CarsBean> carsBeen) { | |||||
| this.context = context; | |||||
| this.carsBeen = carsBeen; | |||||
| } | |||||
| @Override | |||||
| public int getCount() { | |||||
| return carsBeen.size(); | |||||
| } | |||||
| @Override | |||||
| public Object getItem(int i) { | |||||
| return carsBeen.get(i); | |||||
| } | |||||
| @Override | |||||
| public long getItemId(int i) { | |||||
| return i; | |||||
| } | |||||
| @Override | |||||
| public View getView(int i, View view, ViewGroup viewGroup) { | |||||
| CarsBean message = carsBeen.get(i); | |||||
| ViewHolder viewHolder; | |||||
| if (view == null){ | |||||
| viewHolder = new ViewHolder(); | |||||
| view = LayoutInflater.from(context).inflate(R.layout.item_cars,viewGroup,false); | |||||
| viewHolder.time = view.findViewById(R.id.cars_time); | |||||
| viewHolder.name = view.findViewById(R.id.cars_name); | |||||
| view.setTag(viewHolder); | |||||
| }else { | |||||
| viewHolder = (ViewHolder) view.getTag(); | |||||
| } | |||||
| viewHolder.name.setText(message.getCarsname()); | |||||
| viewHolder.time.setText(message.getTime()); | |||||
| return view; | |||||
| } | |||||
| class ViewHolder { | |||||
| public TextView time; | |||||
| public Button name; | |||||
| } | |||||
| } | |||||
| @ -0,0 +1,20 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
| android:orientation="vertical" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent"> | |||||
| <include layout="@layout/include_tool_bar"></include> | |||||
| <GridView | |||||
| android:id="@+id/gv_cars" | |||||
| android:numColumns="auto_fit" | |||||
| android:stretchMode="columnWidth" | |||||
| android:columnWidth="100dp" | |||||
| android:gravity="center_horizontal" | |||||
| android:horizontalSpacing="5dp" | |||||
| android:verticalSpacing="5dp" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| </GridView> | |||||
| </LinearLayout> | |||||
| @ -0,0 +1,16 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
| android:orientation="vertical" | |||||
| android:gravity="center_horizontal" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/cars_name" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" /> | |||||
| <TextView | |||||
| android:id="@+id/cars_time" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" /> | |||||
| </LinearLayout> | |||||