当前位置: 首页>>代码示例>>Java>>正文


Java GridView类代码示例

本文整理汇总了Java中android.widget.GridView的典型用法代码示例。如果您正苦于以下问题:Java GridView类的具体用法?Java GridView怎么用?Java GridView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GridView类属于android.widget包,在下文中一共展示了GridView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateView

import android.widget.GridView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    sGrid = new GridView(getActivity());
    sGrid.setNumColumns(KJEmojiConfig.COLUMNS);
    adapter = new EmojiGridAdapter(getActivity(), datas);
    sGrid.setAdapter(adapter);
    sGrid.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                                int position, long id) {
            EditText editText = (EditText) getActivity().findViewById(
                    R.id.emoji_titile_input);
            if (listener != null) {
                listener.onEmojiClick((Emojicon) parent.getAdapter()
                        .getItem(position));
            }
            if (editText != null)
                InputHelper.input2OSC(editText, (Emojicon) parent.getAdapter()
                        .getItem(position));
        }
    });
    sGrid.setSelector(R.drawable.ic_material);
    return sGrid;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:26,代码来源:EmojiPageFragment.java

示例2: createEmotionGridView

import android.widget.GridView; //导入依赖的package包/类
/**
 * 创建显示表情的GridView
 */
private GridView createEmotionGridView(List<String> emotionNames, int gvWidth, int padding, int itemWidth, int gvHeight) {
    // 创建GridView
    GridView gv = new GridView(getActivity());
    //设置点击背景透明
    gv.setSelector(android.R.color.transparent);
    //设置7列
    gv.setNumColumns(7);
    gv.setPadding(padding, padding, padding, padding);
    gv.setHorizontalSpacing(padding);
    gv.setVerticalSpacing(padding * 2);
    //设置GridView的宽高
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(gvWidth, gvHeight);
    gv.setLayoutParams(params);
    // 给GridView设置表情图片
    EmotionGridViewAdapter adapter = new EmotionGridViewAdapter(getActivity(), emotionNames, itemWidth,emotion_map_type);
    gv.setAdapter(adapter);
    //设置全局点击事件
    gv.setOnItemClickListener(GlobalOnItemClickManagerUtils.getInstance().getOnItemClickListener(getActivity(),emotion_map_type));
    return gv;
}
 
开发者ID:SiberiaDante,项目名称:EmotionApp,代码行数:24,代码来源:EmotionComplateFragment.java

示例3: onCreateView

import android.widget.GridView; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.fragment_category, container, false);

    categoryList = new ArrayList<>();

    Request request = new Request(getActivity(), urlCategory, com.android.volley.Request.Method.GET);
    request.requestVolley(this);
    progressDialog = new ProgressDialog(getActivity());
    progressDialog.setMessage("Menü Yükleniyor.");
    progressDialog.show();

    gridView = (GridView) view.findViewById(R.id.gvCat);
    gridView.setOnItemClickListener(this);

    return view;
}
 
开发者ID:yusufcakal,项目名称:RestaurantApp,代码行数:19,代码来源:CategoryFragment.java

示例4: initView

import android.widget.GridView; //导入依赖的package包/类
private void initView() {
    gridView = (GridView) rootView.findViewById(R.id.grid);
    bottomView = rootView.findViewById(R.id.bottom_layout);
    gridAdapter = new TimeLineAdapter(getActivity());
    gridAdapter.setDecodeSize(decodeBitmapWidth);
    gridView.setAdapter(gridAdapter);
    gridAdapter.registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            super.onChanged();
        }

        @Override
        public void onInvalidated() {
            super.onInvalidated();
        }

    });

    gridView.setOnItemClickListener(this);
    gridView.setOnItemLongClickListener(this);
}
 
开发者ID:YuntaoWei,项目名称:PictureShow,代码行数:24,代码来源:TimeLinePage.java

示例5: onResume

import android.widget.GridView; //导入依赖的package包/类
@Override
public void onResume() {
    super.onResume();

    // Load from file "cities.json" first time
    if (mAdapter == null) {
        List<City> cities = loadCities();

        //This is the GridView adapter
        mAdapter = new CityAdapter(this);
        mAdapter.setData(cities);

        //This is the GridView which will display the list of cities
        mGridView = (GridView) findViewById(R.id.cities_list);
        mGridView.setAdapter(mAdapter);
        mGridView.setOnItemClickListener(GridViewExampleActivity.this);
        mAdapter.notifyDataSetChanged();
        mGridView.invalidate();
    }
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:21,代码来源:GridViewExampleActivity.java

示例6: initView

import android.widget.GridView; //导入依赖的package包/类
protected void initView() {
    gridView = (GridView) findViewById(R.id.gridview);
    photo_delete = (ImageView) findViewById(R.id.photo_delete);
    photo_choose = (ImageView) findViewById(R.id.photo_choose);
    gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));
    if (type == VIDEOTYPE) {
        adapter = new ImageGridAdapter(ImageGridActivity.this, null, videoList,
                mHandler, type);
    } else {
        adapter = new ImageGridAdapter(ImageGridActivity.this, dataList, null,
                mHandler, type);
    }
    dialog = new Dialog(this);
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setTitle("数据上传");
    View view = View.inflate(this, R.layout.customerdialogcheckroll, null);
    bar = (ProgressBar) view.findViewById(R.id.customerdialog_pb);
    tip = (TextView) view.findViewById(R.id.customerdialog_tv);

    dialog.setContentView(view);
    gridView.setAdapter(adapter);
}
 
开发者ID:gitxuyulin,项目名称:EditorImageAndText,代码行数:24,代码来源:ImageGridActivity.java

示例7: onCreateView

import android.widget.GridView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_sample, container, false);

    mSwipeRefreshLayout = (MultiSwipeRefreshLayout) view.findViewById(R.id.swiperefresh);

    // BEGIN_INCLUDE (change_colors)
    // Set the color scheme of the SwipeRefreshLayout by providing 4 color resource ids
    mSwipeRefreshLayout.setColorSchemeResources(
            R.color.swipe_color_1, R.color.swipe_color_2,
            R.color.swipe_color_3, R.color.swipe_color_4);
    // END_INCLUDE (change_colors)

    mGridView = (GridView) view.findViewById(android.R.id.list);
    mEmptyView = view.findViewById(android.R.id.empty);
    return view;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SwipeRefreshMultipleViewsFragment.java

示例8: getView

import android.widget.GridView; //导入依赖的package包/类
@SuppressLint("DefaultLocale")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = new CircleView(getContext());
        convertView.setLayoutParams(new GridView.LayoutParams(circleSize, circleSize));
    }
    CircleView child = (CircleView) convertView;
    @ColorInt
    final int color = isInSub() ? mColorsSub[topIndex()][position] : mColorsTop[position];
    child.setBackgroundColor(color);
    if (isInSub())
        child.setSelected(subIndex() == position);
    else child.setSelected(topIndex() == position);
    child.setTag(String.format("%d:%d", position, color));
    child.setOnClickListener(ColorChooserDialog.this);
    child.setOnLongClickListener(ColorChooserDialog.this);
    return convertView;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:ColorChooserDialog.java

示例9: onCreateView

import android.widget.GridView; //导入依赖的package包/类
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View v = inflater.inflate(R.layout.image_grid_fragment, container, false);
    final GridView mGridView = (GridView) v.findViewById(R.id.gridView);
    mGridView.setAdapter(mAdapter);
    mGridView.setOnItemClickListener(this);
    mGridView.getViewTreeObserver().addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
                @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
                @Override
                public void onGlobalLayout() {
                    if (mAdapter.getNumColumns() == 0) {
                        final int numColumns = (int) Math.floor(
                                mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));
                        if (numColumns > 0) {
                            final int columnWidth =
                                    (mGridView.getWidth() / numColumns) - mImageThumbSpacing;
                            mAdapter.setNumColumns(numColumns);
                            mAdapter.setItemHeight(columnWidth);

                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                                mGridView.getViewTreeObserver()
                                        .removeOnGlobalLayoutListener(this);
                            } else {
                                mGridView.getViewTreeObserver()
                                        .removeGlobalOnLayoutListener(this);
                            }
                        }
                    }
                }
            });

    return v;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:ImageGridFragment.java

示例10: onCreateView

import android.widget.GridView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    GridView view = (GridView) inflater.inflate(R.layout.fragment_timetable, container, false);

    /*if (savedInstanceState != null) {
        long[] ids = savedInstanceState.getLongArray("ids");
        String[] names = savedInstanceState.getStringArray("names");
        byte[] times = savedInstanceState.getByteArray("times");

        if (ids != null && names != null && times != null) {
            changes.clear();
            for (int i = 0; i < ids.length; i++)
                changes.add(new Lesson(ids[i], names[i], times[i], Codes.private_));
        }
    }
    view.setAdapter(new TimetableConfigAdapter(-1, changes));*/
    return view;
}
 
开发者ID:whirlwind-studios,项目名称:School1-Android,代码行数:19,代码来源:TimetableFragment.java

示例11: onCreate

import android.widget.GridView; //导入依赖的package包/类
protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_lottery);
StatusBarUtil.setColor(this, getResources().getColor(R.color.colorPrimary));
       etPeriod = forceCast(findViewById(R.id.etPeriod));
       tvDateTime = forceCast(findViewById(R.id.tvDateTime));
       tvName = forceCast(findViewById(R.id.tvName));
       tvSales = forceCast(findViewById(R.id.tvSales));
       tvPool = forceCast(findViewById(R.id.tvPool));
       tvPeriod = forceCast(findViewById(R.id.tvPeriod));
       tvLotteryNumber = forceCast(findViewById(R.id.tvLotteryNumber));

       GridView gvLotteryList = forceCast(findViewById(R.id.gvLotteryList));
       ListView lvLotteryResult = forceCast(findViewById(R.id.lvLotteryAward));
       gvLotteryList.setOnItemClickListener(this);

       //init data
       updateLotteryInfo(null, null, null, null, null, null);

       lotteryTypeList = new ArrayList<HashMap<String, Object>>();
       lotteryTypeListAdapter = new SimpleAdapter(this, lotteryTypeList, android.R.layout.simple_list_item_1, new String[]{"name"}, new int[]{android.R.id.text1});
       gvLotteryList.setAdapter(lotteryTypeListAdapter);

       lotteryResultList = new ArrayList<HashMap<String, Object>>();
       lotteryResultAdapter = new LotteryResultAdapter(this, lotteryResultList);
       lvLotteryResult.setAdapter(lotteryResultAdapter);

       //获取彩种列表
       ((Lottery) forceCast(MobAPI.getAPI(Lottery.NAME))).queryLotteryList(LotteryAPIActivity.this);
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:31,代码来源:LotteryAPIActivity.java

示例12: EmojiconGridView

import android.widget.GridView; //导入依赖的package包/类
public EmojiconGridView(Context context, Emojicon[] emojicons, EmojiconsPopup emojiconPopup) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    mEmojiconPopup = emojiconPopup;
    rootView = inflater.inflate(R.layout.emojicon_grid, null);
    GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView);
    if (emojicons == null) {
        mData = People.DATA;
    } else {
        mData = Arrays.asList(emojicons).toArray(new Emojicon[emojicons.length]);
    }
    EmojiAdapter mAdapter = new EmojiAdapter(rootView.getContext(), mData);
    mAdapter.setEmojiClickListener(emojicon -> {
        if (mEmojiconPopup.getOnEmojiconClickedListener() != null) {
            mEmojiconPopup.getOnEmojiconClickedListener().onEmojiconClicked(emojicon);
        }
    });
    gridView.setAdapter(mAdapter);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:19,代码来源:EmojiconGridView.java

示例13: invalidateViews

import android.widget.GridView; //导入依赖的package包/类
public void invalidateViews() {
    for (GridView gridView : views) {
        if (gridView != null) {
            gridView.invalidateViews();
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:8,代码来源:EmojiView.java

示例14: init

import android.widget.GridView; //导入依赖的package包/类
public void init() {
inflate(getContext(), R.layout.common_emotionbar, this);
mGvDisplay = (GridView) findViewById(R.id.emotionbar_gv_display);
mRgInner = (RadioGroup) findViewById(R.id.emotionbar_rg_inner);
mIvDelete = (ImageView) findViewById(R.id.emotionbar_iv_delete);

mGvDisplay.setOnItemClickListener(this);
mRgInner.setOnCheckedChangeListener(this);
mIvDelete.setOnClickListener(this);

mDefaultAdapter = new EmoteAdapter(getContext(),
		BaseApplication.mEmoticons_Zem);
mEmojiAdapter = new EmoteAdapter(getContext(),
		BaseApplication.mEmoticons_Zemoji);
mGvDisplay.setAdapter(mDefaultAdapter);
mIsSelectedDefault = true;
}
 
开发者ID:qizhenghao,项目名称:HiBangClient,代码行数:18,代码来源:EmoteInputView.java

示例15: onCreateView

import android.widget.GridView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:33,代码来源:DirectoryFragment.java


注:本文中的android.widget.GridView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。