cardview
@@ -1,6 +1,8 @@
|
||||
package com.example.ninefourone.nutritionmaster.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -18,6 +20,16 @@ import java.util.ArrayList;
|
||||
public class CardAdapter extends RecyclerView.Adapter<CardHolder> {
|
||||
private Context context;
|
||||
private ArrayList<String> mList;
|
||||
private int[] picList = new int[]{
|
||||
R.drawable.monday,
|
||||
R.drawable.tuesday,
|
||||
R.drawable.wednesday,
|
||||
R.drawable.thursday,
|
||||
R.drawable.friday,
|
||||
R.drawable.saturday,
|
||||
R.drawable.sunday
|
||||
};
|
||||
|
||||
|
||||
public CardAdapter(Context context, ArrayList<String> mList) {
|
||||
this.context = context;
|
||||
@@ -32,9 +44,10 @@ public class CardAdapter extends RecyclerView.Adapter<CardHolder> {
|
||||
return cardHolder;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
public void onBindViewHolder(CardHolder holder, int position) {
|
||||
holder.bindView(mList.get(position));
|
||||
holder.bindView(picList[position], mList.get(position), context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.example.ninefourone.nutritionmaster.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.RequiresApi;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -7,6 +10,8 @@ import android.widget.TextView;
|
||||
|
||||
import com.example.ninefourone.nutritionmaster.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
@@ -23,13 +28,16 @@ public class CardHolder extends RecyclerView.ViewHolder {
|
||||
TextView tvSign;
|
||||
|
||||
|
||||
|
||||
public CardHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
}
|
||||
|
||||
public void bindView(String text) {
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public void bindView(int picId, String text, Context context) {
|
||||
tvName.setText(text);
|
||||
ivPhoto.setImageDrawable(context.getDrawable(picId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.example.ninefourone.nutritionmaster.base.BaseFragment;
|
||||
import com.example.ninefourone.nutritionmaster.cardconfig.CardConfig;
|
||||
import com.example.ninefourone.nutritionmaster.cardconfig.CardItemTouchCallBack;
|
||||
import com.example.ninefourone.nutritionmaster.cardconfig.SwipeCardLayoutManager;
|
||||
import com.example.ninefourone.nutritionmaster.utils.ConstantUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -68,8 +69,8 @@ public class CustomizationFragment extends BaseFragment {
|
||||
@Override
|
||||
protected void loadData() {
|
||||
super.loadData();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
mDataList.add(i + "个");
|
||||
for (int i = 1; i <= 7; i++) {
|
||||
mDataList.add("周" + ConstantUtils.arab2Chinese(i) + "美食普");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,31 @@
|
||||
package com.example.ninefourone.nutritionmaster.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by ScorpioMiku on 2018/8/26.
|
||||
*/
|
||||
|
||||
public class ConstantUtils {
|
||||
public static String arab2Chinese(int number) {
|
||||
switch (number) {
|
||||
case 1:
|
||||
return "一";
|
||||
case 2:
|
||||
return "二";
|
||||
case 3:
|
||||
return "三";
|
||||
case 4:
|
||||
return "四";
|
||||
case 5:
|
||||
return "五";
|
||||
case 6:
|
||||
return "六";
|
||||
case 7:
|
||||
return "日";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BIN
app/src/main/res/drawable/food_test.jpg
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
app/src/main/res/drawable/friday.jpg
Normal file
|
After Width: | Height: | Size: 137 KiB |
BIN
app/src/main/res/drawable/monday.jpg
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
app/src/main/res/drawable/saturday.jpg
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
app/src/main/res/drawable/sunday.jpg
Normal file
|
After Width: | Height: | Size: 124 KiB |
BIN
app/src/main/res/drawable/thursday.jpg
Normal file
|
After Width: | Height: | Size: 163 KiB |
BIN
app/src/main/res/drawable/tuesday.jpg
Normal file
|
After Width: | Height: | Size: 169 KiB |
BIN
app/src/main/res/drawable/wednesday.jpg
Normal file
|
After Width: | Height: | Size: 173 KiB |
@@ -3,6 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="420dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginTop="10dp"
|
||||
@@ -16,16 +17,17 @@
|
||||
android:id="@+id/iv_photo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="350dp"
|
||||
android:background="@drawable/foods" />
|
||||
/>
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/iv_photo"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:text="Rachel"
|
||||
android:textColor="#000000"
|
||||
android:textSize="18sp"
|
||||
@@ -33,11 +35,12 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_sign"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_name"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:text="其他"
|
||||
android:textSize="10sp" />
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/card_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/ic_record">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</android.support.v7.widget.RecyclerView>
|
||||
</LinearLayout>
|
||||