【发布时间】:2021-07-21 03:56:18
【问题描述】:
应用程序的要求是 DOB(出生日期) 的自定义日历,用户可以在其中从两个微调器中选择月份和年份,并从日历视图中选择最终日期。 例如:-
First Spinner:- 月份:- 六月
第二次旋转:- 年份:- 1990
自定义日历视图:- 日期:- 23
Textview 中的最终输出:- 1990 年 6 月 23 日
我知道在微调器中设置月份和年份,这是代码,但无法连接日历中的月份和年份。请帮忙
// Set years
ArrayList<String> years = new ArrayList<String>();
int thisYear = Calendar.getInstance().get(Calendar.YEAR);
for (int i = 1900; i <= thisYear; i++) {
years.add(Integer.toString(i));
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, years);
Spinner spinYear = (Spinner)findViewById(R.id.spinnerYears);
spinYear.setAdapter(adapter);
// Set months
ArrayAdapter<String> adapterMonths = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, Months);
adapterMonths.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Spinner spinMonths = (Spinner)findViewById(R.id.spinnerMonths);
spinMonths.setAdapter(adapterMonths);
我附上了一张图片,请找到我的附件。我想要与图片中所示完全相同的 UI。
【问题讨论】:
-
谁能帮帮我?任何人...
标签: android android-spinner android-calendar