android 根据生日生成星座

private String[][] constellations = {{"摩羯座", "水瓶座"}, {"水瓶座", "双鱼座"}, {"双鱼座", "白羊座"}, {"白羊座", "金牛座"}, {"金牛座", "双子座"}, {"双子座", "巨蟹座"}, {"巨蟹座", "狮子座"},
        {"狮子座", "处女座"}, {"处女座", "天秤座"}, {"天秤座", "天蝎座"}, {"天蝎座", "射手座"}, {"射手座", "摩羯座"}};
//星座分割时间
private int[] date = {20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22};
/**
 * 星座生成 传进是日期格式为: yyyy-mm-dd
 *
 * @param time
 */
private void getConstellations(String time) {
    String[] data = time.split("-");
    int day = date[Integer.parseInt(data[1]) - 1];
    String[] cl1 = constellations[Integer.parseInt(data[1]) - 1];
    if (Integer.parseInt(data[2]) >= day) {
        constellationTv.setText(cl1[1]);
    } else {
        constellationTv.setText(cl1[0]);
    }
}

阅读更多

没有更多推荐了,返回首页