本文整理汇总了Java中android.widget.TextView.setOnLongClickListener方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setOnLongClickListener方法的具体用法?Java TextView.setOnLongClickListener怎么用?Java TextView.setOnLongClickListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setOnLongClickListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ModuleViewHolder
import android.widget.TextView; //导入方法依赖的package包/类
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;
});
}
示例2: PropertyViewHolder
import android.widget.TextView; //导入方法依赖的package包/类
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);
}
});
}
示例3: displayWeb
import android.widget.TextView; //导入方法依赖的package包/类
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);
}
}
示例4: bindContentView
import android.widget.TextView; //导入方法依赖的package包/类
@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);
}
示例5: loadFileData
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 记载附件消息
*
* @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));
}
}
示例6: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
@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);
}
}
示例7: ViewHolder
import android.widget.TextView; //导入方法依赖的package包/类
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());
}
});
}
}
示例8: setLongClickCopy
import android.widget.TextView; //导入方法依赖的package包/类
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;
}
});
}
示例9: initTimeAndBody
import android.widget.TextView; //导入方法依赖的package包/类
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);
}
示例10: bindContentView
import android.widget.TextView; //导入方法依赖的package包/类
@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);
}
示例11: resetLayout
import android.widget.TextView; //导入方法依赖的package包/类
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);
}
}
示例12: getItemTextView
import android.widget.TextView; //导入方法依赖的package包/类
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;
}
示例13: resetLayout
import android.widget.TextView; //导入方法依赖的package包/类
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);
}
}
示例14: onFinishInflate
import android.widget.TextView; //导入方法依赖的package包/类
@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();
}
示例15: SuggestionStripView
import android.widget.TextView; //导入方法依赖的package包/类
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);
}