I have the following layout:
<GridView
android:id="@+id/gridViewCalendar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:numColumns="7" >
</GridView>
And the following code makes simple ArrayAdapter:
private View initializeCalendarScreen(LayoutInflater inflater) {
View layout=inflater.inflate(R.layout.calendar_layout, null);
GridView events=(GridView)layout.findViewById(R.id.gridViewCalendar);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, items);
events.setAdapter(adapter);
return layout;
}
It works, but text in cells isn’t on the center – it has got default align by left. How can I fix it?
You should create your own layout for the items instead of using android.R.layout.simple_list_item_1
the layout is made this way as seen on the android SKD:
You can simply copy that but put android:gravity=”center” or modify it to suit your needs