Java Code Examples for android.widget.TextView#setTextIsSelectable()
The following examples show how to use
android.widget.TextView#setTextIsSelectable() .
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: AboutActivity.java From PicKing with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); ButterKnife.bind(this); toolbar.setTitle("关于 v " + PackageUtil.getAppPackageInfo(this).versionName); setSupportActionBar(toolbar); TextView alipay = (TextView) findViewById(R.id.alipay); alipay.setTextIsSelectable(true); alipay.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!AliPayUtil.goAliPay(AboutActivity.this)) SnackbarUtils.Short(getWindow().getDecorView(), "设备上没有安装支付宝").danger().show(); } }); }
Example 2
Source File: HyperTextView.java From YCCustomText with Apache License 2.0 | 6 votes |
/** * 生成文本输入框 */ private TextView createTextView(String hint, int paddingTop) { TextView textView = new TextView(getContext()); LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); textView.setLayoutParams(layoutParams); textView.setTextSize(16); textView.setTextColor(Color.parseColor("#616161")); textView.setTextIsSelectable(true); textView.setBackground(null); textView.setTag(viewTagIndex++); textView.setPadding(editNormalPadding, paddingTop, editNormalPadding, paddingTop); textView.setHint(hint); textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, rtTextSize); textView.setLineSpacing(rtTextLineSpace, 1.0f); textView.setTextColor(rtTextColor); return textView; }
Example 3
Source File: DescriptionFragment.java From KernelAdiutor with GNU General Public License v3.0 | 6 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_description, container, false); mTitleView = (TextView) rootView.findViewById(R.id.title); mSummaryView = (TextView) rootView.findViewById(R.id.summary); if (Utils.isTv(getActivity())) { mSummaryView.setFocusable(true); } else { mTitleView.setTextIsSelectable(true); mSummaryView.setTextIsSelectable(true); } mSummaryView.setSelected(true); mSummaryView.setMovementMethod(LinkMovementMethod.getInstance()); mTitle = getArguments().getCharSequence("title"); mSummary = getArguments().getCharSequence("summary"); refresh(); return rootView; }
Example 4
Source File: PropertiesDialog.java From RedReader with GNU General Public License v3.0 | 5 votes |
protected final LinearLayout propView(final Context context, final String title, final CharSequence text, final boolean firstInList) { final int paddingPixels = General.dpToPixels(context, 12); final LinearLayout prop = new LinearLayout(context); prop.setOrientation(LinearLayout.VERTICAL); if(!firstInList) { final View divider = new View(context); divider.setMinimumHeight(General.dpToPixels(context, 1)); divider.setBackgroundColor(rrListDividerCol); prop.addView(divider); } final TextView titleView = new TextView(context); titleView.setText(title.toUpperCase(Locale.getDefault())); titleView.setTextColor(rrListHeaderTextCol); titleView.setTextSize(12.0f); titleView.setPadding(paddingPixels, paddingPixels, paddingPixels, 0); prop.addView(titleView); final TextView textView = new TextView(context); textView.setText(text); textView.setTextColor(rrCommentBodyCol); textView.setTextSize(15.0f); textView.setPadding(paddingPixels, 0, paddingPixels, paddingPixels); textView.setTextIsSelectable(true); prop.addView(textView); return prop; }
Example 5
Source File: RxDialogSure.java From RxTools-master with Apache License 2.0 | 5 votes |
private void initView() { View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_sure, null); mTvSure = (TextView) dialogView.findViewById(R.id.tv_sure); mTvTitle = (TextView) dialogView.findViewById(R.id.tv_title); mTvTitle.setTextIsSelectable(true); mTvContent = (TextView) dialogView.findViewById(R.id.tv_content); mTvContent.setMovementMethod(ScrollingMovementMethod.getInstance()); mTvContent.setTextIsSelectable(true); mIvLogo = (ImageView) dialogView.findViewById(R.id.iv_logo); setContentView(dialogView); }
Example 6
Source File: RxDialogSureCancel.java From RxTools-master with Apache License 2.0 | 5 votes |
private void initView() { View dialogView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_sure_false, null); mIvLogo = (ImageView) dialogView.findViewById(R.id.iv_logo); mTvSure = (TextView) dialogView.findViewById(R.id.tv_sure); mTvCancel = (TextView) dialogView.findViewById(R.id.tv_cancel); mTvContent = (TextView) dialogView.findViewById(R.id.tv_content); mTvContent.setTextIsSelectable(true); mTvTitle = (TextView) dialogView.findViewById(R.id.tv_title); setContentView(dialogView); }
Example 7
Source File: WifiListActivity.java From WiFiKeyShare with GNU General Public License v3.0 | 5 votes |
@Override public boolean onContextItemSelected(MenuItem item) { int itemPosition = ((ContextMenuRecyclerView.RecyclerContextMenuInfo) item.getMenuInfo()).position; switch (item.getItemId()) { case (R.id.context_menu_wifi_list_view_password): final AlertDialog viewPasswordDialog = new AlertDialog.Builder(this) .setTitle(getString(R.string.wifilist_dialog_view_password)) .setView(R.layout.dialog_view_password) .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }) .create(); viewPasswordDialog.show(); /* Set SSID, security and password values */ TextView ssidTextView = (TextView) viewPasswordDialog.findViewById(R.id.ssid_value); TextView authTypeTextView = (TextView) viewPasswordDialog.findViewById(R.id.auth_type_value); TextView passwordTextView = (TextView) viewPasswordDialog.findViewById(R.id.password_value); ssidTextView.setText(wifiNetworks.get(itemPosition).getSsid()); authTypeTextView.setText(wifiNetworks.get(itemPosition).getAuthType().toString()); passwordTextView.setText(wifiNetworks.get(itemPosition).getKey()); passwordTextView.setTextIsSelectable(true); return true; case (R.id.context_menu_wifi_list_clear_password): removeSavedWifiKey(itemPosition); return true; } return super.onContextItemSelected(item); }
Example 8
Source File: WifiNetworkActivity.java From WiFiKeyShare with GNU General Public License v3.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_view_password: // FIXME: redundant with @WifiListActivity#onContextItemSelected final AlertDialog viewPasswordDialog = new AlertDialog.Builder(this) .setTitle(getString(R.string.wifi_dialog_view_password)) .setView(R.layout.dialog_view_password) .setPositiveButton(R.string.action_close, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }) .create(); viewPasswordDialog.show(); /* Set SSID, security and password values */ TextView ssidTextView = (TextView) viewPasswordDialog.findViewById(R.id.ssid_value); TextView authTypeTextView = (TextView) viewPasswordDialog.findViewById(R.id.auth_type_value); TextView passwordTextView = (TextView) viewPasswordDialog.findViewById(R.id.password_value); ssidTextView.setText(wifiNetwork.getSsid()); authTypeTextView.setText(wifiNetwork.getAuthType().toString()); passwordTextView.setText(wifiNetwork.getKey()); passwordTextView.setTextIsSelectable(true); return true; case R.id.action_settings: startActivity(new Intent(this, SettingsActivity.class)); return true; case R.id.action_about: final AlertDialog aboutDialog = new AboutDialog(this); aboutDialog.show(); return true; default: return super.onOptionsItemSelected(item); } }
Example 9
Source File: ViewUtil.java From CapturePacket with MIT License | 5 votes |
public static TextView getContentTextView(Context context){ TextView textView = new TextView(context); int dp_5 = context.getResources().getDimensionPixelSize(R.dimen.dp_5); textView.setPadding(dp_5,0,dp_5,0); textView.setTextSize(13); textView.setTextColor(0xff323232); textView.setTextIsSelectable(true); textView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); return textView; }
Example 10
Source File: AccountInfoFragment.java From tindroid with Apache License 2.0 | 5 votes |
@Override public void updateFormValues(final AppCompatActivity activity, final MeTopic<VxCard> me) { if (activity == null) { return; } ((TextView) activity.findViewById(R.id.topicAddress)).setText(Cache.getTinode().getMyId()); String fn = null; if (me != null) { VxCard pub = me.getPub(); if (pub != null) { fn = pub.fn; final Bitmap bmp = pub.getBitmap(); if (bmp != null) { ((AppCompatImageView) activity.findViewById(R.id.imageAvatar)) .setImageDrawable(new RoundImageDrawable(getResources(), bmp)); } } } final TextView title = activity.findViewById(R.id.topicTitle); if (!TextUtils.isEmpty(fn)) { title.setText(fn); title.setTypeface(null, Typeface.NORMAL); title.setTextIsSelectable(true); } else { title.setText(R.string.placeholder_contact_title); title.setTypeface(null, Typeface.ITALIC); title.setTextIsSelectable(false); } }
Example 11
Source File: Views.java From Android-Shortify with Apache License 2.0 | 5 votes |
public static $ selectable(){ try{ if(mView instanceof TextView){ TextView textView = (TextView) mView; textView.setTextIsSelectable(true); } }catch (Exception e){ Log.d(TAG, e.getMessage()); } return $.getInstance(); }
Example 12
Source File: MainActivity.java From android-orm-benchmark-updated with Apache License 2.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { final TextView resultView = new TextView(getActivity()); final int paddingDp = 10; final int paddingPx = dpToPx(paddingDp); resultView.setPadding(paddingPx, paddingPx, paddingPx, paddingPx); resultView.setText(Html.fromHtml(getArguments().getString(MESSAGE))); resultView.setTextIsSelectable(true); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); return builder.setTitle(getArguments().getInt(TITLE_RES_ID)) .setView(resultView) .create(); }
Example 13
Source File: ChatMsgAdapter.java From MaterialQQLite with Apache License 2.0 | 5 votes |
private void setBubble(TextView txtContent, ChatMsg chatMsg) { Integer nOldBubble = (Integer)txtContent.getTag(); if (null == nOldBubble || nOldBubble != chatMsg.m_nBubble) { int left = txtContent.getPaddingLeft(); int right = txtContent.getPaddingRight(); int top = txtContent.getPaddingTop(); int bottom = txtContent.getPaddingBottom(); boolean bIsUser = (ChatMsg.RIGHT == chatMsg.m_nType); boolean bUseDefBubble = true; if (chatMsg.m_nBubble != 0) { // } if (bUseDefBubble) { if (bIsUser) { txtContent.setBackgroundResource(R.drawable.btn_style7); txtContent.setTextColor(0xFFFFFFFF); txtContent.setTextIsSelectable(true); txtContent.setLinkTextColor(0xFF0000FF); } else { txtContent.setBackgroundResource(R.drawable.btn_style6); txtContent.setTextColor(0xFF000000); txtContent.setTextIsSelectable(true); txtContent.setLinkTextColor(0xFF0000FF); } txtContent.setTag(0); } txtContent.setPadding(left, top, right, bottom); } }
Example 14
Source File: TopicInfoFragment.java From tindroid with Apache License 2.0 | 4 votes |
private void notifyContentChanged() { final Activity activity = getActivity(); if (activity == null || activity.isFinishing() || activity.isDestroyed()) { return; } final AppCompatImageView avatar = activity.findViewById(R.id.imageAvatar); final TextView title = activity.findViewById(R.id.topicTitle); final TextView subtitle = activity.findViewById(R.id.topicSubtitle); VxCard pub = mTopic.getPub(); if (pub != null && !TextUtils.isEmpty(pub.fn)) { title.setText(pub.fn); title.setTypeface(null, Typeface.NORMAL); title.setTextIsSelectable(true); } else { title.setText(R.string.placeholder_contact_title); title.setTypeface(null, Typeface.ITALIC); title.setTextIsSelectable(false); } final Bitmap bmp = pub != null ? pub.getBitmap() : null; if (bmp != null) { avatar.setImageDrawable(new RoundImageDrawable(getResources(), bmp)); } else { avatar.setImageDrawable( new LetterTileDrawable(requireContext()) .setIsCircular(true) .setContactTypeAndColor( mTopic.getTopicType() == Topic.TopicType.P2P ? LetterTileDrawable.ContactType.PERSON : LetterTileDrawable.ContactType.GROUP) .setLetterAndColor(pub != null ? pub.fn : null, mTopic.getName())); } PrivateType priv = mTopic.getPriv(); if (priv != null && !TextUtils.isEmpty(priv.getComment())) { subtitle.setText(priv.getComment()); subtitle.setTypeface(null, Typeface.NORMAL); TypedValue typedValue = new TypedValue(); Resources.Theme theme = getActivity().getTheme(); theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true); TypedArray arr = activity.obtainStyledAttributes(typedValue.data, new int[]{android.R.attr.textColorSecondary}); subtitle.setTextColor(arr.getColor(0, -1)); arr.recycle(); subtitle.setTextIsSelectable(true); } else { subtitle.setText(R.string.placeholder_private); subtitle.setTypeface(null, Typeface.ITALIC); subtitle.setTextColor(getResources().getColor(R.color.colorTextPlaceholder)); subtitle.setTextIsSelectable(false); } ((Switch) activity.findViewById(R.id.switchMuted)).setChecked(mTopic.isMuted()); ((Switch) activity.findViewById(R.id.switchArchived)).setChecked(mTopic.isArchived()); Acs acs = mTopic.getAccessMode(); ((TextView) activity.findViewById(R.id.permissionsSingle)).setText(acs == null ? "" : acs.getMode()); }
Example 15
Source File: LyricsTextFactory.java From QuickLyric with GNU General Public License v3.0 | 4 votes |
@SuppressLint("newAPI") public void setSelectable(TextView t) { t.setTextIsSelectable(true); }
Example 16
Source File: DisplayStatusActivity.java From Rumble with GNU General Public License v3.0 | 4 votes |
private void renderStatus(String statusID) { PushStatus status = DatabaseFactory.getPushStatusDatabase(this).getStatus(statusID); if(status == null) return; ImageView avatarView = (ImageView)findViewById(R.id.status_item_avatar); TextView authorView = (TextView) findViewById(R.id.status_item_author); TextView textView = (TextView) findViewById(R.id.status_item_body); TextView tocView = (TextView) findViewById(R.id.status_item_created); TextView toaView = (TextView) findViewById(R.id.status_item_received); TextView groupNameView = (TextView) findViewById(R.id.status_item_group_name); ImageView attachedView = (ImageView)findViewById(R.id.status_item_attached_image); ImageView moreView = (ImageView)findViewById(R.id.status_item_more_options); LinearLayout box = (LinearLayout)findViewById(R.id.status_item_box); final String uid = status.getAuthor().getUid(); final String name= status.getAuthor().getName(); // we draw the avatar ColorGenerator generator = ColorGenerator.DEFAULT; avatarView.setImageDrawable( builder.build(status.getAuthor().getName().substring(0, 1), generator.getColor(status.getAuthor().getUid()))); // we draw the author field authorView.setText(status.getAuthor().getName()); tocView.setText(TimeUtil.timeElapsed(status.getTimeOfCreation())); toaView.setText(TimeUtil.timeElapsed(status.getTimeOfArrival())); groupNameView.setText(status.getGroup().getName()); groupNameView.setTextColor(generator.getColor(status.getGroup().getGid())); // we draw the status (with clickable links) textView.setText(status.getPost()); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setTextIsSelectable(true); Linkify.addLinks(textView, Linkify.ALL); /* todo: clickable hashtags */ /* we draw the attached file (if any) */ if (status.hasAttachedFile()) { attachedView.setVisibility(View.VISIBLE); try { final File attachedFile = new File(FileUtil.getReadableAlbumStorageDir(), status.getFileName()); if (!attachedFile.isFile() || !attachedFile.exists()) throw new IOException("file does not exists"); Picasso.with(DisplayStatusActivity.this) .load("file://"+attachedFile.getAbsolutePath()) .resize(96, 96) .centerCrop() .into(attachedView); final String filename = status.getFileName(); /* we open the attached image file in gallery */ attachedView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Log.d(TAG, "trying to open: " + filename); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://"+attachedFile.getAbsolutePath()), "image/*"); startActivity(intent); } }); } catch (IOException ignore) { Picasso.with(DisplayStatusActivity.this) .load(R.drawable.ic_close_black_48dp) .resize(96, 96) .centerCrop() .into(attachedView); } } else { attachedView.setVisibility(View.GONE); } /* moreView.setOnClickListener(new PopupMenuListener()); if (!status.hasUserReadAlready() || ((System.currentTimeMillis() - status.getTimeOfArrival()) < 60000)) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { box.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.status_shape_unread)); } else { box.setBackground(activity.getResources().getDrawable(R.drawable.status_shape_unread)); } if (!status.hasUserReadAlready()) { status.setUserRead(true); EventBus.getDefault().post(new UserReadStatus(status)); } } else { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { box.setBackgroundDrawable(activity.getResources().getDrawable(R.drawable.status_shape_read)); } else { box.setBackground(activity.getResources().getDrawable(R.drawable.status_shape_read)); } } */ }
Example 17
Source File: CompatibilityImpl.java From Overchan-Android with GNU General Public License v3.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void setTextIsSelectable(TextView textView) { textView.setTextIsSelectable(true); }
Example 18
Source File: CommonUtils.java From allenglish with Apache License 2.0 | 4 votes |
public static void setTextView(TextView tv, CharSequence charSequence) { tv.setMovementMethod(new ScrollingMovementMethod()); // 设置TextView可滚动 tv.setTextIsSelectable(true); // 设置文本可选 tv.setText(charSequence); }
Example 19
Source File: DownloadDetailsFragment.java From EdXposedManager with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Module module = mActivity.getModule(); if (module == null) return null; final View view = inflater.inflate(R.layout.download_details, container, false); TextView title = view.findViewById(R.id.download_title); title.setText(module.name); title.setTextIsSelectable(true); TextView author = view.findViewById(R.id.download_author); if (module.author != null && !module.author.isEmpty()) author.setText(getString(R.string.download_author, module.author)); else author.setText(R.string.download_unknown_author); TextView description = view.findViewById(R.id.download_description); if (module.description != null) { if (module.descriptionIsHtml) { description.setText(RepoParser.parseSimpleHtml(getActivity(), module.description, description)); description.setTransformationMethod(new LinkTransformationMethod(getActivity())); description.setMovementMethod(LinkMovementMethod.getInstance()); } else { description.setText(module.description); } description.setTextIsSelectable(true); } else { description.setVisibility(View.GONE); } ViewGroup moreInfoContainer = view.findViewById(R.id.download_moreinfo_container); for (Pair<String, String> moreInfoEntry : module.moreInfo) { View moreInfoView = inflater.inflate(R.layout.download_moreinfo, moreInfoContainer, false); TextView txtTitle = moreInfoView.findViewById(android.R.id.title); TextView txtValue = moreInfoView.findViewById(android.R.id.message); txtTitle.setText(String.format(moreInfoEntry.first + "%s", ":")); txtValue.setText(moreInfoEntry.second); final Uri link = NavUtil.parseURL(moreInfoEntry.second); if (link != null) { txtValue.setTextColor(txtValue.getLinkTextColors()); moreInfoView.setOnClickListener(v -> NavUtil.startURL(getActivity(), link)); } moreInfoContainer.addView(moreInfoView); } return view; }