Search in sources :

Example 21 with GridView

use of android.widget.GridView in project howabout-android by recomio.

the class TrackListFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.photo_list, container, false);
    imagesGridView = (GridView) rootView.findViewById(R.id.photoGrid);
    progressBar = (ProgressBar) rootView.findViewById(R.id.load);
    return rootView;
}
Also used : GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 22 with GridView

use of android.widget.GridView in project emojicon by rockerhieu.

the class EmojiconGridFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView);
    Bundle bundle = getArguments();
    if (bundle == null) {
        mEmojiconType = Emojicon.TYPE_UNDEFINED;
        mEmojicons = People.DATA;
        mUseSystemDefault = false;
    } else {
        //noinspection WrongConstant
        mEmojiconType = bundle.getInt(ARG_EMOJICON_TYPE);
        if (mEmojiconType == Emojicon.TYPE_UNDEFINED) {
            Parcelable[] parcels = bundle.getParcelableArray(ARG_EMOJICONS);
            mEmojicons = new Emojicon[parcels.length];
            for (int i = 0; i < parcels.length; i++) {
                mEmojicons[i] = (Emojicon) parcels[i];
            }
        } else {
            mEmojicons = Emojicon.getEmojicons(mEmojiconType);
        }
        mUseSystemDefault = bundle.getBoolean(ARG_USE_SYSTEM_DEFAULTS);
    }
    gridView.setAdapter(new EmojiconAdapter(view.getContext(), mEmojicons, mUseSystemDefault));
    gridView.setOnItemClickListener(this);
}
Also used : Bundle(android.os.Bundle) Parcelable(android.os.Parcelable) GridView(android.widget.GridView)

Example 23 with GridView

use of android.widget.GridView in project Caldroid by roomorama.

the class CaldroidFragment method onCreateView.

/**
     * Setup view
     */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    retrieveInitialArgs();
    // To support keeping instance for dialog
    if (getDialog() != null) {
        try {
            setRetainInstance(true);
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
    }
    LayoutInflater localInflater = getThemeInflater(getActivity(), inflater, themeResource);
    // This is a hack to fix issue localInflater doesn't use the themeResource, make Android
    // complain about layout_width and layout_height missing. I'm unsure about its impact
    // for app that wants to change theme dynamically.
    getActivity().setTheme(themeResource);
    View view = localInflater.inflate(R.layout.calendar_view, container, false);
    // For the monthTitleTextView
    monthTitleTextView = (TextView) view.findViewById(R.id.calendar_month_year_textview);
    // For the left arrow button
    leftArrowButton = (Button) view.findViewById(R.id.calendar_left_arrow);
    rightArrowButton = (Button) view.findViewById(R.id.calendar_right_arrow);
    // Navigate to previous month when user click
    leftArrowButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            prevMonth();
        }
    });
    // Navigate to next month when user click
    rightArrowButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            nextMonth();
        }
    });
    // Show navigation arrows depend on initial arguments
    setShowNavigationArrows(showNavigationArrows);
    // For the weekday gridview ("SUN, MON, TUE, WED, THU, FRI, SAT")
    weekdayGridView = (GridView) view.findViewById(R.id.weekday_gridview);
    WeekdayArrayAdapter weekdaysAdapter = getNewWeekdayAdapter(themeResource);
    weekdayGridView.setAdapter(weekdaysAdapter);
    // Setup all the pages of date grid views. These pages are recycled
    setupDateGridPages(view);
    // Refresh view
    refreshView();
    return view;
}
Also used : LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView)

Example 24 with GridView

use of android.widget.GridView in project BottomSheet by soarcn.

the class BottomSheet method init.

private void init(final Context context) {
    setCanceledOnTouchOutside(cancelOnTouchOutside);
    final ClosableSlidingLayout mDialogView = (ClosableSlidingLayout) View.inflate(context, R.layout.bottom_sheet_dialog, null);
    LinearLayout mainLayout = (LinearLayout) mDialogView.findViewById(R.id.bs_main);
    mainLayout.addView(View.inflate(context, mHeaderLayoutId, null), 0);
    setContentView(mDialogView);
    if (!cancelOnSwipeDown)
        mDialogView.swipeable = cancelOnSwipeDown;
    mDialogView.setSlideListener(new ClosableSlidingLayout.SlideListener() {

        @Override
        public void onClosed() {
            BottomSheet.this.dismiss();
        }

        @Override
        public void onOpened() {
            showFullItems();
        }
    });
    super.setOnShowListener(new OnShowListener() {

        @Override
        public void onShow(DialogInterface dialogInterface) {
            if (showListener != null)
                showListener.onShow(dialogInterface);
            list.setAdapter(adapter);
            list.startLayoutAnimation();
            if (builder.icon == null)
                icon.setVisibility(View.GONE);
            else {
                icon.setVisibility(View.VISIBLE);
                icon.setImageDrawable(builder.icon);
            }
        }
    });
    int[] location = new int[2];
    mDialogView.getLocationOnScreen(location);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        mDialogView.setPadding(0, location[0] == 0 ? helper.mStatusBarHeight : 0, 0, 0);
        mDialogView.getChildAt(0).setPadding(0, 0, 0, helper.mNavBarAvailable ? helper.getNavigationBarHeight(getContext()) + mDialogView.getPaddingBottom() : 0);
    }
    final TextView title = (TextView) mDialogView.findViewById(R.id.bottom_sheet_title);
    if (builder.title != null) {
        title.setVisibility(View.VISIBLE);
        title.setText(builder.title);
    }
    icon = (ImageView) mDialogView.findViewById(R.id.bottom_sheet_title_image);
    list = (GridView) mDialogView.findViewById(R.id.bottom_sheet_gridview);
    mDialogView.mTarget = list;
    if (!builder.grid) {
        list.setNumColumns(1);
    }
    if (builder.grid) {
        for (int i = 0; i < getMenu().size(); i++) {
            if (getMenu().getItem(i).getIcon() == null)
                throw new IllegalArgumentException("You must set icon for each items in grid style");
        }
    }
    if (builder.limit > 0)
        limit = builder.limit * getNumColumns();
    else
        limit = Integer.MAX_VALUE;
    mDialogView.setCollapsible(false);
    actions = builder.menu;
    menuItem = actions;
    // over the initial numbers
    if (getMenu().size() > limit) {
        fullMenuItem = builder.menu;
        menuItem = builder.menu.clone(limit - 1);
        ActionMenuItem item = new ActionMenuItem(context, 0, R.id.bs_more, 0, limit - 1, moreText);
        item.setIcon(more);
        menuItem.add(item);
        actions = menuItem;
        mDialogView.setCollapsible(true);
    }
    BaseAdapter baseAdapter = new BaseAdapter() {

        @Override
        public int getCount() {
            return actions.size() - hidden.size();
        }

        @Override
        public MenuItem getItem(int position) {
            return actions.getItem(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public int getViewTypeCount() {
            return 1;
        }

        @Override
        public boolean isEnabled(int position) {
            return getItem(position).isEnabled();
        }

        @Override
        public boolean areAllItemsEnabled() {
            return false;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            ViewHolder holder;
            if (convertView == null) {
                LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                if (builder.grid)
                    convertView = inflater.inflate(mGridItemLayoutId, parent, false);
                else
                    convertView = inflater.inflate(mListItemLayoutId, parent, false);
                holder = new ViewHolder();
                holder.title = (TextView) convertView.findViewById(R.id.bs_list_title);
                holder.image = (ImageView) convertView.findViewById(R.id.bs_list_image);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
            for (int i = 0; i < hidden.size(); i++) {
                if (hidden.valueAt(i) <= position)
                    position++;
            }
            MenuItem item = getItem(position);
            holder.title.setText(item.getTitle());
            if (item.getIcon() == null)
                holder.image.setVisibility(collapseListIcons ? View.GONE : View.INVISIBLE);
            else {
                holder.image.setVisibility(View.VISIBLE);
                holder.image.setImageDrawable(item.getIcon());
            }
            holder.image.setEnabled(item.isEnabled());
            holder.title.setEnabled(item.isEnabled());
            return convertView;
        }

        class ViewHolder {

            private TextView title;

            private ImageView image;
        }
    };
    adapter = new SimpleSectionedGridAdapter(context, baseAdapter, R.layout.bs_list_divider, R.id.headerlayout, R.id.header);
    list.setAdapter(adapter);
    adapter.setGridView(list);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (((MenuItem) adapter.getItem(position)).getItemId() == R.id.bs_more) {
                showFullItems();
                mDialogView.setCollapsible(false);
                return;
            }
            if (!((ActionMenuItem) adapter.getItem(position)).invoke()) {
                if (builder.menulistener != null)
                    builder.menulistener.onMenuItemClick((MenuItem) adapter.getItem(position));
                else if (builder.listener != null)
                    builder.listener.onClick(BottomSheet.this, ((MenuItem) adapter.getItem(position)).getItemId());
            }
            dismiss();
        }
    });
    if (builder.dismissListener != null) {
        setOnDismissListener(builder.dismissListener);
    }
    setListLayout();
}
Also used : DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) MenuItem(android.view.MenuItem) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) BaseAdapter(android.widget.BaseAdapter) LinearLayout(android.widget.LinearLayout)

Example 25 with GridView

use of android.widget.GridView in project platform_frameworks_base by android.

the class GridDelete method onKeyDown.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_DEL) {
        GridView g = getGridView();
        ((DeleteAdapter) g.getAdapter()).deletePosition(g.getSelectedItemPosition());
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}
Also used : GridView(android.widget.GridView)

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