您的位置:首页 > 移动开发 > Android开发

android 根据生日生成星座

2016-03-31 11:23 411 查看
小菜比,第一次写博客



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



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: