Bạn sẽ phải tạo GridView tùy chỉnh của mình. Nó có thể giống như thế này:
bố trí cho các ngày trong tuần
<GridView
android:id="@+id/weekdays"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:clickable="false"
android:numColumns="7" />
Layout.xml cho những ngày
<GridView
android:id="@+id/days"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:numColumns="7" />
mã java để hiển thị các ngày trong tuần
GridView weekdays = (GridView) linearLayout.findViewById(R.id.weekdays);
weekdays.setAdapter(new Weekdays());
public class WeekDays extends BaseAdapter {
String[] weekdays = null;
public WeekDayAdapter() {
DateFormatSymbols dateFormatSymbols= new DateFormatSymbols();
weekdays = = dateFormatSymbols.getShortWeekdays();
}
public int getCount() {
return 7;
}
public Object getItem(int position) {
return weekdays[position];
}
public long getItemId(int position) {
return GridView.INVALID_ROW_ID;
}
public View getView(int position, View convertView, ViewGroup parent) {
View view = null;
view = new LinearLayout(parent.getContext());
view.setLayoutParams(new GridView.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
view.setOrientation(Horizontal);
LinearLayout linearLayout = new LinearLayout(parent.getContext());
linearLayout.setOrientation(Vertical);
TextView weekDays = new TextView(parent.getContext());
weekDays.setText(weekdays[position + 1]);
linearLayout.addView(weekDays);
view.addView(linearLayout);
return view;
}
}
Bạn có thể làm điều gì đó tương tự để thiết lập các ngày trong tháng. Hãy hỏi bất kỳ câu hỏi nào.
Bạn có câu trả lời không? –
không có tôi không, tôi nghĩ rằng câu hỏi này là tuyệt vọng. –