Java Code Examples for android.widget.GridView#setBackgroundResource()
The following examples show how to use
android.widget.GridView#setBackgroundResource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BirdGridFragment.java From Moring-Alarm with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mPos == -1 && savedInstanceState != null) mPos = savedInstanceState.getInt("mPos"); TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img); mImgRes = imgs.getResourceId(mPos, -1); GridView gv = (GridView) inflater.inflate(R.layout.list_grid, null); gv.setBackgroundResource(android.R.color.black); gv.setAdapter(new GridAdapter()); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (getActivity() == null) return; ResponsiveUIActivity activity = (ResponsiveUIActivity) getActivity(); activity.onBirdPressed(mPos); } }); return gv; }
Example 2
Source File: BirdGridFragment.java From Moring-Alarm with Apache License 2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (mPos == -1 && savedInstanceState != null) mPos = savedInstanceState.getInt("mPos"); TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img); mImgRes = imgs.getResourceId(mPos, -1); GridView gv = (GridView) inflater.inflate(R.layout.list_grid, null); gv.setBackgroundResource(android.R.color.black); gv.setAdapter(new GridAdapter()); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (getActivity() == null) return; ResponsiveUIActivity activity = (ResponsiveUIActivity) getActivity(); activity.onBirdPressed(mPos); } }); return gv; }
Example 3
Source File: CityManagerActivity.java From CoolWeather with Apache License 2.0 | 5 votes |
private void initView() { mCityManagerEntity = new ArrayList<CityManagerEntity>(); mGrid = (GridView) findViewById(R.id.gridview); mGrid.setNumColumns(3); mGrid.setBackgroundResource(R.drawable.bg_homepager_blur); mGrid.setAdapter(new GridCityMAdapter(this, mCityManagerEntity)); }
Example 4
Source File: FlexibleCalendarView.java From FlexibleCalendar with MIT License | 4 votes |
private void init(AttributeSet attrs) { setAttributes(attrs); setOrientation(VERTICAL); //initialize the default calendar view calendarView = new DefaultCalendarView(); //create week view header weekDisplayView = new GridView(context); weekDisplayView.setLayoutParams( new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, GridView.LayoutParams.WRAP_CONTENT)); weekDisplayView.setNumColumns(7); weekDisplayView.setHorizontalSpacing(weekdayHorizontalSpacing); weekDisplayView.setVerticalSpacing(weekdayVerticalSpacing); weekDisplayView.setColumnWidth(GridView.STRETCH_COLUMN_WIDTH); weekDisplayView.setBackgroundResource(weekViewBackground); weekdayDisplayAdapter = new WeekdayNameDisplayAdapter(getContext(), android.R.layout.simple_list_item_1, startDayOfTheWeek); //setting default week cell view weekdayDisplayAdapter.setCellView(new WeekdayCellViewImpl(calendarView)); weekDisplayView.setAdapter(weekdayDisplayAdapter); this.addView(weekDisplayView); //setup month view monthViewPager = new MonthViewPager(context); monthViewPager.setBackgroundResource(monthViewBackground); monthViewPager.setNumOfRows(showDatesOutsideMonth ? 6 : FlexibleCalendarHelper.getNumOfRowsForTheMonth(displayYear, displayMonth, startDayOfTheWeek)); monthViewPagerAdapter = new MonthViewPagerAdapter(context, displayYear, displayMonth, this, showDatesOutsideMonth, decorateDatesOutsideMonth, startDayOfTheWeek, disableAutoDateSelection); monthViewPagerAdapter.setMonthEventFetcher(this); monthViewPagerAdapter.setSpacing(monthDayHorizontalSpacing, monthDayVerticalSpacing); //set the default cell view monthViewPagerAdapter.setCellViewDrawer(new DateCellViewImpl(calendarView)); monthInfPagerAdapter = new InfinitePagerAdapter(monthViewPagerAdapter); //Initializing with the offset value lastPosition = monthInfPagerAdapter.getRealCount() * 100; monthViewPager.setAdapter(monthInfPagerAdapter); monthViewPager.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f)); monthViewPager.addOnPageChangeListener(new MonthChangeListener()); //initialize with the current selected item selectedDateItem = new SelectedDateItem(displayYear, displayMonth, startDisplayDay); monthViewPagerAdapter.setSelectedItem(selectedDateItem); this.addView(monthViewPager); }