-
Notifications
You must be signed in to change notification settings - Fork 28
/
README
30 lines (23 loc) · 811 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Hope its useful to someone, e.g
// gridview xml layout
<GridView
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="7"
android:verticalSpacing="1dp"
android:horizontalSpacing="1dp"
android:gravity="center"
android:background="#DADADA"
/>
// get date
mCalendar = Calendar.getInstance();
mToday[0] = mCalendar.get(Calendar.DAY_OF_MONTH);
mToday[1] = mCalendar.get(Calendar.MONTH); // zero based
mToday[2] = mCalendar.get(Calendar.YEAR);
// get display metrics
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
// set adapter
mGridView = (GridView)findViewById(R.id.gridview);
mGridView.setAdapter(new MonthAdapter(this, mToday[1], mToday[2], metrics);