本文整理汇总了Java中android.widget.GridView.setOnItemClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java GridView.setOnItemClickListener方法的具体用法?Java GridView.setOnItemClickListener怎么用?Java GridView.setOnItemClickListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.GridView
的用法示例。
在下文中一共展示了GridView.setOnItemClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initContentView
import android.widget.GridView; //导入方法依赖的package包/类
/**
* 初始化ContentView
*/
private void initContentView(View rootView) {
GridView mGridView = (GridView) rootView.findViewById(R.id.share_platform_grid);
rootView.findViewById(R.id.share_cancle).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
mGridView.setOnItemClickListener(this);
adapter = new ShareItemAdapter();
mGridView.setAdapter(adapter);
}
示例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;
}
示例3: 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();
}
}
示例4: 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;
}
示例5: 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;
}
示例6: 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);
}
示例7: 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;
}
示例8: 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();
}
}
示例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;
}
示例10: 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);
}
示例11: onViewCreated
import android.widget.GridView; //导入方法依赖的package包/类
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
final GridView gridView = findAdapterView();
gridView.setEmptyView(getEmptyView());
gridView.setOnItemClickListener(this);
}
示例12: 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);
}
示例13: 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;
}
示例14: onCreate
import android.widget.GridView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gridView = (GridView) findViewById(R.id.gridView);
gridView.setOnItemClickListener(this);
findAddOnActivities();
}
示例15: onCreate
import android.widget.GridView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.AppThemeStaffLogin);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_staff_desk);
deskListGlobal = new ArrayList<>();
swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(this);
swipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
swipeRefreshLayout.setRefreshing(true);
}
}
);
Request request = new Request(this, url, com.android.volley.Request.Method.GET);
request.requestVolleyDeskList(this);
gridView = (GridView) findViewById(R.id.gvDesk);
gridView.setOnItemClickListener(this);
getSupportActionBar().setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(R.layout.custom_actionbar);
tvActionBar = (TextView)getSupportActionBar().getCustomView().findViewById(R.id.tvActionBar);
ibLogout = (ImageButton) getSupportActionBar().getCustomView().findViewById(R.id.ibLogout);
ibLogout.setVisibility(View.VISIBLE);
ibLogout.setOnClickListener(this);
tvActionBar.setText(getResources().getString(R.string.staffDeskHeader));
//startService(new Intent(StaffDeskActivity.this, StaffService.class));
}