本文整理匯總了Java中android.widget.GridLayout類的典型用法代碼示例。如果您正苦於以下問題:Java GridLayout類的具體用法?Java GridLayout怎麽用?Java GridLayout使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GridLayout類屬於android.widget包,在下文中一共展示了GridLayout類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createOptionIcon
import android.widget.GridLayout; //導入依賴的package包/類
private View createOptionIcon(GridLayout parent, int rowIndex, boolean editIconExists) {
// The icon has a pre-defined width.
ImageView optionIcon = new ImageView(parent.getContext());
optionIcon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
optionIcon.setBackgroundResource(R.drawable.payments_ui_logo_bg);
optionIcon.setImageDrawable(mOption.getDrawableIcon());
optionIcon.setMaxWidth(mIconMaxWidth);
// Place option icon at column three if no edit icon.
int columnStart = editIconExists ? 2 : 3;
GridLayout.LayoutParams iconParams = new GridLayout.LayoutParams(
GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
GridLayout.spec(columnStart, 1));
iconParams.topMargin = mVerticalMargin;
parent.addView(optionIcon, iconParams);
optionIcon.setOnClickListener(OptionSection.this);
return optionIcon;
}
示例2: 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();
}
示例3: 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);
}
示例4: repopulate
import android.widget.GridLayout; //導入依賴的package包/類
public void repopulate() {
final List<ComponentName> quickRowOrder = db().getAppCategoryOrder(QUICK_ROW_CAT);
mQuickRow.postDelayed(new Runnable() {
@Override
public void run() {
mQuickRow.removeAllViews();
for (ComponentName actvname : quickRowOrder) {
AppLauncher app = db().getApp(actvname);
if (!appAlreadyHere(app)) {
ViewGroup item = mMainActivity.getLauncherView(app, true);
if (item != null) {
GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
lp.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, GridLayout.TOP);
mQuickRow.addView(item, lp);
}
}
}
}
}, 400);
}
示例5: makeColorPresetButton
import android.widget.GridLayout; //導入依賴的package包/類
private void makeColorPresetButton(int color) {
FrameLayout outframe = new FrameLayout(getContext());
outframe.setBackgroundColor(Color.BLACK);
outframe.setPadding(6,6,6,6);
FrameLayout frame = new FrameLayout(getContext());
//frame.setBackgroundColor(Color.BLACK);
frame.setBackgroundResource(R.drawable.transparentgrid);
TextView c = new TextView(getContext());
c.setText(" ");
c.setTextSize(22);
c.setBackgroundColor(color);
// if (color==Color.TRANSPARENT) {
// c.setBackgroundResource(R.drawable.transparentgrid);
// }
c.setTag(color);
c.setClickable(true);
c.setOnClickListener(setColorListener);
frame.addView(c);
GridLayout.LayoutParams lp = new GridLayout.LayoutParams();
lp.setMargins(24, 16, 24, 16);
outframe.setPadding(6,6,6,6);
outframe.addView(frame);
colorPresets.addView(outframe, lp);
}
示例6: onCreate
import android.widget.GridLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chain_explorer);
blocksList = findViewById(R.id.blocks_list);
// Create a progress bar to display while the list loads
ProgressBar progressBar = new ProgressBar(this);
progressBar.setLayoutParams(new LinearLayout.LayoutParams(GridLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT, CENTER));
progressBar.setIndeterminate(true);
blocksList.setEmptyView(progressBar);
// Must add the progress bar to the root of the layout
ViewGroup root = findViewById(android.R.id.content);
root.addView(progressBar);
init();
}
示例7: ColorGridView
import android.widget.GridLayout; //導入依賴的package包/類
public ColorGridView(@NonNull final Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
setWillNotDraw(false);
setRowCount(ROWS);
setColumnCount(COLS);
for (int row = 0; row < ROWS; row++) {
Spec rowSpec = spec(row);
for (int col = 0; col < COLS; col++) {
Spec colSpec = spec(col);
LayoutParams params = new GridLayout.LayoutParams(rowSpec, colSpec);
params.width = 150;
params.height = 150;
View view = createView(context);
addView(view, params);
}
}
}
示例8: ServerSettingsClass
import android.widget.GridLayout; //導入依賴的package包/類
public ServerSettingsClass(Activity activity, String TAG, MainActivity.ServiceControl serviceControl, int extendingSpeed) {
this.TAG = TAG;
this.activity = activity;
this.extendingSpeed = extendingSpeed;
this.serviceControl = serviceControl;
settingsInner = (GridLayout) activity.findViewById(R.id.serverSettingsInner);
settingsHead1 = (TextView) activity.findViewById(R.id.serverSettingsHead1);
settingsHead2 = (TextView) activity.findViewById(R.id.serverSettingsHead2);
showCurrentServerTextView = (TextView) activity.findViewById(R.id.showCurrentServerTextView);
showCurrentServerStatus = (TextView) activity.findViewById(R.id.showCurrentServerStatus);
serverUrlEdit = (TextView) activity.findViewById(R.id.serverUrlEdit);
serverCommonSecretEdit = (TextView) activity.findViewById(R.id.serverCommonSecretEdit);
serverCertEdit = (TextView) activity.findViewById(R.id.serverCertEdit);
setOnClick();
}
示例9: StatusClass
import android.widget.GridLayout; //導入依賴的package包/類
public StatusClass(Activity activity, String TAG, MainActivity.ServiceControl serviceControl, int extendingSpeed) {
this.TAG = TAG;
this.activity = activity;
this.serviceControl = serviceControl;
this.extendingSpeed = extendingSpeed;
statusGrid = (GridLayout) activity.findViewById(R.id.statusGrid);
setOnClick();
lastLocationTopPreview = (TextView) activity.findViewById(R.id.lastLocationTopPreview);
lastLocationBotPreview = (TextView) activity.findViewById(R.id.lastLocationBotPreview);
lastLocationFootPreview = (TextView) activity.findViewById(R.id.lastLocationFootPreview);
lastLocationToSendTextView = (TextView) activity.findViewById(R.id.lastLocationToSendTextView);
mapOverlay = (FrameLayout) activity.findViewById(R.id.mapOverlay);
lastLocationDetails = (LinearLayout) activity.findViewById(R.id.lastLocationDetails);
/* Set listener to receive location changes, so we can display them */
serviceControl.setLastLocationListener(new Runnable() {
@Override
public void run() {
loadLastLocation();
}
});
loadLastLocation();
}
示例10: handlePreview
import android.widget.GridLayout; //導入依賴的package包/類
private void handlePreview(MenuItem item) {
if (eventGismo == null) {
GridLayout gridLayout = findViewById(R.id.events_placeholder);
eventGismo = new EventsGismo(gridLayout, PreferenceManager.getDefaultSharedPreferences(this));
eventGismo.addRecyclerView();
handleRefresh();
}
if (!previewOn) {
findViewById(R.id.events_placeholder).setVisibility(View.VISIBLE);
item.setIcon(getDrawable(R.drawable.action_preview_off_icon));
} else {
findViewById(R.id.events_placeholder).setVisibility(View.GONE);
item.setIcon(getDrawable(R.drawable.action_preview_on_icon));
}
previewOn = !previewOn;
}
示例11: afterHookedMethod
import android.widget.GridLayout; //導入依賴的package包/類
@Override
protected void afterHookedMethod(XC_MethodHook.MethodHookParam param) {
GridLayout gridLayout = (GridLayout) param.thisObject;
eventsGismo = new EventsGismo(gridLayout, new XSharedPreferences(BuildConfig.APPLICATION_ID)) {
@Override
public void notifyUpdatedPreferences() {
((XSharedPreferences) preferences).reload();
super.notifyUpdatedPreferences();
}
};
eventsGismo.addRecyclerView();
log("Added view to lockscreen");
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Constants.events_update);
intentFilter.addAction(Constants.current_event_update);
intentFilter.addAction(Constants.looks_update);
intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
gridLayout.getContext().registerReceiver(updateReceiver, intentFilter);
}
示例12: 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);
}
示例13: initViews
import android.widget.GridLayout; //導入依賴的package包/類
private void initViews() {
mGridLayout = (GridLayout) findViewById(R.id.activity_third_gridview);
mImageView = (ImageView) findViewById(R.id.activity_third_imageview);
mBtnChange = (Button) findViewById(R.id.activity_third_change);
mBtnReset = (Button) findViewById(R.id.activity_third_reset);
mBitmap = ((BitmapDrawable)mImageView.getDrawable()).getBitmap();
mGridLayout.post(new Runnable() {
@Override public void run() {
width = mGridLayout.getWidth() / 5;
height = mGridLayout.getHeight() / 4;
// add edittext
addETs();
// init ETText();
initETText();
}
});
}
示例14: onCreate
import android.widget.GridLayout; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_map);
dynamicGridLayout = (GridLayout) findViewById(R.id.dynamicGridLayout);
colors[0] = ContextCompat.getColor(this, R.color.red);
colors[1] = ContextCompat.getColor(this, R.color.orange);
colors[2] = ContextCompat.getColor(this, R.color.yellow);
colors[3] = ContextCompat.getColor(this, R.color.green);
colors[4] = ContextCompat.getColor(this, R.color.blue);
colors[5] = ContextCompat.getColor(this, R.color.purple);
colors[6] = ContextCompat.getColor(this, R.color.pink);
colors[7] = ContextCompat.getColor(this, R.color.teal);
colors[8] = ContextCompat.getColor(this, R.color.tan);
colors[9] = ContextCompat.getColor(this, R.color.gray);
}
示例15: onCreate
import android.widget.GridLayout; //導入依賴的package包/類
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_map);
dynamicGridLayout = (GridLayout) findViewById(R.id.dynamicGridLayout);
colors[0] = ContextCompat.getColor(this, R.color.red);
colors[1] = ContextCompat.getColor(this, R.color.orange);
colors[2] = ContextCompat.getColor(this, R.color.yellow);
colors[3] = ContextCompat.getColor(this, R.color.green);
colors[4] = ContextCompat.getColor(this, R.color.blue);
colors[5] = ContextCompat.getColor(this, R.color.purple);
colors[6] = ContextCompat.getColor(this, R.color.pink);
colors[7] = ContextCompat.getColor(this, R.color.teal);
colors[8] = ContextCompat.getColor(this, R.color.tan);
colors[9] = ContextCompat.getColor(this, R.color.gray);
SharedPreferences myPref = getSharedPreferences("MyPref", MODE_PRIVATE);
String map =myPref.getString("memMap", "");
memMap = new Gson().fromJson(map,MapWrapper.class).getMap();
onGenerateClicked(null);
}