當前位置: 首頁>>代碼示例>>Java>>正文


Java GridLayout.addView方法代碼示例

本文整理匯總了Java中android.support.v7.widget.GridLayout.addView方法的典型用法代碼示例。如果您正苦於以下問題:Java GridLayout.addView方法的具體用法?Java GridLayout.addView怎麽用?Java GridLayout.addView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v7.widget.GridLayout的用法示例。


在下文中一共展示了GridLayout.addView方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: populateFavorites

import android.support.v7.widget.GridLayout; //導入方法依賴的package包/類
private void populateFavorites(List<Song> favorites)
{
    if(favorites != null)
    {
        GridLayout favoritesLayout = (GridLayout)getView().findViewById(R.id.favorites_layout);

        float favWidth = getContext().getResources().getDimension(R.dimen.album_grid_item_width);
        float favHeight = getContext().getResources().getDimension(R.dimen.album_grid_item_height);

        LayoutInflater inflater = LayoutInflater.from(getContext());
        int max = Math.min(favorites.size(),3);
        for(int i = 0; i < max; i++)
        {
            Song song = favorites.get(i);
            View v = inflater.inflate(R.layout.album_grid_item, favoritesLayout, false);
            favoritesLayout.addView(v);

            ImageView artworkView = (ImageView) v.findViewById(R.id.album_artwork);
        }
    }
}
 
開發者ID:andryr,項目名稱:Harmony-Music-Player,代碼行數:22,代碼來源:HomeFragment.java

示例2: SuggestionViewHolder

import android.support.v7.widget.GridLayout; //導入方法依賴的package包/類
public SuggestionViewHolder(View itemView) {
    super(itemView);

    suggestionRelative = (RelativeLayout) itemView.findViewById(R.id.suggestion_detail);
    suggestionDetailIcon = (ImageView) itemView.findViewById(R.id.suggestion_detail_icon);
    suggestionDetailInfo = (TextView) itemView.findViewById(R.id.suggestion_detail_info);
    suggestionDetailIntroduction = (TextView) itemView.findViewById(R.id.suggestion_detail_introduction);

    suggestionGrid = (GridLayout) itemView.findViewById(R.id.suggestion_grid);
    for (int i = 0; i < 6; i++) {
        View view = View.inflate(mContext, R.layout.item_suggestion_grid, null);
        view.setId(R.id.suggestion_view_id + i);
        GridLayout.LayoutParams params = new GridLayout.LayoutParams();
        params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
        params.setMargins(90, 15, 0, 15);//設置邊距
        view.setLayoutParams(params);
        suggestionType[i] = (TextView) view.findViewById(R.id.suggestion_type);
        suggestionInfo[i] = (TextView) view.findViewById(R.id.suggestion_info);
        suggestionIcon[i] = (ImageView) view.findViewById(R.id.suggestion_icon);
        suggestionGrid.addView(view);
    }
}
 
開發者ID:GavinAndre,項目名稱:MaterialWeather,代碼行數:23,代碼來源:MyAdapter.java

示例3: generateColorBlocks

import android.support.v7.widget.GridLayout; //導入方法依賴的package包/類
public void generateColorBlocks(int[] colors, GridLayout layout) {
    int column = 3;
    int total = colors.length;
    int rows = total / column;

    layout.setColumnCount(column);
    layout.setRowCount(rows + 1);

    for (int i = 0, c = 0, r = 0; i < total; i++, c++) {
        if (c == column) {
            c = 0;
            r++;
        }

        GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
        layoutParams.rowSpec = GridLayout.spec(r);
        layoutParams.columnSpec = GridLayout.spec(c);
        layoutParams.setGravity(Gravity.CENTER);

        ImageView imageView = new ImageView(layout.getContext());
        imageView.setBackgroundColor(colorsParam[i]);
        imageView.setLayoutParams(layoutParams);
        layout.addView(imageView);
    }
}
 
開發者ID:emugabi,項目名稱:colorblocks,代碼行數:26,代碼來源:ColorPickerFragment.java

示例4: onCreateDialog

import android.support.v7.widget.GridLayout; //導入方法依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int preselect = getArguments().getInt("preselect");
    View view = View.inflate(getActivity(), R.layout.dialog_color_chooser, null);
    mColors = initColors();

    GridLayout gridLayout = (GridLayout) view.findViewById(R.id.grid);

    for (int i = 0; i < mColors.length; i++) {
        gridLayout.addView(getColorItemView(getActivity(), i, i == preselect));
    }
    AlertDialog dialog = new AlertDialog.Builder(getActivity())
            .setTitle(R.string.color_chooser)
            .setView(view)
            .show();
    return dialog;
}
 
開發者ID:maoruibin,項目名稱:AppPlus,代碼行數:19,代碼來源:ColorChooseDialog.java

示例5: createOptionIcon

import android.support.v7.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);
    if (mOption.isEditable()) {
        optionIcon.setMaxWidth(mEditableOptionIconMaxWidth);
    } else {
        optionIcon.setMaxWidth(mNonEditableOptionIconMaxWidth);
    }
    optionIcon.setAdjustViewBounds(true);
    optionIcon.setImageDrawable(mOption.getDrawableIcon());

    // 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, GridLayout.CENTER));
    iconParams.topMargin = mVerticalMargin;
    parent.addView(optionIcon, iconParams);

    optionIcon.setOnClickListener(OptionSection.this);
    return optionIcon;
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:24,代碼來源:PaymentRequestSection.java

示例6: createEditIcon

import android.support.v7.widget.GridLayout; //導入方法依賴的package包/類
private View createEditIcon(GridLayout parent, int rowIndex) {
    View editorIcon = LayoutInflater.from(parent.getContext())
                              .inflate(R.layout.payment_option_edit_icon, null);

    // The icon floats to the right of everything.
    GridLayout.LayoutParams iconParams =
            new GridLayout.LayoutParams(GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
                    GridLayout.spec(3, 1, GridLayout.CENTER));
    iconParams.topMargin = mVerticalMargin;
    parent.addView(editorIcon, iconParams);

    editorIcon.setOnClickListener(OptionSection.this);
    return editorIcon;
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:15,代碼來源:PaymentRequestSection.java

示例7: onCreate

import android.support.v7.widget.GridLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(getClass().getName(), "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_numbers);

    getWindow().setStatusBarColor(Color.parseColor("#1C80CF"));

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setBackgroundDrawable(getDrawable(R.color.blue));

    LiteracyApplication literacyApplication = (LiteracyApplication) getApplicationContext();
    numberDao = literacyApplication.getDaoSession().getNumberDao();
    audioDao = literacyApplication.getDaoSession().getAudioDao();

    numberGridLayout = (GridLayout) findViewById(R.id.numberGridLayout);


    List<Number> numbers = new CurriculumHelper(getApplication()).getAvailableNumbers(null);
    Log.i(getClass().getName(), "numbers.size(): " + numbers.size());
    for (final Number number : numbers) {
        View numberView = LayoutInflater.from(this).inflate(R.layout.content_numbers_number_view, numberGridLayout, false);
        TextView numberTextView = (TextView) numberView.findViewById(R.id.numberTextView);
        if (!TextUtils.isEmpty(number.getSymbol())) {
            numberTextView.setText(number.getSymbol());
        } else {
            numberTextView.setText(number.getValue().toString());
        }

        numberView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i(getClass().getName(), "onClick");

                Log.i(getClass().getName(), "number.getValue(): " + number.getValue());
                Log.i(getClass().getName(), "number.getSymbol(): " + number.getSymbol());
                Log.i(getClass().getName(), "number.getAllWords(): " + number.getWords());
                if (!number.getWords().isEmpty()) {
                    for (Word numberWord : number.getWords()) {
                        Log.i(getClass().getName(), "numberWord.getText(): " + numberWord.getText());
                    }
                }

                playNumberSound(number);

                EventTracker.reportNumberLearningEvent(getApplicationContext(), number.getValue());

                Intent numberIntent = new Intent(getApplicationContext(), NumberActivity.class);
                numberIntent.putExtra("number", number.getValue());
                startActivity(numberIntent);
            }
        });

        numberGridLayout.addView(numberView);
    }
}
 
開發者ID:elimu-ai,項目名稱:authentication,代碼行數:60,代碼來源:NumbersActivity.java

示例8: onCreate

import android.support.v7.widget.GridLayout; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.i(getClass().getName(), "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_letters);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);

    LiteracyApplication literacyApplication = (LiteracyApplication) getApplicationContext();
    letterDao = literacyApplication.getDaoSession().getLetterDao();
    audioDao = literacyApplication.getDaoSession().getAudioDao();

    letterGridLayout = (GridLayout) findViewById(R.id.letterGridLayout);


    ContentProvider.initializeDb(this);
    List<Allophone> allophones = ContentProvider.getAllAllophones();
    Log.i(getClass().getName(), "allophones: " + allophones);
    Log.i(getClass().getName(), "allophones.size(): " + allophones.size());

    List<Letter> letters = new CurriculumHelper(getApplication()).getAvailableLetters(null);
    Log.i(getClass().getName(), "letters.size(): " + letters.size());
    for (final Letter letter : letters) {
        View letterView = LayoutInflater.from(this).inflate(R.layout.content_letters_letter_view, letterGridLayout, false);
        TextView letterTextView = (TextView) letterView.findViewById(R.id.letterTextView);
        letterTextView.setText(letter.getText());

        letterView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.i(getClass().getName(), "onClick");

                playLetterSound(letter);

                EventTracker.reportLetterLearningEvent(getApplicationContext(), letter.getText());

                Intent scrollingLetterIntent = new Intent(getApplicationContext(), ScrollingLetterActivity.class);
                scrollingLetterIntent.putExtra("letter", letter.getText());
                startActivity(scrollingLetterIntent);
            }
        });

        letterGridLayout.addView(letterView);
    }
}
 
開發者ID:elimu-ai,項目名稱:authentication,代碼行數:49,代碼來源:LettersActivity.java

示例9: createLabel

import android.support.v7.widget.GridLayout; //導入方法依賴的package包/類
private TextView createLabel(GridLayout parent, int rowIndex, boolean optionIconExists,
        boolean editIconExists, boolean isEnabled) {
    Context context = parent.getContext();
    Resources resources = context.getResources();

    // By default, the label appears to the right of the "button" in the second column.
    // + If there is no button, no option and edit icon, the label spans the whole row.
    // + If there is no option and edit icon, the label spans three columns.
    // + If there is no edit icon or option icon, the label spans two columns.
    // + Otherwise, the label occupies only its own column.
    int columnStart = 1;
    int columnSpan = 1;
    if (!optionIconExists) columnSpan++;
    if (!editIconExists) columnSpan++;

    TextView labelView = new TextView(context);
    if (mRowType == OPTION_ROW_TYPE_OPTION) {
        // Show the string representing the PaymentOption.
        ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
                ? R.style.PaymentsUiSectionDefaultText
                : R.style.PaymentsUiSectionDisabledText);
        labelView.setText(convertOptionToString(mOption,
                mDelegate.isBoldLabelNeeded(OptionSection.this),
                false /* singleLine */));
        labelView.setEnabled(isEnabled);
    } else if (mRowType == OPTION_ROW_TYPE_ADD) {
        // Shows string saying that the user can add a new option, e.g. credit card no.
        String typeface = resources.getString(R.string.roboto_medium_typeface);
        int textStyle = resources.getInteger(R.integer.roboto_medium_textstyle);
        int buttonHeight = resources.getDimensionPixelSize(
                R.dimen.payments_section_add_button_height);

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionAddButtonLabel);
        labelView.setMinimumHeight(buttonHeight);
        labelView.setGravity(Gravity.CENTER_VERTICAL);
        labelView.setTypeface(Typeface.create(typeface, textStyle));
    } else if (mRowType == OPTION_ROW_TYPE_DESCRIPTION) {
        // The description spans all the columns.
        columnStart = 0;
        columnSpan = 4;

        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionDescriptiveText);
    } else if (mRowType == OPTION_ROW_TYPE_WARNING) {
        // Warnings use three columns.
        columnSpan = 3;
        ApiCompatibilityUtils.setTextAppearance(
                labelView, R.style.PaymentsUiSectionWarningText);
    }

    // The label spans two columns if no option or edit icon, or spans three columns if
    // no option and edit icons. Setting the view width to 0 forces it to stretch.
    GridLayout.LayoutParams labelParams =
            new GridLayout.LayoutParams(GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
                    GridLayout.spec(columnStart, columnSpan, GridLayout.FILL, 1f));
    labelParams.topMargin = mVerticalMargin;
    labelParams.width = 0;
    if (optionIconExists) {
        // Margin at the end of the label instead of the start of the option icon to
        // allow option icon in the the next row align with the end of label (include
        // end margin) when edit icon exits in that row, like below:
        // ---Label---------------------[label margin]|---option icon---|
        // ---Label---[label margin]|---option icon---|----edit icon----|
        ApiCompatibilityUtils.setMarginEnd(labelParams, mLargeSpacing);
    }
    parent.addView(labelView, labelParams);

    labelView.setOnClickListener(OptionSection.this);
    return labelView;
}
 
開發者ID:mogoweb,項目名稱:365browser,代碼行數:72,代碼來源:PaymentRequestSection.java


注:本文中的android.support.v7.widget.GridLayout.addView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。