Java Code Examples for android.widget.GridView#setOnItemClickListener()
The following examples show how to use
android.widget.GridView#setOnItemClickListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChatEmotionFragment.java From chatui with Apache License 2.0 | 6 votes |
/** * 创建显示表情的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(8); 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); gv.setAdapter(adapter); //设置全局点击事件 gv.setOnItemClickListener(GlobalOnItemClickManagerUtils.getInstance(getActivity()).getOnItemClickListener()); return gv; }
Example 2
Source File: MssPreviewFragment.java From MainScreenShow with GNU General Public License v2.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { main = (RelativeLayout) inflater.inflate(R.layout.fragment_msspreview, container, false); gv = (GridView) main.findViewById(R.id.gv_mss); mssPA = new MSSPreviewAdapter(); gv.setAdapter(mssPA); gv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) { } }); return main; }
Example 3
Source File: FanartSearchFragmentTv.java From Mizuu with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View v, Bundle savedInstanceState) { super.onViewCreated(v, savedInstanceState); mProgressBar = (ProgressBar) v.findViewById(R.id.progress); if (mImages.size() > 0) mProgressBar.setVisibility(View.GONE); // Hack to remove the ProgressBar on orientation change mGridView = (GridView) v.findViewById(R.id.gridView); mAdapter = new ImageAdapter(getActivity()); mGridView.setAdapter(mAdapter); mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // Create the download Service Intent downloadService = new Intent(getActivity(), DownloadImageService.class); downloadService.putExtra(DownloadImageService.CONTENT_ID, mShowId); downloadService.putExtra(DownloadImageService.IMAGE_URL, mImages.get(arg2)); downloadService.putExtra(DownloadImageService.IMAGE_TYPE, DownloadImageService.IMAGE_TYPE_TVSHOW_BACKDROP); getActivity().startService(downloadService); // End the browser Activity getActivity().finish(); } }); }
Example 4
Source File: FragmentEmojiNature.java From emoji-keyboard with Apache License 2.0 | 6 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView); Bundle bundle = getArguments(); if (bundle == null) { mData = Nature.DATA; mUseSystemDefault = false; } else { Parcelable[] parcels = bundle.getParcelableArray(EMOJI_KEY); mData = new Emoji[parcels.length]; for (int i = 0; i < parcels.length; i++) { mData[i] = (Emoji) parcels[i]; } mUseSystemDefault = bundle.getBoolean(USE_SYSTEM_DEFAULT_KEY); } gridView.setAdapter(new EmojiAdapter(view.getContext(), mData, mUseSystemDefault)); gridView.setOnItemClickListener(this); }
Example 5
Source File: MediaAddActivity.java From BigApp_WordPress_Android with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); setContentView(R.layout.zg_activity_media_add); mGridView = (GridView) findViewById(R.id.gridview); ((TextView) findViewById(R.id.title)) .setText(R.string.zg_content_media_pic_select); findViewById(R.id.iv_left).setOnClickListener(this); TextView tv_right = (TextView) findViewById(R.id.tv_right); tv_right.setOnClickListener(this); mGridView.setOnItemClickListener(this); mGridView.setOnItemSelectedListener(this); mAdapter = new AdapterGridAdd(this); mGridView.setAdapter(mAdapter); mMediaInfoList = (ArrayList<MediaInfo>) getIntent() .getSerializableExtra(MediaConstants.MEDIA_REQUEST_DATAS); if (mMediaInfoList == null) { mMediaInfoList = new ArrayList<MediaInfo>(); } mAdapter.setVideos(mMediaInfoList, 6); }
Example 6
Source File: EmojiconGridFragment.java From talk-android with MIT License | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView); Bundle bundle = getArguments(); if (bundle == null) { mData = People.DATA; mUseSystemDefault = false; } else { Object[] o = (Object[]) getArguments().getSerializable("emojicons"); mData = Arrays.asList(o).toArray(new Emojicon[o.length]); mUseSystemDefault = bundle.getBoolean(USE_SYSTEM_DEFAULT_KEY); } gridView.setAdapter(new EmojiAdapter(view.getContext(), mData, mUseSystemDefault)); gridView.setOnItemClickListener(this); }
Example 7
Source File: LoansByPersonFragment.java From loaned-android with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); View v = inflater.inflate(R.layout.fragment_loanslist, container, false); mProgress = (ProgressBar)v.findViewById(R.id.loanslist_progress); mEmptyState = (TextView)v.findViewById(R.id.loanslist_empty); mGridView = (GridView)v.findViewById(R.id.loanslist_grid); mGridView.setOnItemClickListener(this); mDB = new DatabaseManager(getActivity()); return v; }
Example 8
Source File: XiHaHouFragment.java From Android-EmotionInputDetector with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.emotion_gird, container, false); BaseAdapter adapter = new XiHaHouEmojiAdapter(mContext); GridView grid = (GridView) view.findViewById(R.id.grid); grid.setAdapter(adapter); grid.setOnItemClickListener(GlobalOnItemClickManager.getInstance().getOnItemClickListener(1)); return view; }
Example 9
Source File: HomeActivity.java From Dashboard with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarIcon(R.drawable.ic_ab_drawer); GridView gridView = (GridView) findViewById(R.id.gridView); gridView.setAdapter(new GridViewAdapter()); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String url = (String) view.getTag(); DetailActivity.launch(HomeActivity.this, view.findViewById(R.id.image), url); } }); drawer = (DrawerLayout) findViewById(R.id.drawer); drawer.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START); //TODO Customize Dialog if (prefs.getBoolean("firstrun", true)) { new MaterialDialog.Builder(this) .title("Loading") .content("It may take some time for the wallpapers to load. We're sorry for that but don't worry, this is just for the first start. After that the wallpapers are stored in the cache. Go and get some cookies :)") .positiveText("Okay.") .show(); prefs.edit().putBoolean("firstrun", false).apply(); } }
Example 10
Source File: EmoteInputView.java From WifiChat with GNU General Public License v2.0 | 5 votes |
public void init() { inflate(getContext(), R.layout.common_emotionbar, this); mGvDisplay = (GridView) findViewById(R.id.emotionbar_gv_display); mGvDisplay.setOnItemClickListener(this); mDefaultAdapter = new EmoteAdapter(getContext(), BaseApplication.mEmoticons_Zem); mGvDisplay.setAdapter(mDefaultAdapter); }
Example 11
Source File: LatestFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_latest, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_latest_view); MainActivity activity = (MainActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); latestNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.latest_netWork_relativeLayout); latestGridView = (GridView) view.findViewById(R.id.fragment_latest_gridview); latestGridView.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); latestGridView.setColumnWidth((int) width); latestGridView.setOnItemClickListener(this); if(this.mShowNoNetworkView){ latestNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); }else{ latestNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 12
Source File: CommandChanger.java From TextFiction with Apache License 2.0 | 5 votes |
@Override public boolean onLongClick(View v) { Context ctx = v.getContext(); text = cmdLine.getText().toString(); if (text.length() > 0) { text = cmdLine.getEditableText().toString(); LayoutInflater li = (LayoutInflater) ctx .getSystemService(Context.LAYOUT_INFLATER_SERVICE); cmdIcon = (CmdIcon) v.getTag(); View layout = li.inflate(R.layout.quickcmdsettings, null); GridView gridView = (GridView) layout.findViewById(R.id.iconselect); atOnce = (CheckBox) layout.findViewById(R.id.executeatonce); gridView.setAdapter(new IconAdapter(ctx)); TextView txt = (TextView) layout.findViewById(R.id.replacementcmd); txt.setText("'" + text.trim() + "'"); gridView.setOnItemClickListener(this); atOnce.setChecked(cmdIcon.atOnce); target = (ImageView) v; AlertDialog.Builder builder = new AlertDialog.Builder(ctx); dialog = builder.setTitle(R.string.title_change_commmand).setView(layout) .create(); dialog.show(); } else { Toast.makeText(ctx, ctx.getString(R.string.msg_no_cmd), Toast.LENGTH_SHORT).show(); } return true; }
Example 13
Source File: SearchListActivity.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_searchlist); shuosou_to_tv = (TextView) findViewById(R.id.shuosou_to_tv); isFromRefreshData = true; recommendedGroups = new ArrayList<Group>(); mPullToRefreshView = (PullToRefreshView) findViewById(R.id.main_pull_refresh_view); mPullToRefreshView.setOnHeaderRefreshListener(this); mPullToRefreshView.setOnFooterRefreshListener(this); searchDetailRelativeLayout = (RelativeLayout) findViewById(R.id.searchdetail_relativeLayout); mPhotoWall = (GridView) findViewById(R.id.photo_wall); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); int status = NetworkStatus.networkStatus(); if (status == NetworkStatus.NETWORK_STATUS_REACHABLE) { this.showNoNetworkView(false); } else if (status == NetworkStatus.NETWORK_STATUS_NOTREACHABLE) { this.showNoNetworkView(true); } mPhotoWall.setOnItemClickListener(this); }
Example 14
Source File: EmoticonFragment.java From BlackLight with GNU General Public License v3.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.emoticon_fragment, null); mGrid = (GridView) v.findViewById(R.id.emoticon_grid); // adapter mAdapter = new EmoticonAdapter(getActivity()); mGrid.setAdapter(mAdapter); // listener mGrid.setOnItemClickListener(this); return v; }
Example 15
Source File: SubRecommendedFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_sub_recommended, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_sub_recommended_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); ViewGroup parent = (ViewGroup) view.getParent(); if (parent != null) { parent.removeView(view); } sub_recommendedNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.sub_recommended_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_sub_recommended_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { sub_recommendedNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { sub_recommendedNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 16
Source File: HottestFragment.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_hottest, container, false); mPullToRefreshView = (PullToRefreshView) view.findViewById(R.id.fragment_pull_hottest_view); SubCategoryActivity activity = (SubCategoryActivity) this.getActivity(); mPullToRefreshView.setOnHeaderRefreshListener(activity); mPullToRefreshView.setOnFooterRefreshListener(activity); ViewGroup parent = (ViewGroup) view.getParent(); if (parent != null) { parent.removeView(view); } hottestNetWorkRelativeLayout = (RelativeLayout) view.findViewById(R.id.hottest_netWork_relativeLayout); mPhotoWall = (GridView) view.findViewById(R.id.fragment_hottest_gridview); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); mPhotoWall.setOnItemClickListener(this); if (this.mShowNoNetworkView) { hottestNetWorkRelativeLayout.setVisibility(View.VISIBLE); mPullToRefreshView.setVisibility(View.GONE); } else { hottestNetWorkRelativeLayout.setVisibility(View.GONE); mPullToRefreshView.setVisibility(View.VISIBLE); } return view; }
Example 17
Source File: SearchListActivity.java From wallpaper with GNU General Public License v2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_searchlist); shuosou_to_tv = (TextView) findViewById(R.id.shuosou_to_tv); isFromRefreshData = true; recommendedGroups = new ArrayList<Group>(); mPullToRefreshView = (PullToRefreshView) findViewById(R.id.main_pull_refresh_view); mPullToRefreshView.setOnHeaderRefreshListener(this); mPullToRefreshView.setOnFooterRefreshListener(this); searchDetailRelativeLayout = (RelativeLayout) findViewById(R.id.searchdetail_relativeLayout); mPhotoWall = (GridView) findViewById(R.id.photo_wall); mPhotoWall.setSelector(new ColorDrawable(Color.TRANSPARENT)); float width = (float) (WallWrapperEnvConfigure.getScreenWidth() / 3.0); mPhotoWall.setColumnWidth((int) width); int status = NetworkStatus.networkStatus(); if (status == NetworkStatus.NETWORK_STATUS_REACHABLE) { this.showNoNetworkView(false); } else if (status == NetworkStatus.NETWORK_STATUS_NOTREACHABLE) { this.showNoNetworkView(true); } mPhotoWall.setOnItemClickListener(this); }
Example 18
Source File: ImageFileActivity.java From school_shop with MIT License | 5 votes |
private void initView() { gridView = (GridView)findViewById(R.id.imageFile_act_fileGridView); initToolbar(getResources().getString(R.string.title_activity_picture_file)); helper = AlbumHelper.getHelper(); helper.init(getApplicationContext()); contentList = helper.getImagesBucketList(false); folderAdapter = new FolderAdapter(this,contentList); gridView.setAdapter(folderAdapter); dataList = new ArrayList<ImageItem>(); for(int i = 0; i<contentList.size();i++){ dataList.addAll(contentList.get(i).imageList); } gridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position,long arg3) { ShowFilePhotoActivity.dataList = (ArrayList<ImageItem>) ImageFileActivity.contentList.get(position).imageList; Intent intent = new Intent(); String folderName = ImageFileActivity.contentList.get(position).bucketName; intent.putExtra("folderName", folderName); intent.setClass(ImageFileActivity.this, ShowFilePhotoActivity.class); startActivityForResult(intent, 100); } }); }
Example 19
Source File: YangCongTouFragment.java From Android-EmotionInputDetector with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.emotion_gird, container, false); BaseAdapter adapter = new YangCongTouEmojiAdapter(mContext); GridView grid = (GridView) view.findViewById(R.id.grid); grid.setAdapter(adapter); grid.setOnItemClickListener(GlobalOnItemClickManager.getInstance().getOnItemClickListener(3)); return view; }
Example 20
Source File: MainActivity.java From Android-Lib-Pen with Apache License 2.0 | 5 votes |
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_main); final GridView gallery = (GridView)this.findViewById(R.id.gallery); gallery.setAdapter(this.adapter = new GalleryAdapter(this)); gallery.setOnItemClickListener(this); this.findViewById(R.id.create).setOnClickListener(this); }