根据生肖选择年份控件
来源:互联网 发布:js sort函数 编辑:程序博客网 时间:2024/03/29 06:47
package com.**.mobile.common;import android.app.AlertDialog;import android.content.Context;import android.content.DialogInterface;import android.graphics.Color;import android.view.View;import android.widget.Button;import android.widget.EditText;import android.widget.TableLayout;import android.widget.TableRow;import android.widget.TextView;public class ShengXiao {private Context context = null;private TextView current = null;private Button helpbutton = null;private EditText yeartext = null;public ShengXiao(Context context, Button helpbutton, EditText yeartext) {this.context = context;this.helpbutton = helpbutton;this.yeartext = yeartext;}public void append() {helpbutton.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {current = new TextView(context);String[] items = new String[] {"子鼠: 2008 1996 1984 1972 1960 1948 1936 1924 1912","丑牛: 2009 1997 1985 1973 1961 1949 1937 1925 1913","寅虎: 2010 1998 1986 1974 1962 1950 1938 1926 1914","卯兔: 2011 1999 1987 1975 1963 1951 1939 1927 1915","辰龙: 2012 2000 1988 1976 1964 1952 1940 1928 1916","巳蛇: 2013 2001 1989 1977 1965 1953 1941 1929 1917","午马: 2002 1990 1978 1966 1954 1942 1930 1918","未羊: 2003 1991 1979 1967 1955 1943 1931 1919","申猴: 2004 1992 1980 1968 1956 1944 1932 1920","酉鸡: 2005 1993 1981 1969 1957 1945 1933 1921","戌狗: 2006 1994 1982 1970 1958 1946 1934 1922","亥猪: 2007 1995 1983 1971 1959 1947 1935 1923 1911", };TableLayout table = new TableLayout(context);for (int i = 0; i < items.length; i++) {TableRow row = new TableRow(context);if (i % 2 == 1) {row.setBackgroundColor(Color.GRAY);}String[] years = items[i].split(" ");for (int j = 0; j < years.length; j++) {final TextView text = new TextView(context);text.setText(years[j] + " ");text.setTextSize(20);text.setTextColor(Color.WHITE);if (j != 0) {text.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {current.setTextColor(Color.WHITE);text.setTextColor(Color.argb(255, 75, 204,255));String year = ((String) text.getText()).substring(0, 4);text.setText(year);current = text;}});}row.addView(text);}table.addView(row);}AlertDialog.Builder builder = new AlertDialog.Builder(context);builder.setTitle("根据生肖查询出生年份").setView(table).setPositiveButton("确定",new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {String currentText = current.getText().toString();if(!"".equals(currentText)&& currentText!=null)yeartext.setText(currentText);}}).setNegativeButton("取消", null).create().show();}});}}
点击查询按钮,弹出生肖控件,选择年份按确定,年份添加到文本框中
- 根据生肖选择年份控件
- oracle 根据出生年份计算生肖
- Java根据年份算出所属的生肖。
- android小程序,根据生日年份计算出生肖
- iOS开发小案例之根据年份判断生肖
- JS编写选择年份控件
- 根据用户给出的年份求天干、地支和生肖(Java源代码)
- 获取某个年份的生肖
- 生肖和年份之间的推算公式
- 12生肖年份和星座组合图
- 选择年份
- My97 datepicker 日期控件添加时间自动选择 年龄,生肖,星座
- 根据年份输出日历
- 生肖、天干地支年份、星座简便判断方法(VB)
- 输入一个年份,输出框就能显示这一年是什么生肖
- combobox年份选择
- asp根据出生时间判断生肖
- 根据身份证号获取星座,生肖,性别
- C++ 程序设计模板Template
- (译)在cocos2d里面如何使用物理引擎box2d:弹球
- 通过show status 来优化MySQL数据库
- 杭电1018 阶乘位数
- jquery 结构
- 根据生肖选择年份控件
- linux网络编程多进程并发服务器
- PPT放映期间如何插入音频
- MyEclipse官方下载地址
- oracle order by排序总结
- 域名解析和CDN 原理
- [教程] 【转】Android 通过软引用实现图片缓存,防止内存溢出 [复制链接]
- 给年轻程序员的建议
- SQL注入漏洞全接触--入门篇