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


Java GridView.setNumColumns方法代码示例

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


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

示例1: 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

示例2: 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

示例3: getViewPagerItem

import android.widget.GridView; //导入方法依赖的package包/类
private GridView getViewPagerItem(final int index) {
    GridView gridView = new GridView(_context);
    gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    gridView.setNumColumns(4);
    gridView.setVerticalScrollBarEnabled(false);
    gridView.setHorizontalScrollBarEnabled(false);
    gridView.setPadding(8, 8, 8, 0);
    gridView.setVerticalSpacing(20);
    gridView.setSelector(new ColorDrawable(Color.TRANSPARENT));

    gridView.setAdapter(new YayaEmoGridViewAdapter(_context,
            getGridViewData(index)));
    gridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            int start = index * SysConstant.yayaPageSize;
            onEmoGridViewItemClick.onItemClick(position + start, index);
        }
    });
    return gridView;
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:24,代码来源:YayaEmoGridView.java

示例4: onViewCreated

import android.widget.GridView; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ViewFlipper mainViewFlipper = view.findViewById(R.id.recent_emoticon_flipper);

    List<Emoticon> emoticonList = getEmoticonsList(getArguments().getInt(ARG_CATEGORY_ID, -1));

    if (emoticonList.isEmpty()) {
        mainViewFlipper.setDisplayedChild(1);
    } else {
        mainViewFlipper.setDisplayedChild(0);

        GridView emoticonGrid = view.findViewById(R.id.emoticon_list_grid);
        emoticonGrid.setNumColumns(getResources().getInteger(R.integer.emoticon_recycler_view_span_size));
        emoticonGrid.setOnItemClickListener(this);

        //Bind the adapter
        //noinspection WrongConstant
        EmoticonGridAdapter emoticonGridAdapter = new EmoticonGridAdapter(getActivity(),
                mEmoticonProvider, emoticonList);
        emoticonGrid.setAdapter(emoticonGridAdapter);
    }
}
 
开发者ID:kevalpatel2106,项目名称:EmoticonGIFKeyboard,代码行数:24,代码来源:EmoticonGridFragment.java

示例5: getViewPagerItem

import android.widget.GridView; //导入方法依赖的package包/类
private GridView getViewPagerItem(final int index) {
    GridView gridView = new GridView(_context);
    gridView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    gridView.setNumColumns(7);
    gridView.setVerticalScrollBarEnabled(false);
    gridView.setHorizontalScrollBarEnabled(false);
    gridView.setPadding(8, 8, 8, 0);
    gridView.setVerticalSpacing(CommonUtil.getElementSzie(_context) / 2
            + CommonUtil.getElementSzie(_context) / 3);
    // gridView.setVerticalSpacing(30);
    gridView.setBackgroundColor(Color.TRANSPARENT);
    gridView.setAdapter(new EmoGridViewAdapter(_context,
            getGridViewData(index)));
    gridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            int start = index * (SysConstant.pageSize - 1);
            onEmoGridViewItemClick.onItemClick(position + start, index);
        }
    });
    return gridView;
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:25,代码来源:EmoGridView.java

示例6: onCreateView

import android.widget.GridView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    provider = getArguments().getParcelable(ARG_PROVIDER);
    String result = getSQLResult(getContext(), provider, getString(R.string.sql_injection));
    View rootView = inflater.inflate(R.layout.fragment_details_schema, container, false);
    if (getStatus(result)==100){
        //TODO add image view
        rootView.findViewById(R.id.tv_schema).setVisibility(View.VISIBLE);
    } else {
        LinearLayout linearLayout = (LinearLayout) rootView.findViewById(R.id.ll);
        Map<String, List<List<String>>> resultToMap = parseResultToMap(result);
        for (String name: resultToMap.keySet()){
            TextView tv = getFilledTextView(getContext(),name);
            linearLayout.addView(tv);
            GridView grid = new GridView(getContext());
            grid.setNumColumns(3);
            grid.setHorizontalSpacing(10);
            grid.setVerticalSpacing(10);
            grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
            grid.setGravity(View.TEXT_ALIGNMENT_CENTER);
            List<List<String>> list = resultToMap.get(name);
            grid.setAdapter(new GridAdapter(getContext(),list));
            grid.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, list.size()*35)); //TODO: remove int value
            linearLayout.addView(grid);
        }
    }
    return rootView;
}
 
开发者ID:AlexeyZatsepin,项目名称:CP-Tester,代码行数:30,代码来源:SchemaFragment.java

示例7: init

import android.widget.GridView; //导入方法依赖的package包/类
private void init(){
	cal = Calendar.getInstance();
	base = new RelativeLayout(context);
	base.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
	base.setMinimumHeight(50);
	
	base.setId(4);
	
	LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.leftMargin = 16;
	params.topMargin = 50;
	params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	prev = new ImageView(context);
	prev.setId(1);
	prev.setLayoutParams(params);
	prev.setImageResource(R.drawable.navigation_previous_item);
	prev.setOnClickListener(this);
	base.addView(prev);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.addRule(RelativeLayout.CENTER_HORIZONTAL);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	month = new TextView(context);
	month.setId(2);
	month.setLayoutParams(params);
	month.setTextAppearance(context, android.R.attr.textAppearanceLarge);
	month.setText(cal.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.getDefault())+" "+cal.get(Calendar.YEAR));
	month.setTextSize(25);
	
	base.addView(month);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.rightMargin = 16;
	params.topMargin = 50;
	params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	params.addRule(RelativeLayout.CENTER_VERTICAL);
	next = new ImageView(context);
	next.setImageResource(R.drawable.navigation_next_item);
	next.setLayoutParams(params);
	next.setId(3);
	next.setOnClickListener(this);
	
	base.addView(next);
	
	addView(base);
	
	params = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	params.bottomMargin = 20;
	params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	params.addRule(RelativeLayout.BELOW, base.getId());
	
	calendar = new GridView(context);
	calendar.setLayoutParams(params);
	calendar.setVerticalSpacing(4);
	calendar.setHorizontalSpacing(4);
	calendar.setNumColumns(7);
	calendar.setChoiceMode(GridView.CHOICE_MODE_SINGLE);
	calendar.setDrawSelectorOnTop(true);
	calendar.setFocusable(false);

	mAdapter = new CalendarAdapter(context,cal);
	calendar.setAdapter(mAdapter);
	calendar.setOnTouchListener(new OnTouchListener() {
		
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return calendarGesture.onTouchEvent(event);
        }
    });

	addView(calendar);
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:75,代码来源:ExtendedCalendarView.java

示例8: onCreateView

import android.widget.GridView; //导入方法依赖的package包/类
@Override
    public View onCreateView(final LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_project, container, false);
        // Inflate the layout for this fragment
        mDemoSlider = (SliderLayout) view.findViewById(R.id.slider);
        simpleList = (GridView) view.findViewById(R.id.simpleGridView);

        mHandler = new Handler(Looper.getMainLooper()); // udaan hurdanii shalgax davtalt

        HashMap<String,String> url_maps = new HashMap<String, String>();
        url_maps.put("Өсвөр үеийн эрүүл ирээдүйн төлөө", "https://www.colourbox.com/preview/1282705-colorful-child-hand-prints-on-white-background.jpg");
        url_maps.put("Өсвөр үеийн эрүүл ирээдүйн төлөө", "https://image.freepik.com/free-vector/fantastic-background-of-children-playing-together_23-2147608068.jpg");
        url_maps.put("Өсвөр үеийн эрүүл ирээдүйн төлөө", "https://ak2.picdn.net/shutterstock/videos/14967505/thumb/1.jpg");

        for(String name : url_maps.keySet()){

            TextSliderView textSliderView = new TextSliderView(getActivity());
            // initialize a SliderLayout
            textSliderView
                    .description(name)
                    .image(url_maps.get(name))
                    .setScaleType(BaseSliderView.ScaleType.Fit);
//                    .setOnSliderClickListener(getContext());

            //add your extra information
            textSliderView.bundle(new Bundle());
            textSliderView.getBundle()
                    .putString("extra",name);

            mDemoSlider.addSlider(textSliderView);

        }
        mDemoSlider.setPresetTransformer(SliderLayout.Transformer.Accordion);
        mDemoSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
        mDemoSlider.setCustomAnimation(new DescriptionAnimation());
        mDemoSlider.setDuration(4000);

        simpleList.setNumColumns(2);
        simpleList.setVisibility(View.VISIBLE);

        getProject();

        return view;

    }
 
开发者ID:doljko,项目名称:youth-health,代码行数:47,代码来源:ProjectFragment.java

示例9: initViews

import android.widget.GridView; //导入方法依赖的package包/类
private void initViews() {
    mBtnBack = (Button) findViewById(R.id.btn_puzzle_main_back);
    mBtnImage = (Button) findViewById(R.id.btn_puzzle_main_img);
    mBtnRestart = (Button) findViewById(R.id.btn_puzzle_main_restart);
    //flag是否显示原图
    mIsShowImg = false;
    mGvPuzzleMainDetail = (GridView) findViewById(
            R.id.gv_puzzle_main_detail);
            // 设置为N*N显示
    mGvPuzzleMainDetail.setNumColumns(TYPE);
    RelativeLayout.LayoutParams gridParams = new RelativeLayout.LayoutParams(mPicSelected.getWidth(),mPicSelected.getHeight());
    //水平居中
    gridParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    //其他格式属性
    gridParams.addRule(RelativeLayout.BELOW,R.id.ll_puzzle_main_spinner);
    //Grid显示
    mGvPuzzleMainDetail.setLayoutParams(gridParams);
    mGvPuzzleMainDetail.setHorizontalSpacing(0);
    mGvPuzzleMainDetail.setVerticalSpacing(0);
    //TV步数
    mTvPuzzleMainCounts = (TextView) findViewById(R.id.tv_puzzle_main_counts);
    mTvPuzzleMainCounts.setText(""+ COUNT_INDEX);
    //Tv计时器
    mTvTimer = (TextView) findViewById(R.id.tv_puzzle_main_time);
    mTvTimer.setText("0秒");
    //添加显示的原图
    addImgView();

}
 
开发者ID:Yobin123,项目名称:PinTuGame,代码行数:30,代码来源:PuzzleMain.java

示例10: onViewCreated

import android.widget.GridView; //导入方法依赖的package包/类
@SuppressWarnings("DanglingJavadoc")
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mViewFlipper = view.findViewById(R.id.gif_view_flipper);
    mErrorTv = view.findViewById(R.id.error_textview);

    //Set the grid view
    mGifGridAdapter = new GifGridAdapter(mContext, mGifs, this);

    /**
     * Instead of using recycler view,we are stick to the GRidView here because in recycler view
     * items from the grid column are not getting displayed until user scrolls up-down. There is
     * no solution found for this problem,
     * @see https://stackoverflow.com/questions/29460164/recyclerview-refreshes-items-only-when-scrolling-down-and-up
     */
    GridView gridView = view.findViewById(R.id.gif_gridView);
    gridView.setNumColumns(getResources().getInteger(R.integer.gif_recycler_view_span_size));
    gridView.setAdapter(mGifGridAdapter);

    //Load the list of trending GIFs.
    if (mGifs.isEmpty()) {
        if (mTrendingGifTask != null) mTrendingGifTask.cancel(true);
        mTrendingGifTask = new TrendingGifTask();
        mTrendingGifTask.execute();
        mViewFlipper.setDisplayedChild(0);
    } else {
        mViewFlipper.setDisplayedChild(1);
    }
}
 
开发者ID:kevalpatel2106,项目名称:EmoticonGIFKeyboard,代码行数:32,代码来源:GifFragment.java

示例11: setPhotoList

import android.widget.GridView; //导入方法依赖的package包/类
/**
 * @param photoList 图片地址的集合
 */
public void setPhotoList(List<String> photoList, GridView view) {
    this.photoList = photoList;
    if (photoList.size() == 0) {
        view.setVisibility(View.GONE);
    } else if (photoList.size() <= 3) {
        view.setNumColumns(photoList.size());
    }else{
        view.setNumColumns(3);
    }
}
 
开发者ID:haoxiongqin,项目名称:One_NineGrid,代码行数:14,代码来源:DisplayPhotoAdapter.java

示例12: initViews

import android.widget.GridView; //导入方法依赖的package包/类
private void initViews(){
    mCxt = this;
    captureManager = new ImageCaptureManager(mCxt);
    initToolbar();
    mGridView = (GridView) findViewById(R.id.grid);
    mGridView.setNumColumns(getNumColnums());

    mPopupAnchorView = findViewById(R.id.photo_picker_footer);
    btnAlbum = (Button) findViewById(R.id.btnAlbum);
    btnPreview = (Button) findViewById(R.id.btnPreview);
}
 
开发者ID:Sugarya,项目名称:SugarPhotoPicker,代码行数:12,代码来源:PhotoPickerActivity.java

示例13: onCreateView

import android.widget.GridView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_organization, container, false);
    prgLoading = (ProgressBar) rootView.findViewById(R.id.newsLoading);
    homeItemList = (GridView) rootView.findViewById(R.id.newsItemList);
    txtAlert = (TextView) rootView.findViewById(R.id.newsTxtAlert);

    mHandler = new Handler(Looper.getMainLooper());

    homeItemList.setNumColumns(2);

    homeItemList.setVisibility(View.VISIBLE);

    getNews();

    return rootView;

}
 
开发者ID:doljko,项目名称:youth-health,代码行数:20,代码来源:OrgFragment.java


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