If you think the Android project wally listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright (C) 2014 Freddie (Musenkishi) Lust-Hed
*//www.java2s.com
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/package com.musenkishi.wally.views;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import com.musenkishi.wally.R;
/**
* A Custom GridView where you can set the default width of a cell
* and it will set the numbers of columns accordingly.
* Created by Musenkishi on 2014-03-04 21:08.
*/publicclass AutoGridView extends GridRecyclerView {
privateint defaultCellWidth;
public AutoGridView(Context context) {
super(context);
}
public AutoGridView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
public AutoGridView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context, attrs);
}
privatevoid init(Context context, AttributeSet attrs) {
Resources.Theme theme = context.getTheme();
if (theme != null) {
TypedArray typedArray = theme.obtainStyledAttributes(
attrs,
R.styleable.AutoGridView,
0, 0);
if (typedArray != null) {
try {
defaultCellWidth = (int) typedArray.getDimension(R.styleable.AutoGridView_defaultCellWidth, 0);
} finally {
typedArray.recycle();
}
}
}
}
publicint getDefaultCellWidth(){
return defaultCellWidth;
}
publicvoid setDefaultCellWidth(int width){
this.defaultCellWidth = width;
}
}