Search in sources :

Example 11 with GridView

use of android.widget.GridView in project SeriesGuide by UweTrottmann.

the class ListsFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mAdapter = new ListItemsAdapter(getActivity(), onContextMenuClickListener);
    if (getView() == null) {
        return;
    }
    // setup grid view
    GridView gridView = (GridView) getView().findViewById(android.R.id.list);
    // enable app bar scrolling out of view only on L or higher
    ViewCompat.setNestedScrollingEnabled(gridView, AndroidUtils.isLollipopOrHigher());
    gridView.setAdapter(mAdapter);
    gridView.setOnItemClickListener(this);
    gridView.setEmptyView(getView().findViewById(android.R.id.empty));
    gridView.setFastScrollAlwaysVisible(false);
    gridView.setFastScrollEnabled(true);
    getLoaderManager().initLoader(LOADER_ID, getArguments(), loaderCallbacks);
}
Also used : ListItemsAdapter(com.battlelancer.seriesguide.adapters.ListItemsAdapter) GridView(android.widget.GridView)

Example 12 with GridView

use of android.widget.GridView in project CustomShapeImageView by MostafaGazar.

the class SamplesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_samples);
    GridView gridView = (GridView) findViewById(R.id.gridview);
    gridView.setAdapter(new SvgImagesAdapter(this));
}
Also used : GridView(android.widget.GridView)

Example 13 with GridView

use of android.widget.GridView in project material-dialogs by afollestad.

the class ColorChooserDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (getArguments() == null || !getArguments().containsKey("builder")) {
        throw new IllegalStateException("ColorChooserDialog should be created using its Builder interface.");
    }
    generateColors();
    int preselectColor;
    boolean foundPreselectColor = false;
    if (savedInstanceState != null) {
        foundPreselectColor = !savedInstanceState.getBoolean("in_custom", false);
        preselectColor = getSelectedColor();
    } else {
        if (getBuilder().setPreselectionColor) {
            preselectColor = getBuilder().preselectColor;
            if (preselectColor != 0) {
                for (int topIndex = 0; topIndex < colorsTop.length; topIndex++) {
                    if (colorsTop[topIndex] == preselectColor) {
                        foundPreselectColor = true;
                        topIndex(topIndex);
                        if (getBuilder().accentMode) {
                            subIndex(2);
                        } else if (colorsSub != null) {
                            findSubIndexForColor(topIndex, preselectColor);
                        } else {
                            subIndex(5);
                        }
                        break;
                    }
                    if (colorsSub != null) {
                        for (int subIndex = 0; subIndex < colorsSub[topIndex].length; subIndex++) {
                            if (colorsSub[topIndex][subIndex] == preselectColor) {
                                foundPreselectColor = true;
                                topIndex(topIndex);
                                subIndex(subIndex);
                                break;
                            }
                        }
                        if (foundPreselectColor) {
                            break;
                        }
                    }
                }
            }
        } else {
            preselectColor = Color.BLACK;
            foundPreselectColor = true;
        }
    }
    circleSize = getResources().getDimensionPixelSize(R.dimen.md_colorchooser_circlesize);
    final Builder builder = getBuilder();
    MaterialDialog.Builder bd = new MaterialDialog.Builder(getActivity()).title(getTitle()).autoDismiss(false).customView(R.layout.md_dialog_colorchooser, false).negativeText(builder.cancelBtn).positiveText(builder.doneBtn).neutralText(builder.allowUserCustom ? builder.customBtn : 0).onPositive(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            callback.onColorSelection(ColorChooserDialog.this, getSelectedColor());
            dismiss();
        }
    }).onNegative(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            if (isInSub()) {
                dialog.setActionButton(DialogAction.NEGATIVE, getBuilder().cancelBtn);
                isInSub(false);
                // Do this to avoid ArrayIndexOutOfBoundsException
                subIndex(-1);
                invalidate();
            } else {
                dialog.cancel();
            }
        }
    }).onNeutral(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            toggleCustom(dialog);
        }
    }).showListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            invalidateDynamicButtonColors();
        }
    });
    if (builder.theme != null) {
        bd.theme(builder.theme);
    }
    final MaterialDialog dialog = bd.build();
    final View v = dialog.getCustomView();
    grid = (GridView) v.findViewById(R.id.md_grid);
    if (builder.allowUserCustom) {
        selectedCustomColor = preselectColor;
        colorChooserCustomFrame = v.findViewById(R.id.md_colorChooserCustomFrame);
        customColorHex = (EditText) v.findViewById(R.id.md_hexInput);
        customColorIndicator = v.findViewById(R.id.md_colorIndicator);
        customSeekA = (SeekBar) v.findViewById(R.id.md_colorA);
        customSeekAValue = (TextView) v.findViewById(R.id.md_colorAValue);
        customSeekR = (SeekBar) v.findViewById(R.id.md_colorR);
        customSeekRValue = (TextView) v.findViewById(R.id.md_colorRValue);
        customSeekG = (SeekBar) v.findViewById(R.id.md_colorG);
        customSeekGValue = (TextView) v.findViewById(R.id.md_colorGValue);
        customSeekB = (SeekBar) v.findViewById(R.id.md_colorB);
        customSeekBValue = (TextView) v.findViewById(R.id.md_colorBValue);
        if (!builder.allowUserCustomAlpha) {
            v.findViewById(R.id.md_colorALabel).setVisibility(View.GONE);
            customSeekA.setVisibility(View.GONE);
            customSeekAValue.setVisibility(View.GONE);
            customColorHex.setHint("2196F3");
            customColorHex.setFilters(new InputFilter[] { new InputFilter.LengthFilter(6) });
        } else {
            customColorHex.setHint("FF2196F3");
            customColorHex.setFilters(new InputFilter[] { new InputFilter.LengthFilter(8) });
        }
        if (!foundPreselectColor) {
            // If color wasn't found in the preset colors, it must be custom
            toggleCustom(dialog);
        }
    }
    invalidate();
    return dialog;
}
Also used : InputFilter(android.text.InputFilter) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogInterface(android.content.DialogInterface) GridView(android.widget.GridView) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(android.support.annotation.NonNull) NonNull(android.support.annotation.NonNull)

Example 14 with GridView

use of android.widget.GridView in project CurtainView by aicaprio.

the class SampleActivity method showSample2.

private void showSample2() {
    setContentView(R.layout.activity_sample2);
    final CurtainView curtainView = (CurtainView) findViewById(R.id.cv1);
    final ImageView iv1 = (ImageView) findViewById(R.id.iv1);
    final GridView gv1 = (GridView) findViewById(R.id.gv1);
    final List<Map<String, Integer>> data = getData();
    gv1.setAdapter(new SimpleAdapter(this, data, R.layout.item_numbers, new String[] { TEXT_TAG }, new int[] { R.id.item_tvNum }));
    gv1.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            showToast(data.get(position).get(TEXT_TAG) + " clicked");
        }
    });
    iv1.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            curtainView.toggleStatus();
        }
    });
    curtainView.setScrollerInterpolator(new BounceInterpolator());
    curtainView.post(new Runnable() {

        @Override
        public void run() {
            curtainView.setCurtainGravityAndFixedValue(null, iv1.getHeight());
        }
    });
}
Also used : BounceInterpolator(android.view.animation.BounceInterpolator) SimpleAdapter(android.widget.SimpleAdapter) GridView(android.widget.GridView) ImageView(android.widget.ImageView) CurtainView(com.movitech.aicaprio.CurtainView) View(android.view.View) AdapterView(android.widget.AdapterView) CurtainView(com.movitech.aicaprio.CurtainView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) GridView(android.widget.GridView) HashMap(java.util.HashMap) Map(java.util.Map)

Example 15 with GridView

use of android.widget.GridView in project SlidingMenu by jfeinstein10.

the class BirdGridFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mPos == -1 && savedInstanceState != null)
        mPos = savedInstanceState.getInt("mPos");
    TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img);
    mImgRes = imgs.getResourceId(mPos, -1);
    GridView gv = (GridView) inflater.inflate(R.layout.list_grid, null);
    gv.setBackgroundResource(android.R.color.black);
    gv.setAdapter(new GridAdapter());
    gv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (getActivity() == null)
                return;
            ResponsiveUIActivity activity = (ResponsiveUIActivity) getActivity();
            activity.onBirdPressed(mPos);
        }
    });
    return gv;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) TypedArray(android.content.res.TypedArray) GridView(android.widget.GridView) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView)

Aggregations

GridView (android.widget.GridView)139 View (android.view.View)83 AdapterView (android.widget.AdapterView)61 TextView (android.widget.TextView)41 ImageView (android.widget.ImageView)28 AbsListView (android.widget.AbsListView)20 Intent (android.content.Intent)14 ViewGroup (android.view.ViewGroup)14 SuppressLint (android.annotation.SuppressLint)10 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)10 LayoutInflater (android.view.LayoutInflater)8 ArrayList (java.util.ArrayList)8 WindowManager (android.view.WindowManager)7 Button (android.widget.Button)7 ColorDrawable (android.graphics.drawable.ColorDrawable)6 ListView (android.widget.ListView)6 LinearLayout (android.widget.LinearLayout)5 Bundle (android.os.Bundle)4 ViewTreeObserver (android.view.ViewTreeObserver)4 ArrayAdapter (android.widget.ArrayAdapter)4