Java Code Examples for android.view.View#setOnCreateContextMenuListener()

The following examples show how to use android.view.View#setOnCreateContextMenuListener() . 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: CommentViewHolder.java    From SteamGifts with MIT License 6 votes vote down vote up
public CommentViewHolder(View v, Context context, ICommentableFragment fragment) {
    super(v);
    this.fragment = fragment;
    this.context = context;

    commentAuthor = (TextView) v.findViewById(R.id.user);
    commentTime = (TextView) v.findViewById(R.id.time);
    commentRole = (TextView) v.findViewById(R.id.role);

    commentContent = (TextView) v.findViewById(R.id.content);
    commentContent.setMovementMethod(LinkMovementMethod.getInstance());

    commentMarker = v.findViewById(R.id.comment_marker);
    commentIndent = v.findViewById(R.id.comment_indent);
    commentImage = (ImageView) v.findViewById(R.id.author_avatar);

    tradeScoreDivider = v.findViewById(R.id.trade_divider);
    tradeScorePositive = (TextView) v.findViewById(R.id.trade_score_positive);
    tradeScoreNegative = (TextView) v.findViewById(R.id.trade_score_negative);

    v.setOnCreateContextMenuListener(this);
}
 
Example 2
Source File: LogRecyclerViewAdapter.java    From OpenLibre with GNU General Public License v3.0 6 votes vote down vote up
LogRowViewHolder(View view) {
    super(view);
    tv_date = (TextView) view.findViewById(R.id.tv_log_date);
    tv_time = (TextView) view.findViewById(R.id.tv_log_time);
    tv_glucose = (TextView) view.findViewById(R.id.tv_log_glucose);
    iv_unit = (ImageView) view.findViewById(R.id.iv_log_unit);
    iv_predictionArrow = (ImageView) view.findViewById(R.id.iv_log_prediction);
    view.setOnClickListener(this);

    // enable context menu only in developer mode
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(fragment.getContext());
    boolean developerMode = settings.getBoolean("pref_developer_mode", false);
    if (developerMode) {
        view.setOnCreateContextMenuListener(this);
    }
}
 
Example 3
Source File: ChannelSearchResultAdapter.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int position) {
    final Room searchResult = getItem(position);
    viewHolder.binding.name.setText(searchResult.getName());
    final String description = searchResult.getDescription();
    final String language = searchResult.getLanguage();
    if (TextUtils.isEmpty(description)) {
        viewHolder.binding.description.setVisibility(View.GONE);
    } else {
        viewHolder.binding.description.setText(description);
        viewHolder.binding.description.setVisibility(View.VISIBLE);
    }
    if (language == null || language.length() != 2) {
        viewHolder.binding.language.setVisibility(View.GONE);
    } else {
        viewHolder.binding.language.setText(language.toUpperCase(Locale.ENGLISH));
        viewHolder.binding.language.setVisibility(View.VISIBLE);
    }
    final Jid room = searchResult.getRoom();
    viewHolder.binding.room.setText(room != null ? room.asBareJid().toString() : "");
    AvatarWorkerTask.loadAvatar(searchResult, viewHolder.binding.avatar, R.dimen.avatar);
    final View root = viewHolder.binding.getRoot();
    root.setTag(searchResult);
    root.setOnClickListener(v -> listener.onChannelSearchResult(searchResult));
    root.setOnCreateContextMenuListener(this);
}
 
Example 4
Source File: PropertiesAdapter.java    From android-periodic-table with GNU General Public License v3.0 5 votes vote down vote up
public ViewHolder(View itemView) {
    super(itemView);

    mName = (TextView) itemView.findViewById(R.id.property_name);
    mValue = (TextView) itemView.findViewById(R.id.property_value);

    if (mValue != null) {
        mValue.setTypeface(mTypeface);

        itemView.setOnClickListener(this);
        itemView.setOnCreateContextMenuListener(this);
    }
}
 
Example 5
Source File: TransactionAdapter.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.view_w_transaction, parent, false);
        itemView.setOnCreateContextMenuListener(contextMenuListener);
        itemView.setOnClickListener(clickListener);
        return new MyViewHolder(itemView);
}
 
Example 6
Source File: IsotopesAdapter.java    From android-periodic-table with GNU General Public License v3.0 5 votes vote down vote up
public GroupViewHolder(View view) {
    super(view);

    mIndicator = (ExpandableIndicatorView) view.findViewById(R.id.group_indicator);
    mSymbol = (TextView) view.findViewById(R.id.property_symbol);
    mHalfLife = (TextView) view.findViewById(R.id.property_half_life);
    mAbundance = (TextView) view.findViewById(R.id.property_abundance);

    view.setOnClickListener(this);
    view.setOnCreateContextMenuListener(this);
}
 
Example 7
Source File: TokenAdapter.java    From Lunary-Ethereum-Wallet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.view_w_token, parent, false);

    itemView.setOnClickListener(listener);
    itemView.setOnCreateContextMenuListener(contextMenuListener);
    return new MyViewHolder(itemView);
}
 
Example 8
Source File: TransactionAdapter.java    From Lunary-Ethereum-Wallet with GNU General Public License v3.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (viewType == CONTENT) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.view_w_transaction, parent, false);
        itemView.setOnCreateContextMenuListener(contextMenuListener);
        itemView.setOnClickListener(clickListener);
        return new MyViewHolder(itemView);
    } else {
        return new AdRecyclerHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.view_w_transaction_ad, parent, false));
    }
}
 
Example 9
Source File: ListAdapter.java    From android-app with GNU General Public License v3.0 5 votes vote down vote up
ViewHolder(View itemView, OnItemClickListener listener) {
    super(itemView);
    this.listener = listener;

    title = itemView.findViewById(R.id.title);
    url = itemView.findViewById(R.id.url);
    favourite = itemView.findViewById(R.id.favourite);
    read = itemView.findViewById(R.id.read);
    readingTime = itemView.findViewById(R.id.estimatedReadingTime);

    itemView.setOnClickListener(this);
    itemView.setOnCreateContextMenuListener(this);
}
 
Example 10
Source File: WalletAdapter.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext())
            .inflate(R.layout.view_w_address, parent, false);

    itemView.setOnClickListener(listener);
    itemView.setOnCreateContextMenuListener(contextMenuListener);
    return new MyViewHolder(itemView);
}
 
Example 11
Source File: Fragment.java    From letv with Apache License 2.0 4 votes vote down vote up
public void registerForContextMenu(View view) {
    view.setOnCreateContextMenuListener(this);
}
 
Example 12
Source File: Dialog.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * @see Activity#registerForContextMenu(View)
 */
public void registerForContextMenu(@NonNull View view) {
    view.setOnCreateContextMenuListener(this);
}
 
Example 13
Source File: MicroBlogActivity.java    From YiBo with Apache License 2.0 4 votes vote down vote up
public void initComponent() {
	LinearLayout llRoot = (LinearLayout)findViewById(R.id.llRoot);
	LinearLayout llHeaderBase = (LinearLayout)findViewById(R.id.llHeaderBase);
	ThemeUtil.setRootBackground(llRoot);
	ThemeUtil.setSecondaryMicroBlogHeader(llHeaderBase);
	
	//资料头部
	LayoutInflater inflater = LayoutInflater.from(this);
	View headerView = inflater.inflate(R.layout.include_micro_blog_list_header, null);
	LinearLayout llProfileHeader = (LinearLayout)headerView.findViewById(R.id.llProfileHeader);
	TextView tvScreenName = (TextView)headerView.findViewById(R.id.tvScreenName);
	ImageView ivVerify = (ImageView)headerView.findViewById(R.id.ivVerify);
	TextView tvImpress = (TextView)headerView.findViewById(R.id.tvImpress);
	ImageView ivMoreDetail = (ImageView)headerView.findViewById(R.id.ivMoreDetail);
	ThemeUtil.setHeaderProfile(llProfileHeader);
	int highlight = theme.getColor("highlight");
	tvScreenName.setTextColor(highlight);
	ivVerify.setImageDrawable(theme.getDrawable("icon_verification"));
	tvImpress.setTextColor(theme.getColor("content"));
	ivMoreDetail.setBackgroundDrawable(theme.getDrawable("icon_more_detail"));
	
	//微博内容
	TextView tvText = (TextView)headerView.findViewById(R.id.tvText);
	LinearLayout llThumbnailShape = (LinearLayout)headerView.findViewById(R.id.llThumbnailShape);
	TextView tvImageInfo = (TextView)headerView.findViewById(R.id.tvImageInfo);
	LinearLayout llRetweet = (LinearLayout)headerView.findViewById(R.id.llRetweet);
	TextView tvRetweetText = (TextView)headerView.findViewById(R.id.tvRetweetText);
	LinearLayout llRetweetThumbnailShape = (LinearLayout)headerView.findViewById(R.id.llRetweetThumbnailShape);
	TextView tvRetweetImageInfo = (TextView)headerView.findViewById(R.id.tvRetweetImageInfo);
	ImageView ivRetweetLocation = (ImageView)headerView.findViewById(R.id.ivRetweetLocation);
	TextView tvRetweetLocation = (TextView)headerView.findViewById(R.id.tvRetweetLocation);
	TextView tvRetweetCreatedAt = (TextView)headerView.findViewById(R.id.tvRetweetCreatedAt);
	TextView tvRetweetSource = (TextView)headerView.findViewById(R.id.tvRetweetSource);
	ImageView ivLocation = (ImageView)headerView.findViewById(R.id.ivLocation);
	TextView tvLocation = (TextView)headerView.findViewById(R.id.tvLocation);
	TextView tvCreatedAt = (TextView)headerView.findViewById(R.id.tvCreatedAt);
	TextView tvSource = (TextView)headerView.findViewById(R.id.tvSource);
	TextView tvRetweetCount = (TextView)headerView.findViewById(R.id.tvRetweetCount);
	TextView tvCommentCount = (TextView)headerView.findViewById(R.id.tvCommentCount);
	ImageView ivLineSeperator = (ImageView)headerView.findViewById(R.id.ivLineSeperator);
	
	tvText.setTextColor(theme.getColor("content"));
	ColorStateList selectorTextLink = theme.getColorStateList("selector_text_link");
	tvText.setLinkTextColor(selectorTextLink);
	Drawable shapeAttachment = theme.getDrawable("shape_attachment");
	llThumbnailShape.setBackgroundDrawable(shapeAttachment);
	int quote = theme.getColor("quote");
    tvImageInfo.setTextColor(quote);
    llRetweet.setBackgroundDrawable(theme.getDrawable("bg_retweet_frame"));
    int padding10 = theme.dip2px(10);
    llRetweet.setPadding(padding10, padding10, padding10, theme.dip2px(6));        
    tvRetweetText.setTextColor(quote);
    tvRetweetText.setLinkTextColor(selectorTextLink);
    llRetweetThumbnailShape.setBackgroundDrawable(shapeAttachment);
    tvRetweetImageInfo.setTextColor(quote);
    Drawable iconLocation = theme.getDrawable("icon_location");
    ivRetweetLocation.setImageDrawable(iconLocation);
    tvRetweetLocation.setTextColor(quote);
    tvRetweetCreatedAt.setTextColor(quote);
    tvRetweetSource.setTextColor(quote);
    ivLocation.setImageDrawable(iconLocation);
    tvLocation.setTextColor(quote);
    tvCreatedAt.setTextColor(quote);
    tvSource.setTextColor(quote);       
    
    int emphasize = theme.getColor("emphasize");
    tvRetweetCount.setTextColor(emphasize);
    tvCommentCount.setTextColor(emphasize);
    ivLineSeperator.setBackgroundDrawable(theme.getDrawable("line_comment_of_status_normal"));
    
    //工具条
    LinearLayout llToolbar = (LinearLayout)findViewById(R.id.llToolbar);
    Button btnComment = (Button)findViewById(R.id.btnComment);
    Button btnRetweet = (Button)findViewById(R.id.btnRetweet);
    Button btnFavorite = (Button)findViewById(R.id.btnFavorite);
    Button btnShare = (Button)findViewById(R.id.btnShare);
    Button btnMore = (Button)findViewById(R.id.btnMore);
    llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar"));
    btnComment.setBackgroundDrawable(theme.getDrawable("selector_toolbar_comment"));
    btnRetweet.setBackgroundDrawable(theme.getDrawable("selector_toolbar_retweet"));
    btnFavorite.setBackgroundDrawable(theme.getDrawable("selector_toolbar_favorite_add"));
    btnShare.setBackgroundDrawable(theme.getDrawable("selector_toolbar_share"));
    btnMore.setBackgroundDrawable(theme.getDrawable("selector_toolbar_more"));
    
	lvCommentsOfStatus = (ListView) this.findViewById(R.id.lvCommentsOfStatus);
	ThemeUtil.setListViewStyle(lvCommentsOfStatus);
	lvCommentsOfStatus.addHeaderView(headerView);
    setBack2Top(lvCommentsOfStatus);
    
    //注册上下文菜单
    View statusView = this.findViewById(R.id.llStatus);
    statusContextMenuListener = new MicroBlogStatusContextMenuListener(status);
    statusView.setOnCreateContextMenuListener(statusContextMenuListener);

    autoLoadMoreListener = new AutoLoadMoreListener();
}
 
Example 14
Source File: Fragment.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public void unregisterForContextMenu(View view)
{
    view.setOnCreateContextMenuListener(null);
}
 
Example 15
Source File: SavedListsAdapter.java    From TinyList with GNU General Public License v2.0 4 votes vote down vote up
public ViewHolder(View itemView) {
    super(itemView);
    ButterKnife.bind(this, itemView);
    itemView.setOnCreateContextMenuListener(this);
}
 
Example 16
Source File: SearchClickListener.java    From aedict with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Registers the object to given view.
 * 
 * @param view
 *            the view
 * @return this
 */
public SearchClickListener registerTo(final View view) {
	view.setOnClickListener(this);
	new FocusVisual().registerTo(view);
	view.setOnCreateContextMenuListener(this);
	return this;
}
 
Example 17
Source File: Fragment.java    From droidel with Apache License 2.0 2 votes vote down vote up
/**
 * Prevents a context menu to be shown for the given view. This method will
 * remove the {@link OnCreateContextMenuListener} on the view.
 * 
 * @see #registerForContextMenu(View)
 * @param view The view that should stop showing a context menu.
 */
public void unregisterForContextMenu(View view) {
    view.setOnCreateContextMenuListener(null);
}
 
Example 18
Source File: Fragment.java    From CodenameOne with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Registers a context menu to be shown for the given view (multiple views
 * can show the context menu). This method will set the
 * {@link OnCreateContextMenuListener} on the view to this fragment, so
 * {@link #onCreateContextMenu(ContextMenu, View, ContextMenuInfo)} will be
 * called when it is time to show the context menu.
 * 
 * @see #unregisterForContextMenu(View)
 * @param view The view that should show a context menu.
 */
public void registerForContextMenu(View view) {
    view.setOnCreateContextMenuListener(this);
}
 
Example 19
Source File: Fragment.java    From droidel with Apache License 2.0 2 votes vote down vote up
/**
 * Registers a context menu to be shown for the given view (multiple views
 * can show the context menu). This method will set the
 * {@link OnCreateContextMenuListener} on the view to this fragment, so
 * {@link #onCreateContextMenu(ContextMenu, View, ContextMenuInfo)} will be
 * called when it is time to show the context menu.
 * 
 * @see #unregisterForContextMenu(View)
 * @param view The view that should show a context menu.
 */
public void registerForContextMenu(View view) {
    view.setOnCreateContextMenuListener(this);
}
 
Example 20
Source File: Fragment.java    From droidel with Apache License 2.0 2 votes vote down vote up
/**
 * Registers a context menu to be shown for the given view (multiple views
 * can show the context menu). This method will set the
 * {@link OnCreateContextMenuListener} on the view to this fragment, so
 * {@link #onCreateContextMenu(ContextMenu, View, ContextMenuInfo)} will be
 * called when it is time to show the context menu.
 * 
 * @see #unregisterForContextMenu(View)
 * @param view The view that should show a context menu.
 */
public void registerForContextMenu(View view) {
    view.setOnCreateContextMenuListener(this);
}