Java Code Examples for android.widget.TextView.setOnLongClickListener()

The following are Jave code examples for showing how to use setOnLongClickListener() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Auto.js   File: FunctionsKeyboardView.java   View Source Code Vote up 6 votes
ModuleViewHolder(View itemView) {
    super(itemView);
    mTextView = (TextView) itemView;
    mTextView.setOnClickListener(v -> {
        if (mModule == null)
            return;
        setSelectedModule(mModule, mTextView);
    });
    mTextView.setOnLongClickListener(v -> {
        if (mClickCallback != null) {
            mClickCallback.onModuleLongClick(mModule);
            return true;
        }
        return false;
    });
}
 
Example 2
Project: Auto.js   File: FunctionsKeyboardView.java   View Source Code Vote up 6 votes
PropertyViewHolder(View itemView) {
    super(itemView);
    mTextView = (TextView) itemView;
    mTextView.setOnLongClickListener(v -> {
        if (mClickCallback != null) {
            mClickCallback.onPropertyLongClick(mSelectedModule, mProperty);
            return true;
        }
        return false;
    });
    mTextView.setOnClickListener(v -> {
        if (mClickCallback != null) {
            mClickCallback.onPropertyClick(mSelectedModule, mProperty);
        }
    });
}
 
Example 3
Project: BookyMcBookface   File: GetBooksActivity.java   View Source Code Vote up 6 votes
private void displayWeb(String name, String url, boolean first) {
    TextView v = new TextView(this);
    v.setTextSize(24);
    v.setTextColor(Color.BLUE);
    v.setPadding(16,16,8,8);
    v.setText(name);
    v.setTag(url);
    v.setOnClickListener(this);
    v.setOnLongClickListener(this);
    if (first) {
        list.addView(v, 0);
    } else {
        list.addView(v);
    }

}
 
Example 4
Project: decoy   File: ChatRoomMsgViewHolderBaseText.java   View Source Code Vote up 6 votes
@Override
protected void bindContentView() {
    layoutDirection();

    TextView bodyTextView = findViewById(R.id.nim_message_item_text_body);
    bodyTextView.setTextColor(isReceivedMessage() ? Color.BLACK : Color.WHITE);
    bodyTextView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onItemClick();
        }
    });
    MoonUtil.identifyFaceExpression(NimUIKit.getContext(), bodyTextView, getDisplayText(), ImageSpan.ALIGN_BOTTOM);
    bodyTextView.setMovementMethod(LinkMovementMethod.getInstance());
    bodyTextView.setOnLongClickListener(longClickListener);
}
 
Example 5
Project: yyox   File: AbstractHolder.java   View Source Code Vote up 5 votes
/**
 * 记载附件消息
 *
 * @param message
 * @param tvFileName
 * @param progressBar
 * @param failLayout
 */
protected final void loadFileData(IMMessage message, TextView tvFileName, ProgressBar progressBar, RelativeLayout failLayout) {
    if (progressBar != null)
        progressBar.setVisibility(View.GONE);
    if (failLayout != null)
        failLayout.setBackgroundColor(Color.TRANSPARENT);
    if (tvFileName != null) {
        tvFileName.setText(Html.fromHtml("<a href=\"\">" + message.getUpload().getName() + "</a>"));
        tvFileName.setOnClickListener(new MessageFileClickListener(context, message));
        tvFileName.setOnLongClickListener(new MessageFileLongClickListener(context, message));
    }
}
 
Example 6
Project: KaldiAndroid   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // UI elements initialization
    mFrameLayoutBtn = (FrameLayout) findViewById(R.id.frameLayout_recordBtn);
    mRecordProgress = (FrameLayout) findViewById(R.id.record_progress);
    mCurrentFileTextView = (TextView) findViewById(R.id.textView_audioPath);
    mCurrentFileTextView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            // long click clear the current audio, so kaldi will
            // the default audio
            mCurrentFileName = null;
            mCurrentFileTextView.setText("");
            return true;
        }
    });
    mResultTextView = (TextView) findViewById(R.id.result);

    // Ask for permission (API >= 23)
    String[] requestedPermissions = new String[]{
                Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.RECORD_AUDIO
    };
    int writePermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    int recordPermission = ActivityCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO);

    mKaldi = new Kaldi(this);
    if(writePermission == PackageManager.PERMISSION_GRANTED && recordPermission == PackageManager.PERMISSION_GRANTED) {
        //mKaldi.init();
    } else {
        ActivityCompat.requestPermissions(this, requestedPermissions, 4);
    }
}
 
Example 7
Project: BlackList   File: JournalCursorAdapter.java   View Source Code Vote up 5 votes
ViewHolder(Context context, ImageView iconImageView, TextView senderTextView,
           TextView textTextView, TextView dateTextView,
           TextView timeTextView, CheckBox checkBox, View dateLayout,
           CheckableLinearLayout contentLayout) {
    this.record = null;
    this.itemId = 0;
    this.iconImageView = iconImageView;
    this.senderTextView = senderTextView;
    this.textTextView = textTextView;
    this.dateTextView = dateTextView;
    this.timeTextView = timeTextView;
    this.checkBox = checkBox;
    this.dateLayout = dateLayout;
    this.contentLayout = contentLayout;

    Utils.scaleViewOnTablet(context, checkBox, R.dimen.iconScale);
    Utils.scaleViewOnTablet(context, iconImageView, R.dimen.iconScale);

    contentLayout.setTag(this);
    textTextView.setTag(this);

    // add on click listeners
    contentLayout.setOnClickListener(onClickListener);
    contentLayout.setOnLongClickListener(onLongClickListener);
    if (foldSMSText) {
        textTextView.setOnLongClickListener(onLongClickListener);
        textTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setTextUnfolded(!isTextUnfolded());
            }
        });
    }
}
 
Example 8
Project: OpenHub   File: ViewUtils.java   View Source Code Vote up 5 votes
public static void setLongClickCopy(@NonNull TextView textView) {
    textView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            TextView text = (TextView) v;
            AppUtils.copyToClipboard(text.getContext(), text.getText().toString());
            return true;
        }
    });
}
 
Example 9
Project: boohee_v5.6   File: BaseTimelineAdapter.java   View Source Code Vote up 5 votes
protected void initTimeAndBody(TextView timeText, TextView bodyText, final Post post) {
    timeText.setText(DateHelper.timezoneFormat(post.created_at, "MM-dd HH:mm"));
    bodyText.setOnLongClickListener(new OnLongClickListener() {
        public boolean onLongClick(View v) {
            TimeLineUtility.copyText(BaseTimelineAdapter.this.activity, post.body);
            Helper.showToast(BaseTimelineAdapter.this.activity, (CharSequence) "内容已复制到剪切板");
            return true;
        }
    });
    TimeLineUtility.addLinksWithShowMore(bodyText, post);
}
 
Example 10
Project: decoy   File: ChatRoomMsgViewHolderText.java   View Source Code Vote up 5 votes
@Override
protected void bindContentView() {
    TextView bodyTextView = findViewById(com.netease.nim.uikit.R.id.nim_message_item_text_body);
    bodyTextView.setTextColor(Color.BLACK);
    layoutDirection();
    MoonUtil.identifyFaceExpression(NimUIKit.getContext(), bodyTextView, getDisplayText(), ImageSpan.ALIGN_BOTTOM);
    bodyTextView.setMovementMethod(LinkMovementMethod.getInstance());
    bodyTextView.setOnLongClickListener(longClickListener);
}
 
Example 11
Project: FlickLauncher   File: Hotseat.java   View Source Code Vote up 5 votes
void resetLayout() {
    mContent.removeAllViewsInLayout();

    if (!FeatureFlags.NO_ALL_APPS_ICON) {
        // Add the Apps button
        Context context = getContext();
        int allAppsButtonRank = mLauncher.getDeviceProfile().inv.getAllAppsButtonRank();

        LayoutInflater inflater = LayoutInflater.from(context);
        TextView allAppsButton = (TextView)
                inflater.inflate(R.layout.all_apps_button, mContent, false);
        Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);

        mLauncher.resizeIconDrawable(d);
        int scaleDownPx = getResources().getDimensionPixelSize(R.dimen.all_apps_button_scale_down);
        Rect bounds = d.getBounds();
        d.setBounds(bounds.left, bounds.top + scaleDownPx / 2, bounds.right - scaleDownPx,
                bounds.bottom - scaleDownPx / 2);
        allAppsButton.setCompoundDrawables(null, d, null, null);

        allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
        allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
        if (mLauncher != null) {
            mLauncher.setAllAppsButton(allAppsButton);
            allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
            allAppsButton.setOnClickListener(mLauncher);
            allAppsButton.setOnLongClickListener(mLauncher);
            allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
        }

        // Note: We do this to ensure that the hotseat is always laid out in the orientation of
        // the hotseat in order regardless of which orientation they were added
        int x = getCellXFromOrder(allAppsButtonRank);
        int y = getCellYFromOrder(allAppsButtonRank);
        CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x, y, 1, 1);
        lp.canReorder = false;
        mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
    }
}
 
Example 12
Project: MenuSet   File: Utils.java   View Source Code Vote up 5 votes
public static TextView getItemTextView(Context context, MenuObject menuItem, int menuItemSize,
                                       View.OnClickListener onCLick, View.OnLongClickListener onLongClick) {
    TextView itemTextView = new TextView(context);
    RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, menuItemSize);
    itemTextView.setLayoutParams(textLayoutParams);
    itemTextView.setOnClickListener(onCLick);
    itemTextView.setOnLongClickListener(onLongClick);
    itemTextView.setText(menuItem.getTitle());
    itemTextView.setPadding(0, 0, (int) context.getResources().getDimension(R.dimen.text_right_padding), 0);
    itemTextView.setGravity(Gravity.CENTER_VERTICAL);
    int textColor = menuItem.getTextColor() == 0 ?
            android.R.color.white :
            menuItem.getTextColor();

    itemTextView.setTextColor(ContextCompat.getColor(context, textColor));

    int styleResId = menuItem.getMenuTextAppearanceStyle() > 0
            ? menuItem.getMenuTextAppearanceStyle()
            : R.style.TextView_DefaultStyle;

    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) {
        itemTextView.setTextAppearance(context, styleResId);
    } else {
        itemTextView.setTextAppearance(styleResId);
    }

    return itemTextView;
}
 
Example 13
Project: SimpleUILauncher   File: Hotseat.java   View Source Code Vote up 5 votes
void resetLayout() {
    mContent.removeAllViewsInLayout();

    // 在hotseat中显示进入所有应用列表的图标
    if (!FeatureFlags.NO_ALL_APPS_ICON) {
        // Add the Apps button
        Context context = getContext();
        int allAppsButtonRank = mLauncher.getDeviceProfile().inv.getAllAppsButtonRank();

        LayoutInflater inflater = LayoutInflater.from(context);
        TextView allAppsButton = (TextView)
                inflater.inflate(R.layout.all_apps_button, mContent, false);
        Drawable d = context.getResources().getDrawable(R.drawable.all_apps_button_icon);

        mLauncher.resizeIconDrawable(d);
        int scaleDownPx = getResources().getDimensionPixelSize(R.dimen.all_apps_button_scale_down);
        Rect bounds = d.getBounds();
        d.setBounds(bounds.left, bounds.top + scaleDownPx / 2, bounds.right - scaleDownPx,
                bounds.bottom - scaleDownPx / 2);
        allAppsButton.setCompoundDrawables(null, d, null, null);

        allAppsButton.setContentDescription(context.getString(R.string.all_apps_button_label));
        allAppsButton.setOnKeyListener(new HotseatIconKeyEventListener());
        if (mLauncher != null) {
            mLauncher.setAllAppsButton(allAppsButton);
            allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
            allAppsButton.setOnClickListener(mLauncher);
            allAppsButton.setOnLongClickListener(mLauncher);
            allAppsButton.setOnFocusChangeListener(mLauncher.mFocusHandler);
        }

        // Note: We do this to ensure that the hotseat is always laid out in the orientation of
        // the hotseat in order regardless of which orientation they were added
        int x = getCellXFromOrder(allAppsButtonRank);
        int y = getCellYFromOrder(allAppsButtonRank);
        CellLayout.LayoutParams lp = new CellLayout.LayoutParams(x, y, 1, 1);
        lp.canReorder = false;
        mContent.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
    }
}
 
Example 14
Project: q-mail   File: MessageHeader.java   View Source Code Vote up 4 votes
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    mAnsweredIcon = findViewById(R.id.answered);
    mForwardedIcon = findViewById(R.id.forwarded);
    mFromView = (TextView) findViewById(R.id.from);
    mSenderView = (TextView) findViewById(R.id.sender);
    mToView = (TextView) findViewById(R.id.to);
    mToLabel = (TextView) findViewById(R.id.to_label);
    mCcView = (TextView) findViewById(R.id.cc);
    mCcLabel = (TextView) findViewById(R.id.cc_label);
    mBccView = (TextView) findViewById(R.id.bcc);
    mBccLabel = (TextView) findViewById(R.id.bcc_label);

    mContactBadge = (ContactBadge) findViewById(R.id.contact_badge);

    mSubjectView = (TextView) findViewById(R.id.subject);
    mAdditionalHeadersView = (TextView) findViewById(R.id.additional_headers_view);
    mChip = findViewById(R.id.chip);
    mDateView = (TextView) findViewById(R.id.date);
    mFlagged = (CheckBox) findViewById(R.id.flagged);
    mAttachments = findViewById(R.id.attachments);
    mAttachmentsList = findViewById(R.id.attachmentList);
    mAttachments.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if(mAttachmentsList.getVisibility() != VISIBLE) {
                mAttachmentsList.setVisibility(VISIBLE);
            } else {
                mAttachmentsList.setVisibility(GONE);
            }
        }
    });

    defaultSubjectColor = mSubjectView.getCurrentTextColor();
    mFontSizes.setViewTextSize(mSubjectView, mFontSizes.getMessageViewSubject());
    mFontSizes.setViewTextSize(mDateView, mFontSizes.getMessageViewDate());
    mFontSizes.setViewTextSize(mAdditionalHeadersView, mFontSizes.getMessageViewAdditionalHeaders());

    mFontSizes.setViewTextSize(mFromView, mFontSizes.getMessageViewSender());
    mFontSizes.setViewTextSize(mToView, mFontSizes.getMessageViewTo());
    mFontSizes.setViewTextSize(mToLabel, mFontSizes.getMessageViewTo());
    mFontSizes.setViewTextSize(mCcView, mFontSizes.getMessageViewCC());
    mFontSizes.setViewTextSize(mCcLabel, mFontSizes.getMessageViewCC());
    mFontSizes.setViewTextSize(mBccView, mFontSizes.getMessageViewBCC());
    mFontSizes.setViewTextSize(mBccLabel, mFontSizes.getMessageViewBCC());

    mFromView.setOnClickListener(this);
    mToView.setOnClickListener(this);
    mCcView.setOnClickListener(this);
    mBccView.setOnClickListener(this);

    mFromView.setOnLongClickListener(this);
    mToView.setOnLongClickListener(this);
    mCcView.setOnLongClickListener(this);
    mBccView.setOnLongClickListener(this);

    mCryptoStatusIcon = (MessageCryptoStatusView) findViewById(R.id.crypto_status_icon);
    mCryptoStatusIcon.setOnClickListener(this);

    mMessageHelper = MessageHelper.getInstance(mContext);

    hideAdditionalHeaders();
}
 
Example 15
Project: AOSP-Kayboard-7.1.2   File: SuggestionStripView.java   View Source Code Vote up 4 votes
public SuggestionStripView(final Context context, final AttributeSet attrs,
        final int defStyle) {
    super(context, attrs, defStyle);

    final LayoutInflater inflater = LayoutInflater.from(context);
    inflater.inflate(R.layout.suggestions_strip, this);

    mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
    mVoiceKey = (ImageButton)findViewById(R.id.suggestions_strip_voice_key);
    mImportantNoticeStrip = findViewById(R.id.important_notice_strip);
    mStripVisibilityGroup = new StripVisibilityGroup(this, mSuggestionsStrip,
            mImportantNoticeStrip);

    for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
        final TextView word = new TextView(context, null, R.attr.suggestionWordStyle);
        word.setContentDescription(getResources().getString(R.string.spoken_empty_suggestion));
        word.setOnClickListener(this);
        word.setOnLongClickListener(this);
        mWordViews.add(word);
        final View divider = inflater.inflate(R.layout.suggestion_divider, null);
        mDividerViews.add(divider);
        final TextView info = new TextView(context, null, R.attr.suggestionWordStyle);
        info.setTextColor(Color.WHITE);
        info.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEBUG_INFO_TEXT_SIZE_IN_DIP);
        mDebugInfoViews.add(info);
    }

    mLayoutHelper = new SuggestionStripLayoutHelper(
            context, attrs, defStyle, mWordViews, mDividerViews, mDebugInfoViews);

    mMoreSuggestionsContainer = inflater.inflate(R.layout.more_suggestions, null);
    mMoreSuggestionsView = (MoreSuggestionsView)mMoreSuggestionsContainer
            .findViewById(R.id.more_suggestions_view);
    mMoreSuggestionsBuilder = new MoreSuggestions.Builder(context, mMoreSuggestionsView);

    final Resources res = context.getResources();
    mMoreSuggestionsModalTolerance = res.getDimensionPixelOffset(
            R.dimen.config_more_suggestions_modal_tolerance);
    mMoreSuggestionsSlidingDetector = new GestureDetector(
            context, mMoreSuggestionsSlidingListener);

    final TypedArray keyboardAttr = context.obtainStyledAttributes(attrs,
            R.styleable.Keyboard, defStyle, R.style.SuggestionStripView);
    final Drawable iconVoice = keyboardAttr.getDrawable(R.styleable.Keyboard_iconShortcutKey);
    keyboardAttr.recycle();
    mVoiceKey.setImageDrawable(iconVoice);
    mVoiceKey.setOnClickListener(this);
}
 
Example 16
Project: yyox   File: AbstractHolder.java   View Source Code Vote up 2 votes
/**
 * 加载文本消息
 *
 * @param message
 * @param contentText
 * @param position
 */
protected final void loadTextData(IMMessage message, TextView contentText, int position) {
    CustomTextView.stripUnderlines(context, contentText, message.getMessage(), Linkify.ALL);
    contentText.setOnLongClickListener(new MessageTextLongListener(context, message, position));
}
 
Example 17
Project: yyox   File: AbstractHolder.java   View Source Code Vote up 2 votes
/**
 * 加载机器人消息
 *
 * @param message
 * @param contentText
 * @param position
 */
protected final void loadAIData(IMMessage message, TextView contentText, int position) {
    CustomTextView.setTextWithAIMessage(context, contentText, message.getMessage());
    contentText.setOnLongClickListener(new MessageTextLongListener(context, message, position));
}