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 {
|
||||
{"口舌干燥", "口黏苔腻", "还算正常"},
|
||||
{"沉寂易疲劳", "精力充沛"},
|
||||
{"内向", "开朗"},
|
||||
{"烫的", "冷的", "没有特别喜欢的"}
|
||||
{"烫的", "冷的", "没有特别喜欢的"},
|
||||
{"查看"}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user