add is ok
This commit is contained in:
@@ -21,6 +21,8 @@ import com.example.ninefourone.nutritionmaster.utils.MessageUtils;
|
||||
import com.github.czy1121.view.TurnCardListView;
|
||||
import com.orhanobut.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
@@ -35,17 +37,15 @@ public class AddActivity extends AppCompatActivity {
|
||||
ImageView backButton;
|
||||
|
||||
|
||||
private int[] colors = {0xff3F51B5, 0xff673AB7, 0xff006064, 0xffC51162, 0xffFFEB3B, 0xff795548, 0xff9E9E9E};
|
||||
private Button[] firstButtons = new Button[colors.length];
|
||||
private Button[] secondButtons = new Button[colors.length];
|
||||
private Button[] thirdButtons = new Button[colors.length];
|
||||
private TextView[] titleViews = new TextView[colors.length];
|
||||
// private int[] colors = {0xff3F51B5, 0xff673AB7, 0xff006064, 0xffC51162, 0xffFFEB3B, 0xff795548, 0xff9E9E9E};
|
||||
private int[] colors = {0xffdef6f9, 0xffd6eeec, 0xffB2EBF2, 0xffB2DFDB, 0xff8ed0ca, 0xff80CBC4, 0xff4DB6AC, 0xff3c948b};
|
||||
private Button[] firstButtons = new Button[ConstantUtils.questionList.length];
|
||||
private Button[] secondButtons = new Button[ConstantUtils.questionList.length];
|
||||
private Button[] thirdButtons = new Button[ConstantUtils.questionList.length];
|
||||
private TextView[] titleViews = new TextView[ConstantUtils.questionList.length];
|
||||
|
||||
private Button[][] buttonList;
|
||||
|
||||
private Button[][] buttonList = new Button[][]{
|
||||
firstButtons,
|
||||
secondButtons,
|
||||
thirdButtons
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
@@ -56,6 +56,11 @@ public class AddActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add);
|
||||
ButterKnife.bind(this);
|
||||
buttonList = new Button[][]{
|
||||
firstButtons,
|
||||
secondButtons,
|
||||
thirdButtons
|
||||
};
|
||||
initAddView();
|
||||
}
|
||||
|
||||
@@ -88,29 +93,34 @@ public class AddActivity extends AppCompatActivity {
|
||||
|
||||
firstButtons[position] = child.findViewById(R.id.choose_first);
|
||||
firstButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
for (int i = 0; i < ConstantUtils.answerList[position].length; i++) {
|
||||
firstButtons[position].setText(ConstantUtils.answerList[position][i]);
|
||||
}
|
||||
|
||||
|
||||
secondButtons[position] = child.findViewById(R.id.choose_second);
|
||||
secondButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
for (int i = 0; i < ConstantUtils.answerList[position].length; i++) {
|
||||
firstButtons[position].setText(ConstantUtils.answerList[position][i]);
|
||||
}
|
||||
|
||||
|
||||
thirdButtons[position] = child.findViewById(R.id.choose_third);
|
||||
thirdButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
|
||||
|
||||
firstButtons[position].setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
firstButtons[position].setBackgroundColor(colors[position] - 60);
|
||||
secondButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
thirdButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
cardList.turnTo(position + 1);
|
||||
}
|
||||
});
|
||||
if (position != ConstantUtils.questionList.length - 1) {
|
||||
firstButtons[position].setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
firstButtons[position].setBackgroundColor(colors[position] - 60);
|
||||
secondButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
thirdButtons[position].setBackgroundColor(colors[position] + 30);
|
||||
cardList.turnTo(position + 1);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
firstButtons[position].setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
MessageUtils.MakeToast("结果");
|
||||
}
|
||||
});
|
||||
}
|
||||
secondButtons[position].setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -129,6 +139,11 @@ public class AddActivity extends AppCompatActivity {
|
||||
cardList.turnTo(position + 1);
|
||||
}
|
||||
});
|
||||
|
||||
for (int i = 0; i < ConstantUtils.answerList[position].length; i++) {
|
||||
buttonList[i][position].setText(ConstantUtils.answerList[position][i]);
|
||||
buttonList[i][position].setVisibility(View.VISIBLE);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
@@ -138,16 +153,9 @@ public class AddActivity extends AppCompatActivity {
|
||||
cardList.setOnTurnListener(new TurnCardListView.OnTurnListener() {
|
||||
@Override
|
||||
public void onTurned(int position) {
|
||||
Toast.makeText(AddActivity.this, "position = " + position, Toast.LENGTH_SHORT).show();
|
||||
bottomContent.setBackgroundColor(colors[position] - 60);
|
||||
}
|
||||
});
|
||||
// cardList.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// cardList.turnTo(1);
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,13 +30,15 @@ public class ConstantUtils {
|
||||
|
||||
|
||||
public static String[] questionList = new String[]{
|
||||
"现在去照照镜子吧",
|
||||
"现在先去找个镜子吧" +
|
||||
"\n下面会用到哦",
|
||||
"你舌苔的颜色",
|
||||
"舌底经络颜色",
|
||||
"口腔整体情况",
|
||||
"整体生活精神状况",
|
||||
"性格特点",
|
||||
"食物温度偏向"
|
||||
"食物温度偏向",
|
||||
"揭晓结果"
|
||||
};
|
||||
|
||||
public static String[][] answerList = new String[][]{
|
||||
@@ -46,6 +48,7 @@ public class ConstantUtils {
|
||||
{"口舌干燥", "口黏苔腻", "还算正常"},
|
||||
{"沉寂易疲劳", "精力充沛"},
|
||||
{"内向", "开朗"},
|
||||
{"烫的", "冷的", "没有特别喜欢的"}
|
||||
{"烫的", "冷的", "没有特别喜欢的"},
|
||||
{"查看"}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/bottom_content"
|
||||
android:layout_width="match_parent"
|
||||
android:background="#334397"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#e2eced"
|
||||
tools:context="com.example.ninefourone.nutritionmaster.modules.addinformation.AddActivity">
|
||||
|
||||
|
||||
@@ -22,4 +23,21 @@
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/ic_back_button" />
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="450dp"
|
||||
android:layout_centerInParent="true"
|
||||
app:cardCornerRadius="20dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#31afc2">
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="300dp"
|
||||
android:layout_height="400dp"
|
||||
android:layout_height="450dp"
|
||||
android:layout_gravity="center"
|
||||
app:cardCornerRadius="20dp">
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
android:id="@+id/image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="200dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_margin="20dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -32,30 +33,33 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/choose_first"
|
||||
android:layout_width="200dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="50dp"
|
||||
android:text="是"
|
||||
android:textSize="13sp">
|
||||
android:text="测试"
|
||||
android:textSize="13sp"
|
||||
android:visibility="gone">
|
||||
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/choose_second"
|
||||
android:layout_width="200dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="否"
|
||||
android:textSize="13sp">
|
||||
android:text="测试"
|
||||
android:textSize="13sp"
|
||||
android:visibility="gone">
|
||||
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
android:id="@+id/choose_third"
|
||||
android:layout_width="200dp"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="否"
|
||||
android:textSize="13sp">
|
||||
android:text="测试"
|
||||
android:textSize="13sp"
|
||||
android:visibility="gone">
|
||||
|
||||
</Button>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user