List of usage examples for android.widget TextView setClickable
public void setClickable(boolean clickable)
From source file:org.telegram.ui.IdenticonActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/* w w w . j a v a 2s.c o m*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); fragmentView = new LinearLayout(context); LinearLayout linearLayout = (LinearLayout) fragmentView; linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setWeightSum(100); linearLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); FrameLayout frameLayout = new FrameLayout(context); frameLayout.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); ImageView identiconView = new ImageView(context); identiconView.setScaleType(ImageView.ScaleType.FIT_XY); frameLayout.addView(identiconView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); frameLayout = new FrameLayout(context); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.background)); frameLayout.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); TextView textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLinksClickable(true); textView.setClickable(true); textView.setMovementMethod(new LinkMovementMethodMy()); //textView.setAutoLinkMask(Linkify.WEB_URLS); textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR); textView.setGravity(Gravity.CENTER); frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id); if (encryptedChat != null) { IdenticonDrawable drawable = new IdenticonDrawable(); identiconView.setImageDrawable(drawable); drawable.setEncryptedChat(encryptedChat); TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id); SpannableStringBuilder hash = new SpannableStringBuilder(); if (encryptedChat.key_hash.length > 16) { String hex = Utilities.bytesToHex(encryptedChat.key_hash); for (int a = 0; a < 32; a++) { if (a != 0) { if (a % 8 == 0) { hash.append('\n'); } else if (a % 4 == 0) { hash.append(' '); } } hash.append(hex.substring(a * 2, a * 2 + 2)); hash.append(' '); } hash.append("\n\n"); } hash.append(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name))); final String url = "telegram.org"; int index = hash.toString().indexOf(url); if (index != -1) { hash.setSpan( new URLSpanReplacement( LocaleController.getString("EncryptionKeyLink", R.string.EncryptionKeyLink)), index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } textView.setText(hash); } return fragmentView; }
From source file:com.ibm.helloauthentication.MainActivity.java
/** * Updates text fields in the UI//from w w w. ja va 2s.c o m * @param messageText String that displays in center text box * @param wasSuccessful Boolean that decides appropriate text to display */ private void setStatus(final String messageText, boolean wasSuccessful) { final TextView responseText = (TextView) findViewById(R.id.response_text); final TextView topText = (TextView) findViewById(R.id.top_text); final TextView bottomText = (TextView) findViewById(R.id.bottom_text); final TextView buttonText = (TextView) findViewById(R.id.button_text); final String topStatus = wasSuccessful ? "Yay!" : "Bummer"; final String bottomStatus = wasSuccessful ? "Connected to MCA protected endpoint" : "Something Went Wrong"; runOnUiThread(new Runnable() { @Override public void run() { buttonText.setClickable(true); responseText.setText(messageText); topText.setText(topStatus); bottomText.setText(bottomStatus); } }); }
From source file:org.wheelmap.android.fragment.InfoFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_credit_screen, container, false); TextView openStreetMapLink = (TextView) v.findViewById(R.id.openStreetMapLink); TextView openMapBoxLink = (TextView) v.findViewById(R.id.openMapBox); TextView openNicolasLink = (TextView) v.findViewById(R.id.linkNicolasMollet); String linkOpenStreetMap = "https://www.openstreetmap.org/copyright"; String linkOpenMapBox = "http://mapbox.com/about/maps/"; String linkOpenNicolas = "https://mapicons.mapsmarker.com"; openStreetMapLink.setClickable(true); openMapBoxLink.setClickable(true);//w w w.j a va2s . c o m String text = "<a href=" + linkOpenStreetMap + ">" + openStreetMapLink.getText() + "</a>"; openStreetMapLink.setText(Html.fromHtml(text)); String text1 = "<a href=" + linkOpenMapBox + ">" + openMapBoxLink.getText() + "</a>"; openMapBoxLink.setText(Html.fromHtml(text1)); String text2 = "<a href=" + linkOpenNicolas + ">" + openNicolasLink.getText() + "</a>"; openNicolasLink.setText(Html.fromHtml(text2)); openStreetMapLink.setMovementMethod(LinkMovementMethod.getInstance()); openMapBoxLink.setMovementMethod(LinkMovementMethod.getInstance()); openNicolasLink.setMovementMethod(LinkMovementMethod.getInstance()); return v; }
From source file:com.lfq.pulltorefresh.library.sideslip.SwipeMenuLayout.java
@Override protected void onFinishInflate() { super.onFinishInflate(); if (mRightViewId != 0 && mSwipeRightHorizontal == null) { View view = findViewById(mRightViewId); mSwipeRightHorizontal = new SwipeRightHorizontal(view); }/* w w w .ja va 2 s . c o m*/ if (mContentViewId != 0 && mContentView == null) { mContentView = findViewById(mContentViewId); } else { TextView errorView = new TextView(getContext()); errorView.setClickable(true); errorView.setGravity(Gravity.CENTER); errorView.setTextSize(16); errorView.setText("You may not have set the ContentView."); mContentView = errorView; addView(mContentView); } }
From source file:com.andview.refreshview.swipe.SwipeMenuLayout.java
@Override protected void onFinishInflate() { super.onFinishInflate(); if (mLeftViewId != 0 && mSwipeLeftHorizontal == null) { View view = findViewById(mLeftViewId); mSwipeLeftHorizontal = new SwipeLeftHorizontal(view); }//from ww w. j a v a 2s . c o m if (mRightViewId != 0 && mSwipeRightHorizontal == null) { View view = findViewById(mRightViewId); mSwipeRightHorizontal = new SwipeRightHorizontal(view); } if (mContentViewId != 0 && mContentView == null) { mContentView = findViewById(mContentViewId); } else { TextView errorView = new TextView(getContext()); errorView.setClickable(true); errorView.setGravity(Gravity.CENTER); errorView.setTextSize(16); errorView.setText("You may not have set the ContentView."); mContentView = errorView; addView(mContentView); } }
From source file:me.piebridge.prevent.ui.UserGuideActivity.java
@Override public void onCreate(Bundle savedInstanceState) { ThemeUtils.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.about);//www . j a v a 2 s .c om ThemeUtils.fixSmartBar(this); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { getActionBar().setDisplayHomeAsUpEnabled(true); } WebView webView = (WebView) findViewById(R.id.webview); webView.setVerticalScrollBarEnabled(false); webView.setHorizontalScrollBarEnabled(false); if ("zh".equals(Locale.getDefault().getLanguage())) { webView.loadUrl("file:///android_asset/about.zh.html"); } else { webView.loadUrl("file:///android_asset/about.en.html"); } setView(R.id.alipay, "com.eg.android.AlipayGphone"); if (hasPermission()) { setView(R.id.wechat, "com.tencent.mm"); } else { findViewById(R.id.wechat).setVisibility(View.GONE); } if (!setView(R.id.paypal, "com.paypal.android.p2pmobile")) { TextView paypal = (TextView) findViewById(R.id.paypal); paypal.setClickable(true); paypal.setOnClickListener(this); paypal.setCompoundDrawablesWithIntrinsicBounds(null, cropDrawable(paypal.getCompoundDrawables()[1]), null, null); } if (setView(R.id.play, "com.android.vending")) { findViewById(R.id.play).setVisibility(View.GONE); checkDonate(); } donateView = findViewById(R.id.donate); if (BuildConfig.DONATE && TextUtils.isEmpty(LicenseUtils.getLicense(this))) { donateView.setVisibility(View.VISIBLE); } else { donateView.setVisibility(View.GONE); } retrieveInfo(); }
From source file:fiskinfoo.no.sintef.fiskinfoo.CardViewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_card_view, container, false); RelativeLayout textAreaPlaceHolder = (RelativeLayout) rootView.findViewById(R.id.card_view_container); TextView title = (TextView) rootView.findViewById(R.id.card_view_title_text_view); if (subscription != null) { title.setText(subscription.GeoDataServiceName); TextView idView = generateTextViewWithText("id: " + subscription.Id, title); TextView geoDataServiceNameView = generateTextViewWithText( "Navn p kartlaget: " + subscription.GeoDataServiceName, idView); TextView fileFormatTypeView = generateTextViewWithText("Filformat: " + subscription.FileFormatType, geoDataServiceNameView); TextView userEmailView = generateTextViewWithText("Bruker e-post: " + subscription.UserEmail, fileFormatTypeView);/*from ww w . j ava2s. com*/ TextView subscriptionEmailView = generateTextViewWithText( "Abbonents e-post: " + subscription.SubscriptionEmail, userEmailView); TextView subscriptionIntervalNameView = generateTextViewWithText( "Kartet sendes: " + subscription.SubscriptionIntervalName, subscriptionEmailView); TextView createdView = generateTextViewWithText("Opprettet: " + subscription.Created, subscriptionIntervalNameView); TextView lastModifiedView = generateTextViewWithText("Sist oppdatert: " + subscription.LastModified, createdView); textAreaPlaceHolder.addView(idView); textAreaPlaceHolder.addView(geoDataServiceNameView); textAreaPlaceHolder.addView(fileFormatTypeView); textAreaPlaceHolder.addView(userEmailView); textAreaPlaceHolder.addView(subscriptionEmailView); textAreaPlaceHolder.addView(subscriptionIntervalNameView); textAreaPlaceHolder.addView(createdView); textAreaPlaceHolder.addView(lastModifiedView); } if (propertyDescription != null) { title.setText(propertyDescription.Name); Button notificationIconButton = (Button) rootView.findViewById(R.id.card_notification_image_view); CardViewInformationRow row; Button downloadMapButton; Button showOnMapButton; final ScrollView scrollView = (ScrollView) rootView.findViewById(R.id.card_view_scroll_view); final LinearLayout informationContainer = (LinearLayout) rootView .findViewById(R.id.card_view_information_container); LinearLayout bottomButtonContainer = (LinearLayout) rootView.findViewById(R.id.bottom_button_container); showOnMapButton = new Button(getActivity()); downloadMapButton = (Button) rootView.findViewById(R.id.card_view_download_map_button); row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.last_updated), propertyDescription.LastUpdated.replace('T', ' '), true); informationContainer.addView(row.getView()); String description = (propertyDescription.LongDescription == null || propertyDescription.LongDescription.trim().equals("")) ? propertyDescription.Description : propertyDescription.LongDescription; String hyperlink = null; description = description.replace("<p>", ""); description = description.replace("</p>", ""); // TODO: should rewrite in order to handle multiple links. if (description.contains("<a href=\"")) { hyperlink = "<a href='" + description.substring(description.indexOf("href=") + 6, description.indexOf(">", description.indexOf("href=")) - 1) + "'>" + "\t\t\t* " + getString(R.string.see_more_info) + "</a>"; description = description.substring(0, description.indexOf("<a href")) + description.substring(description.indexOf(">", description.indexOf("<a href")) + 1, description.indexOf("</a")) + "*" + (description.indexOf("a>") > description.length() - 3 ? "" : description.substring(description.indexOf("a>") + 2, description.length())); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.information), description, true); informationContainer.addView(row.getView()); if (hyperlink != null) { TextView textView = new TextView(getActivity()); textView.setClickable(true); textView.setMovementMethod(LinkMovementMethod.getInstance()); textView.setText(Html.fromHtml(hyperlink)); textView.setTextSize(getResources().getInteger(R.integer.hyperlinkTextSize)); informationContainer.addView(textView); } String updateFrequency = (propertyDescription.UpdateFrequencyText == null || propertyDescription.UpdateFrequencyText.trim().equals("")) ? getString(R.string.update_frequency_not_available) : propertyDescription.UpdateFrequencyText; row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.update_frequency), updateFrequency, true); informationContainer.addView(row.getView()); if (ApiErrorType.getType(propertyDescription.ErrorType) == ApiErrorType.WARNING) { row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.error_text), propertyDescription.ErrorText, true); final View dataField = row.getView(); final Animation animation = getBlinkAnimation(); notificationIconButton.setVisibility(View.VISIBLE); notificationIconButton .setBackground(ContextCompat.getDrawable(getActivity(), R.drawable.ic_warning_black_36dp)); row.setTextColor(getResources().getColor(R.color.warning_orange)); notificationIconButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { focusOnView(scrollView, dataField); dataField.startAnimation(animation); } }); informationContainer.addView(row.getView()); } else if (ApiErrorType.getType(propertyDescription.ErrorType) == ApiErrorType.WARNING) { row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.error_text), propertyDescription.ErrorText, true); final TextView dataField = row.getFieldDataTextView(); final Animation animation = getBlinkAnimation(); notificationIconButton.setVisibility(View.VISIBLE); notificationIconButton.setBackground( ContextCompat.getDrawable(getActivity(), R.drawable.ic_error_outline_black_36dp)); row.setTextColor(getResources().getColor(R.color.error_red)); notificationIconButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { focusOnView(scrollView, dataField); dataField.startAnimation(animation); } }); informationContainer.addView(row.getView()); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.data_owner), propertyDescription.DataOwner, true); informationContainer.addView(row.getView()); if (propertyDescription.DataOwnerLink != null && !propertyDescription.DataOwnerLink.trim().equals("")) { String partnerLink = (propertyDescription.DataOwnerLink.contains("http") || propertyDescription.DataOwnerLink.contains("www")) ? "<a href='" + propertyDescription.DataOwnerLink + "'>" + propertyDescription.DataOwnerLink + "</a>" : "<a href='" + getString(R.string.about_partners_base_address) + propertyDescription.DataOwnerLink + "'>" + getString(R.string.about_partners_base_address) + propertyDescription.DataOwnerLink + "</a>"; row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.data_owner_link), partnerLink, true); row.setHyperlink(partnerLink); row.getFieldDataTextView().setMovementMethod(LinkMovementMethod.getInstance()); informationContainer.addView(row.getView()); } StringBuilder stringBuilder = new StringBuilder(); for (String format : propertyDescription.Formats) { stringBuilder.append(format); stringBuilder.append("\n"); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.formats), stringBuilder.toString().trim(), false); informationContainer.addView(row.getView()); stringBuilder.setLength(0); for (String interval : propertyDescription.SubscriptionInterval) { stringBuilder.append(SubscriptionInterval.getType(interval).toString()); stringBuilder.append("\n"); } row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.subscription_frequencies), stringBuilder.toString().trim(), false); informationContainer.addView(row.getView()); row = utilityRows.getCardViewInformationRow(getActivity(), getString(R.string.map_creation_date), propertyDescription.Created.substring(0, propertyDescription.Created.indexOf('T')), true); informationContainer.addView(row.getView()); LinearLayout.LayoutParams bottomButtonLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); bottomButtonLayoutParams.gravity = Gravity.CENTER_VERTICAL; bottomButtonLayoutParams.weight = (float) 0.5; showOnMapButton.setLayoutParams(bottomButtonLayoutParams); showOnMapButton.setText(getString(R.string.show_on_map)); showOnMapButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //TODO: Need to update the toolbar as well. List<String> layersList = new ArrayList<>(); String layerName = propertyDescription.Name; layersList.add("Grunnkart"); layersList.add(layerName); user.setActiveLayers(layersList); user.writeToSharedPref(getActivity()); getFragmentManager().beginTransaction().replace(R.id.fragment_container, new FiskInfoUtility().createFragment(MapFragment.TAG, user, TAG), MapFragment.TAG) .addToBackStack(null).commit(); } }); bottomButtonContainer.addView(showOnMapButton); downloadMapButton.setOnClickListener(utilityOnClickListeners .getSubscriptionDownloadButtonOnClickListener(getActivity(), propertyDescription, user, TAG)); } if (warning != null) { TextView content = generateTextViewWithText(warning, title); textAreaPlaceHolder.addView(content); } clearIds(); return rootView; }
From source file:com.ibm.helloauthentication.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView buttonText = (TextView) findViewById(R.id.button_text); // initialize SDK with IBM Bluemix application ID and REGION, TODO: Update region if not using Bluemix US SOUTH BMSClient.getInstance().initialize(this, BMSClient.REGION_US_SOUTH); // Runtime Permission handling required for SDK 23+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) { buttonText.setClickable(false); ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.GET_ACCOUNTS }, PERMISSION_REQUEST_GET_ACCOUNTS); }/*from w w w . j a va 2 s. c o m*/ // Register this activity as the default auth listener Log.i(TAG, "Registering Google Auth Listener"); // Must create MCA auth manager before registering Google auth Manager //TODO: Please replace <APP_GUID> with a valid Application GUID from your MCA instance MCAAuthorizationManager MCAAuthMan = MCAAuthorizationManager.createInstance(this, "<APP_GUID>"); BMSClient.getInstance().setAuthorizationManager(MCAAuthMan); GoogleAuthenticationManager.getInstance().register(this); }
From source file:jahirfiquitiva.iconshowcase.adapters.ChangelogAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = LayoutInflater.from(context); convertView = inflater.inflate(R.layout.changelog_content, parent, false); convertView.setClickable(false); convertView.setLongClickable(false); convertView.setFocusable(false); convertView.setFocusableInTouchMode(false); convertView.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); }/*from w w w. ja v a 2 s.c o m*/ TextView title = (TextView) convertView.findViewById(R.id.changelog_title); TextView content = (TextView) convertView.findViewById(R.id.changelog_content); String nameStr = mChangelog[position][0]; String contentStr = ""; for (int i = 1; i < mChangelog[position].length; i++) { if (i > 1) { // No need for new line on the first item contentStr += "\n"; } contentStr += "\u2022 "; contentStr += mChangelog[position][i]; } title.setText(nameStr); title.setClickable(false); title.setLongClickable(false); title.setFocusable(false); title.setFocusableInTouchMode(false); title.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); content.setText(contentStr); content.setClickable(false); content.setLongClickable(false); content.setFocusable(false); content.setFocusableInTouchMode(false); content.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent)); return convertView; }
From source file:com.cmax.bodysheild.widget.PagerSlidingTabStripExtends.java
public void setAllTabTextColor(int res) { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (v instanceof TextView) { TextView tv = (TextView) v; tv.setTextColor(res);/*from w w w . j a v a2s.com*/ tv.setClickable(true); tv.setEnabled(true); tv.setFocusable(true); } } }