Java Code Examples for android.widget.GridView#setColumnWidth()
The following examples show how to use
android.widget.GridView#setColumnWidth() .
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: PXGridStyler.java From pixate-freestyle-android with Apache License 2.0 | 6 votes |
@Override public void applyStylesWithContext(PXStylerContext stylerContext) { GridStyle style = stylerContext.getGridStyle(); if (style != null) { GridView view = (GridView) stylerContext.getStyleable(); if (style.columnCount != Integer.MIN_VALUE) { view.setNumColumns(style.columnCount); } if (style.columnWidth != Integer.MIN_VALUE) { view.setColumnWidth(style.columnWidth); } if (style.columnGap != Integer.MIN_VALUE) { view.setHorizontalSpacing(style.columnGap); } if (style.rowGap != Integer.MIN_VALUE) { view.setVerticalSpacing(style.rowGap); } if (style.columnStretchMode != Integer.MIN_VALUE) { view.setStretchMode(style.columnStretchMode); } } super.applyStylesWithContext(stylerContext); }
Example 2
Source File: SubRecommendedFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sub_recommended, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_sub_recommended_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); ViewGroup parent = (ViewGroup) view.getParent(); if (parent != null) { parent.removeView(view); } sub_recommendedNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.sub_recommended_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_sub_recommended_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { sub_recommendedNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { sub_recommendedNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 3
Source File: EmojiKeyboardView.java From Game-of-Thrones with Apache License 2.0 | 5 votes |
private GridView createGridPage(ViewGroup container, int position1, BaseAdapter adapter, int columnSizeResId) { int columnWidth = getContext().getResources().getDimensionPixelSize(columnSizeResId); GridView view = (GridView) viewFactory.inflate(R.layout.keyboard_page_emoji, container, false); view.setColumnWidth(columnWidth); view.setAdapter(adapter); container.addView(view); view.setTag(position1); return view; }
Example 4
Source File: CollectionLibraryFragment.java From Mizuu with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); mProgressBar = (ProgressBar) v.findViewById(R.id.progress); if (mMovieKeys.size() > 0) mProgressBar.setVisibility(View.GONE); mAdapter = new LoaderAdapter(getActivity()); mGridView = (GridView) v.findViewById(R.id.gridView); mGridView.setAdapter(mAdapter); mGridView.setColumnWidth(mImageThumbSize); // Calculate the total column width to set item heights by factor 1.5 mGridView.getViewTreeObserver().addOnGlobalLayoutListener( new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (mAdapter.getNumColumns() == 0) { final int numColumns = (int) Math.floor(mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing)); if (numColumns > 0) { mAdapter.setNumColumns(numColumns); mResizedWidth = (int) (((mGridView.getWidth() - (numColumns * mImageThumbSpacing)) / numColumns) * 1.1); // * 1.1 is a hack to make images look slightly less blurry mResizedHeight = (int) (mResizedWidth * 1.5); } MizLib.removeViewTreeObserver(mGridView.getViewTreeObserver(), this); } } }); mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { showDetails(arg2); } }); }
Example 5
Source File: TransferFriendPresenter.java From Android with MIT License | 5 votes |
@Override public void horizontal_layout(GridView gridView) { int spacingH = SystemUtil.dipToPx(10); int itemWidth = SystemUtil.dipToPx(45); int size = list.size() + 1; int allWidth = ((spacingH + itemWidth) * size); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( allWidth, LinearLayout.LayoutParams.FILL_PARENT); gridView.setLayoutParams(params); gridView.setColumnWidth(itemWidth); gridView.setHorizontalSpacing(spacingH); gridView.setStretchMode(GridView.NO_STRETCH); gridView.setNumColumns(size); }
Example 6
Source File: LatestFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_latest, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_latest_view); MainActivity activity = (MainActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); latestNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.latest_netWork_relativeLayout); latestGridView = (GridView) view.findViewById(R.id.fragment_latest_gridview); latestGridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); latestGridView.setColumnWidth((int) width); latestGridView.setOnItemClickListener(this); if(this.mShowNoNetworkView){ latestNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); }else{ latestNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 7
Source File: RecommendedFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_recommended, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_recommended_view); MainActivity activity = (MainActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); mPhotoWall = (GridView) view.findViewById(R.id.fragment_recommended_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); recommendedNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.recommended_netWork_relativeLayout); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { recommendedNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { recommendedNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 8
Source File: HottestFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_hottest, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_hottest_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); ViewGroup parent = (ViewGroup) view.getParent(); if (parent != null) { parent.removeView(view); } hottestNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.hottest_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_hottest_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { hottestNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { hottestNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 9
Source File: MediaPagerAdapter.java From ChatKeyboard with Apache License 2.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { LayoutInflater inflater = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.keyboard_media_page, container, false); GridView grid = (GridView) layout.findViewById(R.id.media_grid); grid.setColumnWidth(mColumnWidth); grid.setAdapter(gridAdapterList.get(position)); container.addView(layout); return layout; }
Example 10
Source File: SubLatestFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sub_latest, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_sub_latest_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); subLatestNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.sub_latest_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_sub_latest_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { subLatestNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { subLatestNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 11
Source File: SubRecommendedFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sub_recommended, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_sub_recommended_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); ViewGroup parent = (ViewGroup) view.getParent(); if (parent != null) { parent.removeView(view); } sub_recommendedNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.sub_recommended_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_sub_recommended_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { sub_recommendedNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { sub_recommendedNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 12
Source File: GridViewFragment.java From AndroidStarterKit with MIT License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_gridview_main, null); final int colSize = 3; final int columnWidth = getScreenWidth() / colSize; GridView gridView = (GridView) view.findViewById(R.id.grid_view); gridView.setNumColumns(colSize); gridView.setColumnWidth(columnWidth); gridView.setAdapter(new GridViewAdapter(getActivity(), platforms, columnWidth)); return view; }
Example 13
Source File: TypeContentIndexPageAdapter.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
private View getLinkView(int position, View convertView) { if (convertView == null) { convertView = View.inflate(context, R.layout.item_home_link, null); } GridView gridView = ViewHolder.get(convertView, R.id.gridView); gridView.setNumColumns(3); gridView.setColumnWidth(screenWidth / 3); gridView.setAdapter(new LinkAdapter(context, (ArrayList<HomeConfigItem>) getItem(position))); return convertView; }
Example 14
Source File: SearchListActivity.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_searchlist); shuosou_to_tv = (TextView) findViewById(R.id.shuosou_to_tv); isFromRefreshData = true; recommendedGroups = new ArrayList<Group>(); mPullToRefreshView = (PullToRefreshView) findViewById(R.id.main_pull_refresh_view); mPullToRefreshView.setOnHeaderRefreshListener(this); mPullToRefreshView.setOnFooterRefreshListener(this); searchDetailRelativeLayout = (RelativeLayout) findViewById(R.id.searchdetail_relativeLayout); mPhotoWall = (GridView) findViewById(R.id.photo_wall); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); int status = NetworkStatus.networkStatus(); if (status == NetworkStatus.NETWORK_STATUS_REACHABLE) { this.showNoNetworkView(false); } else if (status == NetworkStatus.NETWORK_STATUS_NOTREACHABLE) { this.showNoNetworkView(true); } mPhotoWall.setOnItemClickListener(this); }
Example 15
Source File: EmojiView.java From Yahala-Messenger with MIT License | 4 votes |
private void init() { setOrientation(LinearLayout.VERTICAL); for (int i = 0; i < Emoji.data.length; i++) { GridView gridView = new GridView(getContext()); gridView.setColumnWidth(OSUtilities.dpf(45.0f)); gridView.setNumColumns(-1); views.add(gridView); EmojiGridAdapter localEmojiGridAdapter = new EmojiGridAdapter(Emoji.data[i]); gridView.setAdapter(localEmojiGridAdapter); adapters.add(localEmojiGridAdapter); } setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{-14145496, -16777216})); pager = new ViewPager(getContext()); pager.setAdapter(new EmojiPagesAdapter()); PagerSlidingTabStripEmoji tabs = new PagerSlidingTabStripEmoji(getContext()); tabs.setViewPager(pager); tabs.setShouldExpand(true); tabs.setIndicatorColor(0xff33b5e5); tabs.setIndicatorHeight(OSUtilities.dpf(2.0f)); tabs.setUnderlineHeight(OSUtilities.dpf(2.0f)); tabs.setUnderlineColor(1711276032); tabs.setTabBackground(0); LinearLayout localLinearLayout = new LinearLayout(getContext()); localLinearLayout.setOrientation(LinearLayout.HORIZONTAL); localLinearLayout.addView(tabs, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f)); ImageView localImageView = new ImageView(getContext()); localImageView.setImageResource(R.drawable.ic_emoji_backspace); localImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); localImageView.setBackgroundResource(R.drawable.bg_emoji_bs); localImageView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (EmojiView.this.listener != null) { EmojiView.this.listener.onBackspace(); } } }); localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(OSUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT)); recentsWrap = new FrameLayout(getContext()); recentsWrap.addView(views.get(0)); TextView localTextView = new TextView(getContext()); localTextView.setText(LocaleController.getString("NoRecent", R.string.NoRecent)); localTextView.setTextSize(18.0f); localTextView.setTextColor(-7829368); localTextView.setGravity(17); recentsWrap.addView(localTextView); views.get(0).setEmptyView(localTextView); addView(localLinearLayout, new LinearLayout.LayoutParams(-1, OSUtilities.dpf(48.0f))); addView(pager); loadRecents(); if (Emoji.data[0] == null || Emoji.data[0].length == 0) { pager.setCurrentItem(1); } }
Example 16
Source File: GridViewStyler.java From dynamico with Apache License 2.0 | 4 votes |
@Override public View style(View view, JSONObject attributes) throws Exception { super.style(view, attributes); GridView gridView = (GridView) view; if(attributes.has("numColumns")) { gridView.setNumColumns(attributes.getInt("numColumns")); } if(attributes.has("selection")) { gridView.setSelection(attributes.getInt("selection")); } if(attributes.has("horizontalSpacing")) { gridView.setHorizontalSpacing(Display.unitToPx(attributes.getString("horizontalSpacing"), context)); } if(attributes.has("verticalSpacing")) { gridView.setVerticalSpacing(Display.unitToPx(attributes.getString("verticalSpacing"), context)); } if(attributes.has("columnWidth")) { gridView.setColumnWidth(Display.unitToPx(attributes.getString("columnWidth"), context)); } if(attributes.has("stretchMode")) { String mode = attributes.getString("stretchMode"); if(mode.equalsIgnoreCase("no_stretch")) { gridView.setStretchMode(NO_STRETCH); }else if(mode.equalsIgnoreCase("stretch_spacing")) { gridView.setStretchMode(STRETCH_SPACING); }else if(mode.equalsIgnoreCase("stretch_column_width")) { gridView.setStretchMode(STRETCH_COLUMN_WIDTH); }else if(mode.equalsIgnoreCase("stretch_spacing_uniform")) { gridView.setStretchMode(STRETCH_SPACING_UNIFORM); } } if(attributes.has("gravity")) { String gravity = attributes.getString("gravity"); if(gravity.equalsIgnoreCase("start")) { gridView.setGravity(Gravity.START); }else if(gravity.equalsIgnoreCase("top")) { gridView.setGravity(Gravity.TOP); }else if(gravity.equalsIgnoreCase("end")) { gridView.setGravity(Gravity.END); }else if(gravity.equalsIgnoreCase("bottom")) { gridView.setGravity(Gravity.BOTTOM); }else if(gravity.equalsIgnoreCase("center")) { gridView.setGravity(Gravity.CENTER); }else if(gravity.equalsIgnoreCase("center_horizontal")) { gridView.setGravity(Gravity.CENTER_HORIZONTAL); }else if(gravity.equalsIgnoreCase("center_vertical")) { gridView.setGravity(Gravity.CENTER_VERTICAL); } } return gridView; }
Example 17
Source File: CollectionGridAdapter.java From DistroHopper with GNU General Public License v3.0 | 4 votes |
@Override public View getView (int position, View view, ViewGroup parent) { LensSearchResultCollection coll = this.getItem (position); boolean show = true; if (view == null) view = LayoutInflater.from (this.getContext ()).inflate (R.layout.widget_dash_lens_result_collection, parent, false); TextView tvLabel = (TextView) view.findViewById (R.id.tvLabel); GridView gvResults = (GridView) view.findViewById (R.id.gvResults); gvResults.setColumnWidth(Math.round((80 // 80 is the minimum + this.dashIconWidth) * this.displayDensity)); // Adjust for the screen's pixel density tvLabel.setText (coll.getLens ().getName ()); tvLabel.setTextColor (view.getResources ().getColor (HomeActivity.theme.dash_applauncher_text_colour)); tvLabel.setShadowLayer (5, 2, 2, view.getResources ().getColor (HomeActivity.theme.dash_applauncher_text_shadow_colour)); List<LensSearchResult> results = coll.getResults (); if (results == null) { results = new ArrayList<LensSearchResult> (); Exception ex = coll.getException (); if (ex != null) { if (ex instanceof UnknownHostException || ex instanceof SocketException) { ConnectivityManager connectivityManager = (ConnectivityManager) this.getContext ().getSystemService (Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo (); if (! (networkInfo != null && networkInfo.isConnected ())) show = false; } LensSearchResult error = new LensSearchResult (this.getContext (), ex.getClass ().getSimpleName (), "error://" + ex.getMessage (), this.getContext ().getResources ().getDrawable (R.drawable.dash_search_lens_error)); results.add (error); } } if (show) { gvResults.setAdapter (new GridAdapter (this.getContext (), results, this.displayDensity, this.dashIconWidth)); gvResults.setOnItemClickListener (new LensSearchResultClickListener (coll.getLens ())); gvResults.setOnItemLongClickListener (new LensSearchResultLongClickListener (coll.getLens ())); view.setVisibility (View.VISIBLE); } else { view.setVisibility (View.GONE); } view.setTag (coll); return view; }
Example 18
Source File: TypeContentIndexPageAdapter.java From BigApp_Discuz_Android with Apache License 2.0 | 3 votes |
private View getPlateView(int position, View convertView) { if (convertView == null) { convertView = inflater.inflate(R.layout.item_home_plate, null); } GridView gridView = ViewHolder.get(convertView, R.id.gridView); gridView.setNumColumns(2); gridView.setColumnWidth(screenWidth / 2); gridView.setAdapter(new PlateAdapter(context, (ArrayList<HomeConfigItem>) getItem(position))); return convertView; }
Example 19
Source File: IndexPageAdapter.java From BigApp_Discuz_Android with Apache License 2.0 | 3 votes |
private View getPlateView(int position, View convertView) { if (convertView == null) { convertView = inflater.inflate(R.layout.item_home_plate, null); } GridView gridView = ViewHolder.get(convertView, R.id.gridView); gridView.setNumColumns(2); gridView.setColumnWidth(screenWidth / 2); gridView.setAdapter(new PlateAdapter(context, homeConfigJson.getVariables().getMyHome().getFunc().getPlate())); return convertView; }
Example 20
Source File: TypeRecommendIndexPageAdapter.java From BigApp_Discuz_Android with Apache License 2.0 | 3 votes |
private View getPlateView(int position, View convertView) { if (convertView == null) { convertView = inflater.inflate(R.layout.item_home_plate, null); } GridView gridView = ViewHolder.get(convertView, R.id.gridView); gridView.setNumColumns(2); gridView.setColumnWidth(screenWidth / 2); gridView.setAdapter(new PlateAdapter(context, (ArrayList<HomeConfigItem>) getItem(position))); return convertView; }