本文整理匯總了Java中android.widget.GridLayout.setColumnCount方法的典型用法代碼示例。如果您正苦於以下問題:Java GridLayout.setColumnCount方法的具體用法?Java GridLayout.setColumnCount怎麽用?Java GridLayout.setColumnCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.GridLayout
的用法示例。
在下文中一共展示了GridLayout.setColumnCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addStripes
import android.widget.GridLayout; //導入方法依賴的package包/類
private void addStripes() {
GridLayout gridLayout=new GridLayout(this);
RelativeLayout.LayoutParams gl=new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
gridLayout.setColumnCount(gridColumnCount);
gridLayout.setLayoutParams(gl);
parentLayout.addView(gridLayout);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(deviceWidth/2,deviceHeight/3);
Log.i(Tag,"addStripes called");
for (int i = 0; i < stripeCount; i++) {
stripe[i] = new Stripes(this,i);
stripe[i].setLayoutParams(layoutParams);
gridLayout.addView(stripe[i]);
}
addColors();
}
示例2: createMainSectionContent
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
Context context = mainSectionLayout.getContext();
// Add a label that will be used to indicate that the total cart price has been updated.
addUpdateText(mainSectionLayout);
// The breakdown is represented by an end-aligned GridLayout that takes up only as much
// space as it needs. The GridLayout ensures a consistent margin between the columns.
mBreakdownLayout = new GridLayout(context);
mBreakdownLayout.setColumnCount(2);
LayoutParams breakdownParams =
new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
breakdownParams.gravity = Gravity.END;
mainSectionLayout.addView(mBreakdownLayout, breakdownParams);
}
示例3: onResume
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
protected void onResume() {
super.onResume();
GridLayout sortArea = (GridLayout) findViewById(R.id.sort_area);
if (isLandscape()) {
numcolumns = 6;
} else {
numcolumns = 3;
}
sortArea.setColumnCount(numcolumns);
//override super class
LinearLayout centercol = (LinearLayout) findViewById(R.id.centercol);
centercol.setOrientation(LinearLayout.VERTICAL);
findViewById(R.id.score_total_correct_area).setVisibility(View.GONE);
findViewById(R.id.score_level_percent_area).setVisibility(View.GONE);
}
示例4: onCreateDialog
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
mRootView = (ViewGroup) layoutInflater.inflate(R.layout.dialog_colors, null);
mAlphaSeekBar = (SeekBar) mRootView.findViewById(android.R.id.progress);
mAlphaSeekBar.setOnSeekBarChangeListener(alphaSeekListener);
mAlphaSeekBar.setMax(255);
mAlphaSeekBar.setProgress(getValueAlpha(false));
mColorGrid = (GridLayout) mRootView.findViewById(R.id.color_grid);
mColorGrid.setColumnCount(mPreference.mNumColumns);
repopulateItems();
return new AlertDialog.Builder(getActivity())
.setView(mRootView)
.setNegativeButton(android.R.string.cancel, clickListener)
.setPositiveButton(android.R.string.ok, clickListener)
.create();
}
示例5: init
import android.widget.GridLayout; //導入方法依賴的package包/類
private void init() {
LayoutInflater.from(getContext()).inflate(R.layout.layout_condition_grid, this);
mTvTitle = (TextView) findViewById(R.id.tv_title_condition_grid);
mGrid = (GridLayout) findViewById(R.id.grid_condition_grid);
mGrid.setColumnCount(columnCount);
mLayout = (LinearLayout) findViewById(R.id.grid_condition_custom_view);
mGrid.addOnLayoutChangeListener(this);
}
示例6: onCreate
import android.widget.GridLayout; //導入方法依賴的package包/類
/**
* @param savedInstanceState
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
estado = Estado.NAO_VIRADA;
grid = (GridLayout) findViewById(R.id.grid);
grid.setColumnCount(4);
final int NUMBER_OF_CARDS = this.resources.length * 2;
cards = new ArrayList<>(NUMBER_OF_CARDS);
for (int i = 0; i < NUMBER_OF_CARDS; i++) {
ImageButton btn = new ImageButton(this);
btn.setImageResource(R.mipmap.ic_costas);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(150, 150);
btn.setLayoutParams(layoutParams);
btn.setOnClickListener(this);
btn.setTag(new CardInfo(resources[i % 8]));
cards.add(btn);
}
Collections.shuffle(cards);
for(ImageButton button : this.cards ){
grid.addView(button);
}
}
示例7: onCreateDialog
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
View rootView = layoutInflater.inflate(R.layout.dialog_colors, null);
mColorGrid = (GridLayout) rootView.findViewById(R.id.color_grid);
mColorGrid.setColumnCount(mPreference.mNumColumns);
repopulateItems();
return new AlertDialog.Builder(getActivity())
.setView(rootView)
.create();
}
示例8: onCreate
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animations);
// Grayscale filter used on all thumbnails
ColorMatrix grayMatrix = new ColorMatrix();
grayMatrix.setSaturation(0);
ColorMatrixColorFilter grayscaleFilter = new ColorMatrixColorFilter(grayMatrix);
mGridLayout = (GridLayout) findViewById(R.id.gridLayout);
mGridLayout.setColumnCount(3);
mGridLayout.setUseDefaultMargins(true);
// add all photo thumbnails to layout
Resources resources = getResources();
ArrayList<PictureData> pictures = mBitmapUtils.loadPhotos(resources);
for (int i = 0; i < pictures.size(); ++i) {
PictureData pictureData = pictures.get(i);
BitmapDrawable thumbnailDrawable =
new BitmapDrawable(resources, pictureData.thumbnail);
thumbnailDrawable.setColorFilter(grayscaleFilter);
ImageView imageView = new ImageView(this);
imageView.setOnClickListener(thumbnailClickListener);
imageView.setImageDrawable(thumbnailDrawable);
mPicturesData.put(imageView, pictureData);
mGridLayout.addView(imageView);
}
}
示例9: createIconSheet
import android.widget.GridLayout; //導入方法依賴的package包/類
@NonNull
private GridLayout createIconSheet(String category) {
final GridLayout iconSheet = new GridLayout(MainActivity.this);
mIconSheets.put(category, iconSheet);
mRevCategoryMap.put(iconSheet, category);
iconSheet.setColumnCount(mColumns);
iconSheet.setOnDragListener(mMainDragListener);
final TextView categoryTab = createCategoryTab(category, iconSheet);
mCategoryTabs.put(category, categoryTab);
mRevCategoryMap.put(categoryTab, category);
return iconSheet;
}
示例10: setColumnCount
import android.widget.GridLayout; //導入方法依賴的package包/類
private void setColumnCount(GridLayout answerarea, int count) {
List<View> kids = new ArrayList<>();
for(int i = 0; i< answerarea.getChildCount(); i++) {
kids.add(answerarea.getChildAt(i));
}
answerarea.removeAllViews();
answerarea.setColumnCount(count);
for (View k: kids) {
k.setLayoutParams(new GridLayout.LayoutParams());
answerarea.addView(k);
}
}
示例11: showUserData
import android.widget.GridLayout; //導入方法依賴的package包/類
private void showUserData(ViewGroup list, String username) {
UserData user = mAppdata.getUser(username);
TextView uname = new TextView(this);
String avname = user.getAvatar() + " " + user.getUsername() + ": " + user.getTotalPoints();
uname.setPadding(0, 23, 0, 2);
uname.setText(avname);
uname.setTextSize(24);
list.addView(uname);
GridLayout userlayout = new GridLayout(this);
//userlayout.setOrientation(GridLayout.VERTICAL);
userlayout.setColumnCount(2);
userlayout.setPadding(24, 8, 4, 16);
list.addView(userlayout);
for (String sub : user.getSubjectsStarted()) {
UserData.Subject subject = user.getSubjectForUser(sub);
addTextView(userlayout, sub + " (" + subjects.get(sub).getName() + "): ", 20, 0);
addTextView(userlayout, subject.getTotalPoints() + "");
Map<String, Integer> thist = subject.getTodayPointHistory();
for (String day : AppData.sort(thist.keySet())) {
addTextView(userlayout, day, 18, 32);
addTextView(userlayout, thist.get(day) + "");
}
}
}
示例12: onCreateDialog
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
View rootView = layoutInflater.inflate(R.layout.dialog_colors, null);
colorGrid = (GridLayout) rootView.findViewById(R.id.color_grid);
colorGrid.setColumnCount(numColumns);
repopulateItems();
return new AlertDialog.Builder(getActivity())
.setView(rootView)
.create();
}
示例13: onCreate
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_animator);
viewGroup = (ViewGroup) findViewById(R.id.id_container);
mAppear = (CheckBox) findViewById(R.id.id_appear);
mChangeAppear = (CheckBox) findViewById(R.id.id_change_appear);
mDisAppear = (CheckBox) findViewById(R.id.id_disappear);
mChangeDisAppear = (CheckBox) findViewById(R.id.id_change_disappear);
mAppear.setOnCheckedChangeListener(this);
mChangeAppear.setOnCheckedChangeListener(this);
mDisAppear.setOnCheckedChangeListener(this);
mChangeDisAppear.setOnCheckedChangeListener(this);
// 創建一個GridLayout
mGridLayout = new GridLayout(this);
// 設置每列5個按鈕
mGridLayout.setColumnCount(5);
// 添加到布局中
viewGroup.addView(mGridLayout);
// 默認動畫全部開啟
mTransition = new LayoutTransition();
mTransition.setAnimator(LayoutTransition.APPEARING, (mAppear
.isChecked() ? ObjectAnimator.ofFloat(this, "scaleX", 0, 1)
: null));
mGridLayout.setLayoutTransition(mTransition);
}
示例14: onCreate
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GridLayout layout = new GridLayout(this);
ScrollView scroll = new ScrollView(this);
scroll.addView(layout);
setContentView(scroll);
try {
String [] list = getAssets().list("images");
// count tga images
int count = 0;
for(int i=0; i<list.length; i++) {
if(list[i].endsWith(".tga")) count++;
}
layout.setColumnCount(3);
layout.setRowCount(count/3);
// create tga image view
for(int i=0; i<list.length; i++) {
if(list[i].endsWith(".tga")) {
LinearLayout view = createTGAView(list[i]);
if(view != null) layout.addView(view);
}
}
}
catch (IOException e) {
e.printStackTrace();
}
}
示例15: onCreateView
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
int index = getArguments().getInt("INDEX");
View v = inflater.inflate(R.layout.view_matrix_frag, container, false);
CardView cardView = (CardView) v.findViewById(R.id.DynamicCardView);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
String string = sharedPreferences.getString("ELEVATE_AMOUNT", "4");
String string2 = sharedPreferences.getString("CARD_CHANGE_KEY", "#bdbdbd");
cardView.setCardElevation(Integer.parseInt(string));
cardView.setCardBackgroundColor(Color.parseColor(string2));
CardView.LayoutParams params1 = new CardView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
GridLayout gridLayout = new GridLayout(getContext());
gridLayout.setRowCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow());
gridLayout.setColumnCount(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol());
for (int i = 0; i < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(); i++) {
for (int j = 0; j < ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(); j++) {
TextView textView = new TextView(getContext());
textView.setGravity(Gravity.CENTER);
textView.setText(SafeSubString(GetText(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetElementof(i, j)), getLength()));
textView.setWidth(CalculatedWidth(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol()));
textView.setTextSize(SizeReturner(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow(), ((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetCol(),
PreferenceManager.getDefaultSharedPreferences(getContext()).
getBoolean("EXTRA_SMALL_FONT", false)));
textView.setHeight(CalculatedHeight(((GlobalValues) getActivity().getApplication()).GetCompleteList().get(index).GetRow()));
GridLayout.Spec Row = GridLayout.spec(i, 1);
GridLayout.Spec Col = GridLayout.spec(j, 1);
GridLayout.LayoutParams params = new GridLayout.LayoutParams(Row, Col);
gridLayout.addView(textView, params);
}
}
gridLayout.setLayoutParams(params1);
cardView.addView(gridLayout);
// Inflate the layout for this fragment
return v;
}