Java Code Examples for android.widget.GridView#setOnItemLongClickListener()
The following examples show how to use
android.widget.GridView#setOnItemLongClickListener() .
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: VideoActivity.java From GreenDamFileExploere with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video); mViewNothing = findViewById(R.id.nothing); mGridView = (GridView) findViewById(R.id.mVideoGrideView); mAdapter = new VideoGridViewAdapter(this, mVideos, mGridView); mGridView.setAdapter(mAdapter); mGridView.setOnItemClickListener(this); mGridView.setOnItemLongClickListener(this); mThread = new VideoLoadThread(); mThread.start(); }
Example 2
Source File: ImageWallActivity.java From GreenDamFileExploere with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_wall); mDialog = UiUtil.createLoadingDialog(this, "你的图片好多..."); mViewNoting = findViewById(R.id.nothing); mContentResolver = getContentResolver(); mGridView = (GridView) findViewById(R.id.mListViewImageWall); mAdapter = new ImageWallGridAdapter(ImageWallActivity.this, mImages, mGridView); mGridView.setAdapter(mAdapter); mGridView.setOnItemClickListener(this); mGridView.setOnItemLongClickListener(this); mThread = new ImageLoadThread(); mThread.start(); }
Example 3
Source File: FloatWindow.java From AdDetector with Apache License 2.0 | 6 votes |
public FloatWindow(final Context context) { super(context); LayoutInflater.from(context).inflate(R.layout.float_folder, this); View view = findViewById(R.id.big_window_layout); viewWidth = view.getLayoutParams().width; viewHeight = view.getLayoutParams().height; Button close = (Button) findViewById(R.id.finishBtn); close.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // close float window,stop service. MyWindowManager.removeBigWindow(context); Intent intent = new Intent(getContext(), FloatWindowService.class); context.stopService(intent); } }); appWall = (GridView) findViewById(R.id.app_wall); List<AppInfo> apps = getAllInstalledSysApps(context); AppWallAdapter adapter = new AppWallAdapter(context, 0, apps, appWall); appWall.setAdapter(adapter); appWall.setOnItemClickListener(new ItemClickListener() ); appWall.setOnItemLongClickListener(new ItemLongClickListener()); }
Example 4
Source File: DateGridFragment.java From iSCAU-Android with GNU General Public License v3.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { gridView = (GridView) inflater.inflate(R.layout.date_grid_fragment, container, false); // Client normally needs to provide the adapter and onItemClickListener // before the fragment is attached to avoid complex crash due to // fragment life cycles if (gridAdapter != null) { gridView.setAdapter(gridAdapter); } if (onItemClickListener != null) { gridView.setOnItemClickListener(onItemClickListener); } if(onItemLongClickListener != null) { gridView.setOnItemLongClickListener(onItemLongClickListener); } return gridView; }
Example 5
Source File: MarkerPicker.java From Androzic with GNU General Public License v3.0 | 6 votes |
@NonNull @SuppressLint("InflateParams") @Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.markericon_name)); View view = getActivity().getLayoutInflater().inflate(R.layout.act_markericon, null); builder.setView(view); GridView grid = (GridView) view.findViewById(R.id.marker_grid); grid.setAdapter(new ImageAdapter(getActivity(), icons)); grid.setOnItemClickListener(this); grid.setOnItemLongClickListener(this); return builder.create(); }
Example 6
Source File: MenuGrid.java From commcare-android with Apache License 2.0 | 5 votes |
@Override protected void initViewAndAdapter(String menuId) { adapterView = (GridView)activity.findViewById(R.id.grid_menu_grid); adapterView.setOnItemLongClickListener(this); adapter = new GridMenuAdapter(activity, CommCareApplication.instance().getCommCarePlatform(), menuId); }
Example 7
Source File: ContentFragment.java From droid-stealth with GNU General Public License v2.0 | 5 votes |
/** * Creates a new content view and sets its listeners * * @param inflater * @param container * @param savedInstanceState * @return */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View content = inflater.inflate(R.layout.fragment_content, container, false); FontManager.handleFontTags(content); mGridView = (GridView) content.findViewById(R.id.content_container); // mGridView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); mGridView.setOnItemClickListener(this); mGridView.setOnItemLongClickListener(this); // temporarily remove the bottom bar content.findViewById(R.id.content_bottombar).setVisibility(View.GONE); mContentManager = ContentManagerFactory.getInstance( getActivity(), FileIndex.get()); mActionManager = new ActionManager(mContentManager); mAdapter = new ContentAdapter(mContentManager, mGridView); mAdapter.setAdapterChangedListener(this); mContentManager.addContentChangedListener(mAdapter); mGridView.setAdapter(mAdapter); mObserver = new UnlockObserver(DirectoryManager.unlocked().getPath()); mObserver.addListener(mAdapter); return content; }
Example 8
Source File: MarkerPickerActivity.java From Androzic with GNU General Public License v3.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.act_markericon); names = new ArrayList<>(); icons = new ArrayList<>(); Androzic application = Androzic.getApplication(); File dir = new File(application.markerPath); List<File> result = new ArrayList<>(); File[] files = dir.listFiles(iconFilter); if (files != null) result.addAll(Arrays.asList(files)); Collections.sort(result); for (File file : result) { Bitmap b = BitmapFactory.decodeFile(file.getAbsolutePath()); if (b != null) { names.add(file.getName()); icons.add(b); } } GridView grid = (GridView) findViewById(R.id.marker_grid); grid.setAdapter(new ImageAdapter(this, icons)); grid.setOnItemClickListener(this); grid.setOnItemLongClickListener(this); }
Example 9
Source File: CollectionGridAdapter.java From DistroHopper with GNU General Public License v3.0 | 4 votes |
@Override public View getView (int position, View view, ViewGroup parent) { LensSearchResultCollection coll = this.getItem (position); boolean show = true; if (view == null) view = LayoutInflater.from (this.getContext ()).inflate (R.layout.widget_dash_lens_result_collection, parent, false); TextView tvLabel = (TextView) view.findViewById (R.id.tvLabel); GridView gvResults = (GridView) view.findViewById (R.id.gvResults); gvResults.setColumnWidth(Math.round((80 // 80 is the minimum + this.dashIconWidth) * this.displayDensity)); // Adjust for the screen's pixel density tvLabel.setText (coll.getLens ().getName ()); tvLabel.setTextColor (view.getResources ().getColor (HomeActivity.theme.dash_applauncher_text_colour)); tvLabel.setShadowLayer (5, 2, 2, view.getResources ().getColor (HomeActivity.theme.dash_applauncher_text_shadow_colour)); List<LensSearchResult> results = coll.getResults (); if (results == null) { results = new ArrayList<LensSearchResult> (); Exception ex = coll.getException (); if (ex != null) { if (ex instanceof UnknownHostException || ex instanceof SocketException) { ConnectivityManager connectivityManager = (ConnectivityManager) this.getContext ().getSystemService (Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo (); if (! (networkInfo != null && networkInfo.isConnected ())) show = false; } LensSearchResult error = new LensSearchResult (this.getContext (), ex.getClass ().getSimpleName (), "error://" + ex.getMessage (), this.getContext ().getResources ().getDrawable (R.drawable.dash_search_lens_error)); results.add (error); } } if (show) { gvResults.setAdapter (new GridAdapter (this.getContext (), results, this.displayDensity, this.dashIconWidth)); gvResults.setOnItemClickListener (new LensSearchResultClickListener (coll.getLens ())); gvResults.setOnItemLongClickListener (new LensSearchResultLongClickListener (coll.getLens ())); view.setVisibility (View.VISIBLE); } else { view.setVisibility (View.GONE); } view.setTag (coll); return view; }
Example 10
Source File: PictureElement.java From sana.mobile with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * {@inheritDoc} */ @Override protected View createView(Context c) { imageGrid = new GridView(c); Log.i(TAG, "Looking up for encounter: " + getProcedure().getInstanceUri()); String procedureId = getProcedure().getInstanceUri().getLastPathSegment(); Log.w(TAG, "PictureELement: Encounter id " + procedureId); String whereStr; if (!UUIDUtil.isValid(procedureId)) whereStr = ImageSQLFormat.ENCOUNTER_ID + " = ? AND " + ImageSQLFormat.ELEMENT_ID + " = ? AND " + ImageSQLFormat.FILE_VALID + " = ?"; else whereStr = ImageSQLFormat.ENCOUNTER_ID + " = '?' AND " + ImageSQLFormat.ELEMENT_ID + " = ? AND " + ImageSQLFormat.FILE_VALID + " = ?"; Cursor cursor = c.getContentResolver().query( SanaDB.ImageSQLFormat.CONTENT_URI, new String[]{ImageSQLFormat._ID}, whereStr, new String[]{procedureId, id, "1"}, null); // HAXMODE -- if we don't do this we leak the Cursor if (c instanceof Activity) { ((Activity) c).startManagingCursor(cursor); } imageAdapter = new ScalingImageAdapter(c, cursor, THUMBNAIL_SCALE_FACTOR); imageGrid.setAdapter(imageAdapter); imageGrid.setNumColumns(3); imageGrid.setVerticalSpacing(5); imageGrid.setPadding(5, 0, 0, 0); imageGrid.setOnItemClickListener(this); imageGrid.setOnItemLongClickListener(this); //imageGrid.setTranscriptMode(imageGrid.TRANSCRIPT_MODE_ALWAYS_SCROLL); cameraButton = new Button(c); cameraButton.setText(R.string.btn_add_photo); cameraButton.setOnClickListener(this); imageReview = new ImagePreviewDialog(c); LinearLayout picContainer = new LinearLayout(c); picContainer.setOrientation(LinearLayout.VERTICAL); if (question == null) { question = c.getString(R.string.question_standard_picture_element); } //Set question TextView tv = new TextView(c); tv.setText(String.format("%s: %s", id, question)); tv.setGravity(Gravity.CENTER); tv.setTextAppearance(c, android.R.style.TextAppearance_Medium); //Add to layout picContainer.addView(tv, new LinearLayout.LayoutParams(-1, -1, 0.1f)); //picContainer.addView(imageView, new LinearLayout.LayoutParams(-1,-1,0.1f)); //Add button picContainer.addView(cameraButton, new LinearLayout.LayoutParams(-1, -1, 0.1f)); picContainer.addView(imageGrid, new LinearLayout.LayoutParams(-1, 210)); //LayoutParams(-1,-1,0.8f)); picContainer.setWeightSum(1.0f); return picContainer; }