本文整理了Java中android.widget.GridView.setAdapter()
方法的一些代码示例,展示了GridView.setAdapter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.setAdapter()
方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:setAdapter
暂无
代码示例来源:origin: stackoverflow.com
@Override
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.photos_layout,container,false);
GridView gridView = (GridView) view.findViewById(R.id.photogridview);
gridView.setAdapter(new MyAdapter(view.getContext())); // uses the view to get the context instead of getActivity().
return view;
}
代码示例来源:origin: facebook/facebook-android-sdk
public void setSelectionView(final GridView selectionView) {
this.selectionView = selectionView;
selectionAdapter = new SelectionAdapter();
this.selectionView.setAdapter(selectionAdapter);
this.selectionView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
if (selectedNum != position) {
resetSelection();
selectedNum = position;
v.setBackgroundResource(R.drawable.selected_icon_background);
selectedView = v;
} else {
resetSelection();
}
}
});
}
代码示例来源:origin: rockerhieu/emojicon
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
EmojiconRecentsManager recents = EmojiconRecentsManager
.getInstance(view.getContext());
mAdapter = new EmojiconAdapter(view.getContext(), recents, mUseSystemDefault);
GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView);
gridView.setAdapter(mAdapter);
gridView.setOnItemClickListener(this);
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fr_image_grid, container, false);
listView = (GridView) rootView.findViewById(R.id.grid);
((GridView) listView).setAdapter(new ImageAdapter(getActivity()));
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
startImagePagerActivity(position);
}
});
return rootView;
}
代码示例来源:origin: amitshekhariitbhu/Fast-Android-Networking
final GridView mGridView = (GridView) v.findViewById(R.id.gridView);
mGridView.setAdapter(mAdapter);
mGridView.setOnItemClickListener(this);
mGridView.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
代码示例来源:origin: facebook/facebook-android-sdk
public void setBoardView(final GridView boardView) {
this.boardView = boardView;
boardAdapter = new BoardAdapter();
this.boardView.setAdapter(boardAdapter);
this.boardView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
if (selectedNum >= 0) {
if (board.isLocked(position)) {
Toast.makeText(context.getApplicationContext(),
R.string.position_locked,
Toast.LENGTH_SHORT).show();
} else {
board.setValue(selectedNum, position);
dataSetChanged();
}
} else {
Toast.makeText(context.getApplicationContext(),
R.string.nothing_selected,
Toast.LENGTH_SHORT).show();
}
}
});
}
代码示例来源:origin: redsolution/xabber-android
public EmojiconRecentsGridView(Context context, Emojicon[] emojicons,
EmojiconRecents recents,EmojiconsPopup emojiconsPopup) {
super(context, emojicons, recents, emojiconsPopup);
EmojiconRecentsManager recents1 = EmojiconRecentsManager
.getInstance(rootView.getContext());
mAdapter = new EmojiAdapter(rootView.getContext(), recents1);
mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() {
@Override
public void onEmojiconClicked(Emojicon emojicon) {
if (mEmojiconPopup.onEmojiconClickedListener != null) {
mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon);
}
}
});
GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView);
gridView.setAdapter(mAdapter);
}
代码示例来源:origin: rockerhieu/emojicon
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView);
Bundle bundle = getArguments();
if (bundle == null) {
mEmojiconType = Emojicon.TYPE_UNDEFINED;
mEmojicons = People.DATA;
mUseSystemDefault = false;
} else {
//noinspection WrongConstant
mEmojiconType = bundle.getInt(ARG_EMOJICON_TYPE);
if (mEmojiconType == Emojicon.TYPE_UNDEFINED) {
Parcelable[] parcels = bundle.getParcelableArray(ARG_EMOJICONS);
mEmojicons = new Emojicon[parcels.length];
for (int i = 0; i < parcels.length; i++) {
mEmojicons[i] = (Emojicon) parcels[i];
}
} else {
mEmojicons = Emojicon.getEmojicons(mEmojiconType);
}
mUseSystemDefault = bundle.getBoolean(ARG_USE_SYSTEM_DEFAULTS);
}
gridView.setAdapter(new EmojiconAdapter(view.getContext(), mEmojicons, mUseSystemDefault));
gridView.setOnItemClickListener(this);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.main);
selection=(TextView)findViewById(R.id.selection);
GridView g=(GridView) findViewById(R.id.grid);
g.setAdapter(new ArrayAdapter<String>(this,
R.layout.cell,
items));
g.setOnItemClickListener(this);
}
代码示例来源:origin: redsolution/xabber-android
public EmojiconGridView(Context context, Emojicon[] emojicons, EmojiconRecents recents, EmojiconsPopup emojiconPopup) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
mEmojiconPopup = emojiconPopup;
rootView = inflater.inflate(R.layout.emojicon_grid, null);
setRecents(recents);
GridView gridView = (GridView) rootView.findViewById(R.id.Emoji_GridView);
if (emojicons== null) {
mData = People.DATA;
} else {
Object[] o = (Object[]) emojicons;
mData = Arrays.asList(o).toArray(new Emojicon[o.length]);
}
EmojiAdapter mAdapter = new EmojiAdapter(rootView.getContext(), mData);
mAdapter.setEmojiClickListener(new OnEmojiconClickedListener() {
@Override
public void onEmojiconClicked(Emojicon emojicon) {
if (mEmojiconPopup.onEmojiconClickedListener != null) {
mEmojiconPopup.onEmojiconClickedListener.onEmojiconClicked(emojicon);
}
if (mRecents != null) {
mRecents.addRecentEmoji(rootView.getContext(), emojicon);
}
}
});
gridView.setAdapter(mAdapter);
}
代码示例来源:origin: stackoverflow.com
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(new OnItemClickListener() {
convertView = mInflater.inflate(R.layout.list_item_icon_text, null);
holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.text);
convertView.setTag(holder);
} else {
代码示例来源:origin: novoda/android-demos
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
GridView gridView = (GridView) inflater.inflate(R.layout.gridview, null);
gridView.setAdapter(new GridViewAdapter(mContext));
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> l, View v, int position, long id) {
}
});
gridView.requestFocus();
return gridView;
}
}
代码示例来源:origin: stackoverflow.com
GridView imagegrid = (GridView) findViewById(R.id.PhoneImageGrid);
imageAdapter = new ImageAdapter();
imagegrid.setAdapter(imageAdapter);
convertView = mInflater.inflate(
R.layout.galleryitem, null);
holder.imageview = (ImageView) convertView.findViewById(R.id.thumbImage);
代码示例来源:origin: wangdan/AisenWeiBo
@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 MaterialDialog.Builder(getActivity())
.customView(view, false)
.positiveText(R.string.cancel)
.build();
}
代码示例来源:origin: dongjunkun/DropDownMenu
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() {
constellation.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
代码示例来源:origin: Aspsine/SwipeToLoadLayout
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
swipeToLoadLayout = (SwipeToLoadLayout) view.findViewById(R.id.swipeToLoadLayout);
gridView = (GridView) view.findViewById(R.id.swipe_target);
swipeToLoadLayout.setOnRefreshListener(this);
swipeToLoadLayout.setOnLoadMoreListener(this);
gridView.setAdapter(mAdapter);
gridView.setOnScrollListener(new AbsListView.OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
if (!ViewCompat.canScrollVertically(view, 1)) {
swipeToLoadLayout.setLoadingMore(true);
}
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
});
}
代码示例来源:origin: lovetuzitong/MultiImageSelector
mImageAdapter.showSelectIndicator(mode == MODE_MULTI);
mPopupAnchorView = view.findViewById(R.id.footer);
mCategoryText = (TextView) view.findViewById(R.id.category_btn);
mCategoryText.setText(R.string.mis_folder_all);
mCategoryText.setOnClickListener(new View.OnClickListener() {
mGridView = (GridView) view.findViewById(R.id.grid);
mGridView.setAdapter(mImageAdapter);
mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
代码示例来源:origin: daimajia/AndroidSwipeLayout
final GridViewAdapter adapter = new GridViewAdapter(this);
adapter.setMode(Attributes.Mode.Multiple);
gridView.setAdapter(adapter);
gridView.setSelected(false);
gridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
代码示例来源:origin: stackoverflow.com
grdImages.setAdapter(imageAdapter);
imagecursor.close();
holder = new ViewHolder();
convertView = mInflater.inflate(R.layout.custom_gallery_item, null);
holder.imgThumb = (ImageView) convertView.findViewById(R.id.imgThumb);
holder.chkImage = (CheckBox) convertView.findViewById(R.id.chkImage);
代码示例来源:origin: stackoverflow.com
mGrid = (GridView) chooserView.findViewById(R.id.resolver_grid);
mGrid.setAdapter(mAdapter);
mGrid.setOnItemClickListener(this);
内容来源于网络,如有侵权,请联系作者删除!