Search in sources :

Example 51 with GridView

use of android.widget.GridView in project AisenWeiBo by wangdan.

the class MDColorsDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    setCancelable(true);
    View view = View.inflate(getActivity(), R.layout.ui_mdcolors_dialog, null);
    GridView gridView = (GridView) view.findViewById(R.id.grid);
    gridView.setAdapter(new MDColorsAdapter());
    gridView.setOnItemClickListener(this);
    gridView.setOnItemLongClickListener(this);
    return new AlertDialogWrapper.Builder(getActivity()).setView(view).setPositiveButton(R.string.cancel, null).create();
}
Also used : AlertDialogWrapper(com.afollestad.materialdialogs.AlertDialogWrapper) GridView(android.widget.GridView) CircleImageView(org.aisen.android.ui.widget.CircleImageView) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 52 with GridView

use of android.widget.GridView in project XhsEmoticonsKeyboard by w446108264.

the class SimpleUserDefAppsGridView method init.

protected void init() {
    GridView gv_apps = (GridView) view.findViewById(R.id.gv_apps);
    gv_apps.setSelector(new ColorDrawable(Color.TRANSPARENT));
    gv_apps.setNumColumns(2);
    ArrayList<AppBean> mAppBeanList = new ArrayList<>();
    mAppBeanList.add(new AppBean(R.mipmap.chatting_photo, "图片"));
    mAppBeanList.add(new AppBean(R.mipmap.chatting_camera, "拍照"));
    ChattingAppsAdapter adapter = new ChattingAppsAdapter(getContext(), mAppBeanList);
    gv_apps.setAdapter(adapter);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ArrayList(java.util.ArrayList) GridView(android.widget.GridView) SimpleAppsGridView(com.xhsemoticonskeyboard.common.widget.SimpleAppsGridView) AppBean(com.xhsemoticonskeyboard.common.data.AppBean)

Example 53 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 54 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 55 with GridView

use of android.widget.GridView in project JustAndroid by chinaltz.

the class DropMenuActivity method initView.

private void initView() {
    //init city menu
    final ListView cityView = new ListView(this);
    cityAdapter = new GirdDropDownAdapter(this, Arrays.asList(citys));
    cityView.setDividerHeight(0);
    cityView.setAdapter(cityAdapter);
    //init age menu
    final ListView ageView = new ListView(this);
    ageView.setDividerHeight(0);
    ageAdapter = new ListDropDownAdapter(this, Arrays.asList(ages));
    ageView.setAdapter(ageAdapter);
    //init sex menu
    final ListView sexView = new ListView(this);
    sexView.setDividerHeight(0);
    sexAdapter = new ListDropDownAdapter(this, Arrays.asList(sexs));
    sexView.setAdapter(sexAdapter);
    //init constellation
    final View constellationView = getLayoutInflater().inflate(R.layout.custom_layout, null);
    GridView constellation = ButterKnife.findById(constellationView, R.id.constellation);
    constellationAdapter = new ConstellationAdapter(this, Arrays.asList(constellations));
    constellation.setAdapter(constellationAdapter);
    TextView ok = ButterKnife.findById(constellationView, R.id.ok);
    ok.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mDropDownMenu.setTabText(constellationPosition == 0 ? headers[3] : constellations[constellationPosition]);
            mDropDownMenu.closeMenu();
        }
    });
    //init popupViews
    popupViews.add(cityView);
    popupViews.add(ageView);
    popupViews.add(sexView);
    popupViews.add(constellationView);
    //add item click event
    cityView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            cityAdapter.setCheckItem(position);
            mDropDownMenu.setTabText(position == 0 ? headers[0] : citys[position]);
            mDropDownMenu.closeMenu();
        }
    });
    ageView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ageAdapter.setCheckItem(position);
            mDropDownMenu.setTabText(position == 0 ? headers[1] : ages[position]);
            mDropDownMenu.closeMenu();
        }
    });
    sexView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            sexAdapter.setCheckItem(position);
            mDropDownMenu.setTabText(position == 0 ? headers[2] : sexs[position]);
            mDropDownMenu.closeMenu();
        }
    });
    constellation.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            constellationAdapter.setCheckItem(position);
            constellationPosition = position;
        }
    });
    //init context view
    TextView contentView = new TextView(this);
    contentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    contentView.setText("内容显示区域");
    contentView.setGravity(Gravity.CENTER);
    contentView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    //init dropdownview
    mDropDownMenu.setDropDownMenu(Arrays.asList(headers), popupViews, contentView);
}
Also used : ConstellationAdapter(com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.ConstellationAdapter) ViewGroup(android.view.ViewGroup) GridView(android.widget.GridView) ImageView(android.widget.ImageView) BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) GirdDropDownAdapter(com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.GirdDropDownAdapter) ListView(android.widget.ListView) ListDropDownAdapter(com.litingzhe.justandroid.ui.segmentAndSelectMenu.dropMenu.adapter.ListDropDownAdapter) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) GridView(android.widget.GridView)

Aggregations

GridView (android.widget.GridView)142 View (android.view.View)86 AdapterView (android.widget.AdapterView)64 TextView (android.widget.TextView)42 ImageView (android.widget.ImageView)30 AbsListView (android.widget.AbsListView)20 Intent (android.content.Intent)15 ViewGroup (android.view.ViewGroup)14 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)11 SuppressLint (android.annotation.SuppressLint)10 ArrayList (java.util.ArrayList)9 LayoutInflater (android.view.LayoutInflater)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