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();
}
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);
}
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;
}
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();
}
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);
}
Aggregations