本文整理了Java中android.widget.GridView.setOnItemClickListener()
方法的一些代码示例,展示了GridView.setOnItemClickListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GridView.setOnItemClickListener()
方法的具体详情如下:
包路径:android.widget.GridView
类名称:GridView
方法名:setOnItemClickListener
暂无
代码示例来源: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: 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: 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: amitshekhariitbhu/Fast-Android-Networking
mGridView.setAdapter(mAdapter);
mGridView.setOnItemClickListener(this);
mGridView.getViewTreeObserver().addOnGlobalLayoutListener(
new ViewTreeObserver.OnGlobalLayoutListener() {
代码示例来源: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: 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: stackoverflow.com
gridView.setAdapter(myAdapter);
gridView.setOnItemClickListener(new OnItemClickListener() {
代码示例来源: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: 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: 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: TommyLemon/APIJSON
if (adapter == null) {
adapter = new GridAdapter(context).setHasName(false);
gvMomentView.setAdapter(adapter);
gvMomentView.setOnItemClickListener(this);
代码示例来源:origin: lovetuzitong/MultiImageSelector
mGridView.setAdapter(mImageAdapter);
mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
代码示例来源:origin: smuyyh/BookReader
gvTheme.setAdapter(gvAdapter);
gvTheme.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
代码示例来源:origin: bm-x/PhotoView
gv.setAdapter(new BaseAdapter() {
@Override
public int getCount() {
gv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
代码示例来源:origin: zuiwuyuan/WeChatPswKeyboard
private void setupView() {
// 这里、重新为数字键盘gridView设置了Adapter
KeyBoardAdapter keyBoardAdapter = new KeyBoardAdapter(mContext, valueList);
gridView.setAdapter(keyBoardAdapter);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position < 11 && position != 9) { //点击0~9按钮
if (currentIndex >= -1 && currentIndex < 5) { //判断输入位置————要小心数组越界
;
++currentIndex;
tvList[currentIndex].setText(valueList.get(position).get("name"));
tvList[currentIndex].setVisibility(View.INVISIBLE);
imgList[currentIndex].setVisibility(View.VISIBLE);
}
} else {
if (position == 11) { //点击退格键
if (currentIndex - 1 >= -1) { //判断是否删除完毕————要小心数组越界
tvList[currentIndex].setText("");
tvList[currentIndex].setVisibility(View.VISIBLE);
imgList[currentIndex].setVisibility(View.INVISIBLE);
currentIndex--;
}
}
}
}
});
}
代码示例来源:origin: stackoverflow.com
private void showAlertDialog() {
// Prepare grid view
GridView gridView = new GridView(this);
List<Integer> mList = new ArrayList<Integer>();
for (int i = 1; i < 36; i++) {
mList.add(i);
}
gridView.setAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, mList));
gridView.setNumColumns(5);
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// do something here
}
});
// Set grid view to alertDialog
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(gridView);
builder.setTitle("Goto");
builder.show();
}
代码示例来源:origin: stackoverflow.com
mGrid.setAdapter(mAdapter);
mGrid.setOnItemClickListener(this);
代码示例来源:origin: stackoverflow.com
gridView.setAdapter(adapter);
gridView.setOnItemClickListener(this);
代码示例来源:origin: stackoverflow.com
imgbtn_show_smileys.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
final Dialog groupIconsDialog = new Dialog(UserChatActivity.this);
groupIconsDialog.setTitle("Choose Group Icon");
groupIconsDialog.setContentView(R.layout.group_icons_layout);
//calling and setting the image icons to the grid view adapter
final GridView groupIconsGrid = (GridView)groupIconsDialog.findViewById(R.id.grid_groupIcons);
groupIconsGrid.setAdapter(new SmileysAdapter(arrayListSmileys, UserChatActivity.this, emoticons));
groupIconsGrid.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1,
int position, long arg3) {
// TODO Auto-generated method stub
String value = groupIconsGrid.getAdapter().getItem(position).toString();
value = editMessage.getText()+value;
Spannable spannable = getSmiledText(UserChatActivity.this, value);
editMessage.setText(spannable);
groupIconsDialog.dismiss();
}
});
groupIconsDialog.show();
}
});
内容来源于网络,如有侵权,请联系作者删除!