Browse Source

车辆布局

developer
lh 8 years ago
parent
commit
2ba55f2125
8 changed files with 82 additions and 27 deletions
  1. +19
    -3
      app/src/main/java/com/qhclh/ytzh/index/planorder/CarsActivity.java
  2. +2
    -2
      app/src/main/java/com/qhclh/ytzh/index/planorder/CarsAdapter.java
  3. +4
    -4
      app/src/main/res/drawable/shape_bg.xml
  4. +17
    -0
      app/src/main/res/drawable/shape_bg1.xml
  5. +19
    -9
      app/src/main/res/layout/act_cars.xml
  6. +18
    -9
      app/src/main/res/layout/item_cars.xml
  7. +2
    -0
      app/src/main/res/values/colors.xml
  8. +1
    -0
      app/src/main/res/values/strings.xml

+ 19
- 3
app/src/main/java/com/qhclh/ytzh/index/planorder/CarsActivity.java View File

@ -1,5 +1,8 @@
package com.qhclh.ytzh.index.planorder;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.LinearLayout;
@ -17,6 +20,8 @@ import butterknife.BindView;
*/
public class CarsActivity extends BaseActivity {
@BindView(R.id.toolbar)
Toolbar mToolbar;
@BindView(R.id.gv_cars)
GridView gv_cars;
private List<CarsBean> carsBeanList;
@ -28,14 +33,19 @@ public class CarsActivity extends BaseActivity {
@Override
protected void initView() {
initToolbar(mToolbar, "车辆", new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
@Override
protected void initData() {
carsBeanList = new ArrayList<>();
for (int i=0;i<10;i++){
carsBeanList.add(new CarsBean(i,"aa"+i,"bb"+i));
carsBeanList.add(new CarsBean(i+11,"aa"+i,"bb"+i));
}
carsAdapter = new CarsAdapter(this,carsBeanList);
gv_cars.setAdapter(carsAdapter);
@ -43,6 +53,12 @@ public class CarsActivity extends BaseActivity {
@Override
protected void initOper() {
gv_cars.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
showToast(l+"");
}
});
}
}

+ 2
- 2
app/src/main/java/com/qhclh/ytzh/index/planorder/CarsAdapter.java View File

@ -38,7 +38,7 @@ public class CarsAdapter extends BaseAdapter {
@Override
public long getItemId(int i) {
return i;
return carsBeen.get(i).getId();
}
@Override
@ -62,6 +62,6 @@ public class CarsAdapter extends BaseAdapter {
class ViewHolder {
public TextView time;
public Button name;
public TextView name;
}
}

+ 4
- 4
app/src/main/res/drawable/shape_bg.xml View File

@ -7,10 +7,10 @@
android:width="@dimen/dp_1"
android:color="@color/grey888888" />
<corners
android:bottomLeftRadius="@dimen/dp_2"
android:bottomRightRadius="@dimen/dp_2"
android:topLeftRadius="@dimen/dp_2"
android:topRightRadius="@dimen/dp_2" />
android:bottomLeftRadius="@dimen/dp_3"
android:bottomRightRadius="@dimen/dp_3"
android:topLeftRadius="@dimen/dp_3"
android:topRightRadius="@dimen/dp_3" />
<size
android:width="@dimen/dp_20"
android:height="@dimen/dp_20" />

+ 17
- 0
app/src/main/res/drawable/shape_bg1.xml View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/greyf2" />
<stroke
android:width="@dimen/dp_1"
android:color="@color/grey888888" />
<corners
android:bottomLeftRadius="@dimen/dp_3"
android:bottomRightRadius="@dimen/dp_3"
android:topLeftRadius="@dimen/dp_3"
android:topRightRadius="@dimen/dp_3" />
<size
android:width="@dimen/dp_20"
android:height="@dimen/dp_20" />
</shape>

+ 19
- 9
app/src/main/res/layout/act_cars.xml View File

@ -1,20 +1,30 @@
<?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">
android:layout_height="match_parent"
android:background="@color/greyf4f4f4"
android:orientation="vertical">
<include layout="@layout/include_tool_bar"></include>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/dp_10"
android:text="@string/driver1"
android:background="@color/greyf4f4f4"
android:textColor="@color/grey888888" />
<GridView
android:id="@+id/gv_cars"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnWidth="100dp"
android:gravity="center_horizontal"
android:horizontalSpacing="5dp"
android:verticalSpacing="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:padding="@dimen/dp_10"
android:verticalSpacing="15dp">
</GridView>
</LinearLayout>

+ 18
- 9
app/src/main/res/layout/item_cars.xml View File

@ -1,16 +1,25 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/cars_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_bg1"
android:gravity="center_horizontal"
android:textColor="@color/black303030"
android:padding="@dimen/dp_3"
android:textSize="@dimen/text_size_20" />
<TextView
android:id="@+id/cars_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:textColor="@color/grey666666"
android:textSize="@dimen/text_size_18" />
</LinearLayout>

+ 2
- 0
app/src/main/res/values/colors.xml View File

@ -21,7 +21,9 @@
<color name="grey_a3a3a3">#a3a3a3</color>
<color name="green029737">#029737</color>
<color name="grey888888">#888888</color>
<color name="grey666666">#666666</color>
<color name="greyf4f4f4">#f4f4f4</color>
<color name="greyf2">#f2f2f2f2</color>
<color name="greydbdbdb">#dbdbdb</color>
<color name="greycacaca">#cacaca</color>
<color name="black303030">#303030</color>


+ 1
- 0
app/src/main/res/values/strings.xml View File

@ -15,6 +15,7 @@
<string name="supplier">供货商:</string>
<string name="variety">品种:</string>
<string name="driver">司机:</string>
<string name="driver1">司机</string>
<string name="number">数量:</string>
<string name="permission_camera">请给予应用打开摄像头权限</string>
<string name="permission_phonestate">请给予应用获取手机状态权限</string>


Loading…
Cancel
Save