本文整理匯總了Java中android.widget.GridLayout.getChildCount方法的典型用法代碼示例。如果您正苦於以下問題:Java GridLayout.getChildCount方法的具體用法?Java GridLayout.getChildCount怎麽用?Java GridLayout.getChildCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.GridLayout
的用法示例。
在下文中一共展示了GridLayout.getChildCount方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: interruptPicDownload
import android.widget.GridLayout; //導入方法依賴的package包/類
protected void interruptPicDownload(GridLayout gridLayout) {
for (int i = 0; i < gridLayout.getChildCount(); i++) {
ImageView iv = (ImageView) gridLayout.getChildAt(i);
if (iv != null) {
Drawable drawable = iv.getDrawable();
if (drawable instanceof PictureBitmapDrawable) {
PictureBitmapDrawable downloadedDrawable = (PictureBitmapDrawable) drawable;
IPictureWorker worker = downloadedDrawable.getBitmapDownloaderTask();
if (worker != null) {
((MyAsyncTask) worker).cancel(true);
}
iv.setImageDrawable(null);
}
}
}
}
示例2: interruptPicDownload
import android.widget.GridLayout; //導入方法依賴的package包/類
protected void interruptPicDownload(GridLayout gridLayout) {
for (int i = 0; i < gridLayout.getChildCount(); i++) {
ImageView iv = (ImageView) gridLayout.getChildAt(i);
if (iv != null) {
Drawable drawable = iv.getDrawable();
if (drawable instanceof PictureBitmapDrawable) {
PictureBitmapDrawable downloadedDrawable = (PictureBitmapDrawable) drawable;
IPictureWorker worker = downloadedDrawable
.getBitmapDownloaderTask();
if (worker != null) {
((MyAsyncTask) worker).cancel(true);
}
iv.setImageDrawable(null);
}
}
}
}
示例3: interruptPicDownload
import android.widget.GridLayout; //導入方法依賴的package包/類
protected void interruptPicDownload(GridLayout gridLayout) {
for (int i = 0; i < gridLayout.getChildCount(); i++) {
ImageView iv = (ImageView) gridLayout.getChildAt(i);
if (iv != null) {
Drawable drawable = iv.getDrawable();
if (drawable instanceof PictureBitmapDrawable) {
PictureBitmapDrawable downloadedDrawable
= (PictureBitmapDrawable) drawable;
IPictureWorker worker = downloadedDrawable.getBitmapDownloaderTask();
if (worker != null) {
((MyAsyncTask) worker).cancel(true);
}
iv.setImageDrawable(null);
}
}
}
}
示例4: setChildrenOnClickListener
import android.widget.GridLayout; //導入方法依賴的package包/類
private void setChildrenOnClickListener(AppCompatRadioButton child) {
GridLayout parent = (GridLayout) child.getParent();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View v = parent.getChildAt(i);
if (v instanceof AppCompatRadioButton) {
if (((RadioButton) v).isChecked()) {
activeRadioButton = (AppCompatRadioButton) v;
}
v.setOnClickListener(this);
}
}
}
示例5: onWindowFocusChanged
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
// GridLayout內のアイテムをレイアウトサイズに合わせてストレッチ
final GridLayout gl = (GridLayout) findViewById(R.id.calcFrame);
int childWidth = gl.getWidth() / gl.getColumnCount();
int childHeight = gl.getHeight() / gl.getRowCount();
for (int i = 0; i < gl.getChildCount(); i++) {
gl.getChildAt(i).setMinimumWidth(childWidth);
gl.getChildAt(i).setMinimumHeight(childHeight);
}
}
示例6: 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);
}
}
示例7: markSorted
import android.widget.GridLayout; //導入方法依賴的package包/類
private void markSorted() {
final GridLayout sortArea = (GridLayout) findViewById(R.id.sort_area);
for (int i = 0; i < sortArea.getChildCount() - 1; i++) {
int num1 = (int) sortArea.getChildAt(i).getTag();
int num2 = (int) sortArea.getChildAt(i + 1).getTag();
if (num1 > num2) {
//sortArea.getChildAt(i).setBackgroundColor(Color.CYAN);
sortArea.getChildAt(i+1).setBackgroundColor(Color.RED);
//break;
}
}
}
示例8: onCreateView
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = (GridLayout) inflater.inflate(R.layout.fragment_drum_grid, container, false);
for (int i = 0; i < rootView.getChildCount(); i++) {
DrumPad dp = (DrumPad) rootView.getChildAt(i);
dp.init(MainActivity.config.gridDrumSounds[i], DrumFragment.isEditMode);
}
return rootView;
}
示例9: selectTheme
import android.widget.GridLayout; //導入方法依賴的package包/類
public void selectTheme(View view) {
GridLayout grid = (GridLayout) view.getParent();
int selection = grid.indexOfChild(view);
for (int i = 0; i < grid.getChildCount(); i++)
grid.getChildAt(i).setSelected(false);
view.setSelected(true);
selectTheme(selection, true);
}
示例10: playAgain
import android.widget.GridLayout; //導入方法依賴的package包/類
public void playAgain(View view) {
gameIsActive = true;
LinearLayout layout = (LinearLayout)findViewById(R.id.playAgainLayout);
layout.setVisibility(View.INVISIBLE);
activePlayer = 0;
for (int i = 0; i < gameState.length; i++) {
gameState[i] = 2;
}
GridLayout gridLayout = (GridLayout)findViewById(R.id.gridLayout);
for (int i = 0; i< gridLayout.getChildCount(); i++) {
((ImageView) gridLayout.getChildAt(i)).setImageResource(0);
}
}
示例11: checkDone
import android.widget.GridLayout; //導入方法依賴的package包/類
private void checkDone() {
if (!problemDone) {
final GridLayout sortArea = (GridLayout) findViewById(R.id.sort_area);
boolean sorted = true;
for (int i = 0; i < sortArea.getChildCount() - 1; i++) {
int num1 = (int) sortArea.getChildAt(i).getTag();
int num2 = (int) sortArea.getChildAt(i + 1).getTag();
if (num1 > num2) {
sorted = false;
break;
}
}
if (sorted) {
cancelHint();
problemDone = true;
stopTimer();
for (int i = 0; i < sortArea.getChildCount(); i++) {
final int c = i;
handler.postDelayed(new Runnable() {
@Override
public void run() {
sortArea.getChildAt(c).setBackgroundColor(Color.GREEN);
}
}, (c + 1) * 1000 / sortArea.getChildCount());
}
handler.postDelayed(new Runnable() {
@Override
public void run() {
finishDone();
}
}, 1200);
}
}
}
示例12: showDialog
import android.widget.GridLayout; //導入方法依賴的package包/類
@Override
public void showDialog(Bundle state) {
if (getEntryValues() == null) {
throw new IllegalStateException(
"ColorGridPreference requires an entryValues array.");
}
if (originalValue == null)
originalValue = getValue();
final int preselect = findIndexOfValue(getValue());
AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
.setTitle(getDialogTitle())
.setIcon(getDialogIcon())
.setCancelable(true)
.setNegativeButton(android.R.string.cancel, (dialog, which) -> {
onDialogClosed(false);
dialog.cancel();
})
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
onDialogClosed(true);
dialog.dismiss();
})
.setView(R.layout.theme_dialog);
PreferenceManager pm = getPreferenceManager();
try {
Method method = pm.getClass().getDeclaredMethod(
"registerOnActivityDestroyListener",
PreferenceManager.OnActivityDestroyListener.class);
method.setAccessible(true);
method.invoke(pm, this);
} catch (Exception e) {
e.printStackTrace();
}
mDialog = builder.create();
mDialog.setCanceledOnTouchOutside(false);
mDialog.getWindow().getAttributes().windowAnimations = android.R.anim.accelerate_interpolator;
if (state != null)
mDialog.onRestoreInstanceState(state);
mDialog.show();
GridLayout gridLayout = mDialog.findViewById(R.id.grid);
gridLayout.getChildAt(preselect).setSelected(true);
for (int i = 0; i < gridLayout.getChildCount(); i++) {
gridLayout.getChildAt(i).setOnClickListener(v -> ((SettingsActivity) getContext()).selectTheme(v));
}
}