List of usage examples for android.view View showContextMenu
public boolean showContextMenu()
From source file:Main.java
/** * Performs button-related actions during a touch down event. * * @param event The event.//from w ww .j av a2 s . c o m * @return True if the down was consumed. */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) private static boolean performButtonActionOnTouchDown(View v, MotionEvent event) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { if ((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0) { if (v.showContextMenu()) { return true; } } } return false; }
From source file:tinygsn.gui.android.ActivityPullData.java
public void select_server(View view) { view.showContextMenu(); }
From source file:org.chaos.fx.cnbeta.details.ImageFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ButterKnife.bind(this, view); mUrl = getArguments().getString(KEY_IMAGE_URL); ViewCompat.setTransitionName(mPhotoView, mUrl); loadImage();// ww w .ja v a 2 s . c o m mPhotoView.setOnOutsidePhotoTapListener(new OnOutsidePhotoTapListener() { @Override public void onOutsidePhotoTap(ImageView imageView) { if (getActivity() != null) { getActivity().supportFinishAfterTransition(); } } }); mPhotoView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { registerForContextMenu(v); v.showContextMenu(); unregisterForContextMenu(v); return true; } }); }
From source file:com.deange.textfaker.ui.activity.MessageActivity.java
@Override public boolean onLongClick(final View v) { return v.showContextMenu(); }
From source file:cc.softwarefactory.lokki.android.fragments.PlacesFragment.java
private void setListAdapter() { Log.d(TAG, "setListAdapter"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, R.layout.places_row_layout, placesList) { @Override/*from ww w. j a v a2 s. c o m*/ public View getView(int position, View unusedView, ViewGroup parent) { View convertView = getActivity().getLayoutInflater().inflate(R.layout.places_row_layout, parent, false); AQuery aq = new AQuery(getActivity(), convertView); final String placeName = getItem(position); aq.id(R.id.place_name).text(placeName); aq.id(R.id.places_context_menu_button).clicked(new View.OnClickListener() { @Override public void onClick(View v) { v.showContextMenu(); } }); Log.d(TAG, "Plane name: " + placeName); Log.d(TAG, "peopleInsidePlace? " + peopleInsidePlace.has(placeName)); if (peopleInsidePlace.has(placeName)) { // People are inside this place Log.d(TAG, "Inside loop"); try { JSONArray people = peopleInsidePlace.getJSONArray(placeName); LinearLayout avatarRow = (LinearLayout) convertView.findViewById(R.id.avatar_row); avatarRow.removeAllViewsInLayout(); // Deletes old avatars, if any. for (int i = 0; i < people.length(); i++) { final String email = people.getString(i); if (MainApplication.iDontWantToSee.has(email)) { continue; } RoundedImageView image = createAvatar(email); if (MainApplication.avatarCache.get(email) != null) { image.setImageBitmap(MainApplication.avatarCache.get(email)); } else { Log.d(TAG, "Avatar not in cache, email: " + email); image.setImageResource(R.drawable.default_avatar); } image.setContentDescription(email); avatarRow.addView(image); } } catch (Exception ex) { Log.d(TAG, "Error in adding avatars"); } } return convertView; } }; listView.setAdapter(adapter); }
From source file:info.staticfree.android.units.Units.java
public boolean onLongClick(View v) { switch (v.getId()) { case R.id.result: v.showContextMenu(); return true; }/*from w ww . j a va 2 s . co m*/ return false; }
From source file:com.android.mms.ui.MessageListItem.java
private void setOnClickListener(final MessageItem msgItem) { switch (msgItem.mAttachmentType) { case WorkingMessage.VCARD: case WorkingMessage.VCAL: case WorkingMessage.IMAGE: case WorkingMessage.VIDEO: mImageView.setOnClickListener(new OnClickListener() { @Override// w ww . j av a 2 s . c o m public void onClick(View v) { sendMessage(msgItem, MSG_LIST_PLAY); } }); mImageView.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { return v.showContextMenu(); } }); break; default: mImageView.setOnClickListener(null); break; } }
From source file:org.brandroid.openmanager.fragments.ContentFragment.java
@Override public boolean onLongClick(View v) { if (v.equals(mGrid)) { if (v.getTag() != null && v.getTag() instanceof MotionEvent) { MotionEvent lastEvent = (MotionEvent) v.getTag(); int x = (int) Math.floor(lastEvent.getX()); int y = (int) Math.floor(lastEvent.getY()); return createContextMenu(mPath, mGrid, mGrid, 0, x, y); } else/*from w ww. ja v a 2 s.com*/ return v.showContextMenu(); } return false; }
From source file:uk.org.ngo.squeezer.NowPlayingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v; if (mFullHeightLayout) { v = inflater.inflate(R.layout.now_playing_fragment_full, container, false); artistText = (TextView) v.findViewById(R.id.artistname); nextButton = (ImageButton) v.findViewById(R.id.next); prevButton = (ImageButton) v.findViewById(R.id.prev); shuffleButton = (ImageButton) v.findViewById(R.id.shuffle); repeatButton = (ImageButton) v.findViewById(R.id.repeat); currentTime = (TextView) v.findViewById(R.id.currenttime); totalTime = (TextView) v.findViewById(R.id.totaltime); seekBar = (SeekBar) v.findViewById(R.id.seekbar); btnContextMenu = (ImageView) v.findViewById(R.id.context_menu); btnContextMenu.setOnCreateContextMenuListener(this); btnContextMenu.setOnClickListener(new OnClickListener() { @Override//ww w. j av a 2 s . co m public void onClick(View v) { v.showContextMenu(); } }); } else { v = inflater.inflate(R.layout.now_playing_fragment_mini, container, false); mProgressBar = (ProgressBar) v.findViewById(R.id.progressbar); } albumArt = (ImageView) v.findViewById(R.id.album); trackText = (TextView) v.findViewById(R.id.trackname); albumText = (TextView) v.findViewById(R.id.albumname); playPauseButton = (ImageButton) v.findViewById(R.id.pause); // Marquee effect on TextViews only works if they're focused. trackText.requestFocus(); playPauseButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mService == null) { return; } if (isConnected()) { Log.v(TAG, "Pause..."); mService.togglePausePlay(); } else { // When we're not connected, the play/pause // button turns into a green connect button. onUserInitiatesConnect(); } } }); if (mFullHeightLayout) { /* * TODO: Simplify these following the notes at * http://developer.android.com/resources/articles/ui-1.6.html. * Maybe. because the TextView resources don't support the * android:onClick attribute. */ nextButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mService == null) { return; } mService.nextTrack(); } }); prevButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mService == null) { return; } mService.previousTrack(); } }); shuffleButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mService == null) { return; } mService.toggleShuffle(); } }); repeatButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mService == null) { return; } mService.toggleRepeat(); } }); seekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() { Song seekingSong; // Update the time indicator to reflect the dragged thumb // position. @Override public void onProgressChanged(SeekBar s, int progress, boolean fromUser) { if (fromUser) { currentTime.setText(Util.formatElapsedTime(progress)); } } // Disable updates when user drags the thumb. @Override public void onStartTrackingTouch(SeekBar s) { seekingSong = getCurrentSong(); updateSeekBar = false; } // Re-enable updates. If the current song is the same as when // we started seeking then jump to the new point in the track, // otherwise ignore the seek. @Override public void onStopTrackingTouch(SeekBar s) { Song thisSong = getCurrentSong(); updateSeekBar = true; if (seekingSong == thisSong) { setSecondsElapsed(s.getProgress()); } } }); } else { // Clicking on the layout goes to NowPlayingActivity. v.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { NowPlayingActivity.show(mActivity); } }); } return v; }
From source file:com.gigabytedevelopersinc.app.calculator.Calculator.java
void fillData() { Cursor c = dbAdapter.fetchAllMemories(); startManagingCursor(c);//from ww w. ja va 2 s.c o m String[] from = new String[] { DbAdapter.KEY_EXP, DbAdapter.KEY_RESULT }; int[] to = new int[] { R.id.text1, R.id.text2 }; SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.history_row, c, from, to); memoryList.setAdapter(notes); registerForContextMenu(memoryList); memoryList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { view.showContextMenu(); } }); c = dbAdapter.fetchAllHistories(); startManagingCursor(c); from = new String[] { DbAdapter.KEY_EXP, DbAdapter.KEY_RESULT }; to = new int[] { R.id.text1, R.id.text2 }; notes = new SimpleCursorAdapter(this, R.layout.history_row, c, from, to); historyList.setAdapter(notes); registerForContextMenu(historyList); historyList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { view.showContextMenu(); } }); try { if (page_no == 2) c = dbAdapter.fetchAllFavs(1); else c = dbAdapter.fetchAllFavs(2); startManagingCursor(c); from = new String[] { DbAdapter.KEY_EXP, DbAdapter.KEY_RESULT }; to = new int[] { R.id.text1, R.id.text2 }; notes = new SimpleCursorAdapter(this, R.layout.history_row, c, from, to); favList.setAdapter(notes); registerForContextMenu(favList); favList.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { view.showContextMenu(); } }); } catch (Exception exe) { // } }