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


Java GridView.setAdapter方法代码示例

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


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

示例1: 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:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:GridViewExampleActivity.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: 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: setUiAfterDetection

import android.widget.GridView; //导入方法依赖的package包/类
private void setUiAfterDetection(Face[] result, boolean succeed) {
    mProgressDialog.dismiss();

    if (succeed) {
        // Set the information about the detection result.
        if (result != null) {
            setInfo(result.length + " face"
                    + (result.length != 1 ? "s" : "") + " detected");
        } else {
            setInfo("0 face detected");
        }

        // Set the adapter of the ListView which contains the details of the detected faces.
        mFaceGridViewAdapter = new FaceGridViewAdapter(result);

        // Show the detailed list of detected faces.
        GridView gridView = (GridView) findViewById(R.id.gridView_faces_to_select);
        gridView.setAdapter(mFaceGridViewAdapter);
    }
}
 
开发者ID:interritus1996,项目名称:memento-app,代码行数:21,代码来源:AddFaceToPersonActivity.java

示例5: onViewCreated

import android.widget.GridView; //导入方法依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    if (DBG_LC) Log.d(TAG, "onViewCreated");

    // cancel button
    view.findViewById(R.id.cancel).setOnClickListener(this);

    // image grid
    mGrid = (GridView) view.findViewById(R.id.list);
    mGrid.setAdapter(mAdapter);
    mGrid.setOnItemClickListener(this);
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:13,代码来源:VideoInfoPosterChooserFragment.java

示例6: onCreate

import android.widget.GridView; //导入方法依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Override
public void onCreate(Bundle state) {
	super.onCreate(state);
	exitIfStartupFailed(getIntent());
	setContentView(R.layout.activity_nav_drawer);

	Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
	drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
	navigation = (NavigationView) findViewById(R.id.navigation);
	GridView transportsView = (GridView) findViewById(R.id.transportsView);

	setSupportActionBar(toolbar);
	getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	getSupportActionBar().setHomeButtonEnabled(true);

	drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar,
			R.string.nav_drawer_open_description,
			R.string.nav_drawer_close_description);
	drawerLayout.addDrawerListener(drawerToggle);
	navigation.setNavigationItemSelectedListener(this);

	initializeTransports(getLayoutInflater());
	transportsView.setAdapter(transportsAdapter);

	if (state == null) {
		startFragment(ForumListFragment.newInstance(), R.id.nav_btn_forums);
	}
	if (getIntent() != null) {
		onNewIntent(getIntent());
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:33,代码来源:NavDrawerActivity.java

示例7: onCreate

import android.widget.GridView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);

	setContentView(R.layout.act_colors);

	mColorScheme = HostDatabase.DEFAULT_COLOR_SCHEME;

	mHostDb = HostDatabase.get(this);

	mColorList = mHostDb.getColorsForScheme(mColorScheme);
	mDefaultColors = mHostDb.getDefaultColorsForScheme(mColorScheme);

	mColorGrid = (GridView) findViewById(R.id.color_grid);
	mColorGrid.setAdapter(new ColorsAdapter(true));
	mColorGrid.setOnItemClickListener(this);
	mColorGrid.setSelection(0);

	mFgSpinner = (Spinner) findViewById(R.id.fg);
	mFgSpinner.setAdapter(new ColorsAdapter(false, R.string.colors_fg_label));
	mFgSpinner.setSelection(mDefaultColors[0]);
	mFgSpinner.setOnItemSelectedListener(this);

	mBgSpinner = (Spinner) findViewById(R.id.bg);
	mBgSpinner.setAdapter(new ColorsAdapter(false, R.string.color_bg_label));
	mBgSpinner.setSelection(mDefaultColors[1]);
	mBgSpinner.setOnItemSelectedListener(this);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:ColorsActivity.java

示例8: onCreate

import android.widget.GridView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");
    list.add("sfd");

    ListAdapter adapter=new ListAdapter();
    gridView=(GridView) findViewById(R.id.gridview);
    gridView.setAdapter(adapter);

    favoriteLL=(LinearLayout)findViewById(R.id.btm);



}
 
开发者ID:inceleb,项目名称:InstagramManager-Android,代码行数:33,代码来源:DetailActivity.java

示例9: onCreate

import android.widget.GridView; //导入方法依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.sample_gridview_activity);

  GridView gv = (GridView) findViewById(R.id.grid_view);
  gv.setAdapter(new SampleGridViewAdapter(this));
  gv.setOnScrollListener(new SampleScrollListener(this));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:SampleGridViewActivity.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: onCreateView

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

    final View v = inflater.inflate(R.layout.fragment_event, container, false);
    ((MainActivity) getActivity()).setActionBarTitle("Events");

    GridView gridView = (GridView)v.findViewById(R.id.gridview);

    gridView.setAdapter(new MyAdapter(getActivity()));
    gridView.setOnItemClickListener(this);
    return v;
}
 
开发者ID:vikasdesale,项目名称:Wings2K16,代码行数:14,代码来源:EventFragment.java

示例12: onCreate

import android.widget.GridView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_usage_example_gridview);
    GridView gridView = (GridView) findViewById(R.id.usage_example_gridview);

    gridView.setAdapter(
            new SimpleImageListAdapter(
                    GridViewActivity.this,
                    ListViewActivity.eatFoodyImages
            )
    );
}
 
开发者ID:fs-opensource,项目名称:android-glide-youtube-sample,代码行数:15,代码来源:GridViewActivity.java

示例13: addHeaderView

import android.widget.GridView; //导入方法依赖的package包/类
private void addHeaderView() {
    View header =  LayoutInflater.from(getContext()).inflate(R.layout.layout_calender_header, this, false);
    header.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, headerHeight));
    header.setBackgroundColor(headerBgColor);
    GridView weekGrid = (GridView) header.findViewById(R.id.grid_week);
    addView(header);
    weekGrid.setAdapter(new WeekAdapter(getViewHelper));
    header.setVisibility(showWeek ? VISIBLE : GONE);
}
 
开发者ID:LineChen,项目名称:Month_Calendar,代码行数:10,代码来源:MonthCalendar.java

示例14: instantiateItem

import android.widget.GridView; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.media_page, container, false);

    GridView grid = (GridView) layout.findViewById(R.id.media_grid);
    grid.setColumnWidth(mColumnWidth);
    grid.setAdapter(gridAdapterList.get(position));

    container.addView(layout);

    return layout;
}
 
开发者ID:yangchaojiang,项目名称:ChatKeyboard-master,代码行数:14,代码来源:MediaPagerAdapter.java

示例15: StickersGridView

import android.widget.GridView; //导入方法依赖的package包/类
public StickersGridView(Context context, StickerSet set, EmojiconsPopup emojiconPopup) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
    mEmojiconPopup = emojiconPopup;
    rootView = inflater.inflate(R.layout.stickers_grid, null);
    GridView gridView = rootView.findViewById(R.id.grid_stickers);

    StickersAdapter mAdapter = new StickersAdapter(rootView.getContext(), set);
    mAdapter.setStickerClickedListener(stickerId -> {
        if (mEmojiconPopup.getOnStickerClickedListener() != null) {
            mEmojiconPopup.getOnStickerClickedListener().onStickerClick(stickerId);
        }
    });

    gridView.setAdapter(mAdapter);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:16,代码来源:StickersGridView.java


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