List of usage examples for android.text SpannableString SpannableString
public SpannableString(CharSequence source)
From source file:net.bible.android.view.util.widget.BookmarkStyleAdapterHelper.java
/** * Replace first character of text with image *//*from w w w . j a v a 2s .c om*/ private CharSequence addImageAtStart(String text, int drawableImage, Context context) { ImageSpan imageSpan = new ImageSpan(context, drawableImage, ImageSpan.ALIGN_BASELINE); final SpannableString spannableString = new SpannableString(text); spannableString.setSpan(imageSpan, 0, 1, SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE); return spannableString; }
From source file:com.hpush.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;/* w ww.ja v a2s. c o m*/ try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append( Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName))); // Licenses. SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses)); licensesLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showOpenSourceLicenses(getActivity()); } }, 0, licensesLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.lbl_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.itbooks.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;/*from ww w. j ava2 s . c o m*/ try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append(Html.fromHtml(getString(R.string.about_body, versionName))); // Licenses. SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses)); licensesLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showOpenSourceLicenses(getActivity()); } }, 0, licensesLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.lbl_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:com.osc.tweet.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;//from www . ja v a 2 s . com try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append( Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName))); // Licenses. SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses)); licensesLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showOpenSourceLicenses(getActivity()); } }, 0, licensesLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:de.tum.mw.lfe.drtrc.AboutFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_about, container, false); ((MainActivity) getActivity()).addToReportView(null);//call with (null) just to refresh the reportView String tempStr = getVersionString(); tempStr += "<br/><br/>This is an open source implementation of an application to control an Arduino Detection Response Task (DRT) via USB OTG connection."; tempStr += "<br/><br/> (c) Michael Krause <a href=\"mailto:krause@tum.de\">krause@tum.de</a> <br/>2015 Institute of Ergonomics, TUM"; tempStr += "<br/><br/>More information on <br/><a href=\"http://www.lfe.mw.tum.de/drt-rc\">http://www.lfe.mw.tum.de/drt-rc</a>"; tempStr += "<br/><br/>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details."; final SpannableString s = new SpannableString(Html.fromHtml(tempStr)); Linkify.addLinks(s, Linkify.EMAIL_ADDRESSES | Linkify.WEB_URLS); TextView tv = (TextView) rootView.findViewById(R.id.aboutTextView); tv.setText(s);//from w w w. j av a 2 s . c o m return rootView; }
From source file:com.topfeeds4j.sample.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;/* w w w. ja v a 2s. co m*/ try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append( Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName))); // Licenses. SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses)); licensesLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showOpenSourceLicenses(getActivity()); } }, 0, licensesLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.fragment_dialog_about, null); aboutBodyView.setText(aboutBody); aboutBodyView.setLinkTextColor(getResources().getColor(R.color.com_facebook_blue)); aboutBodyView.setMovementMethod(new LinkMovementMethod()); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(aboutBodyView) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }
From source file:net.net76.lifeiq.TaskiQ.RegisterActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); inputFirstname = (EditText) findViewById(R.id.firstname); inputSurname = (EditText) findViewById(R.id.surname); inputUserID = (EditText) findViewById(R.id.userID); inputEmail = (EditText) findViewById(R.id.email); //1 inputPassword = (EditText) findViewById(R.id.password); //1inputPassword2 = (EditText) findViewById(R.id.password2); Spinner spinner = (Spinner) findViewById(R.id.spinner); EULA = (TextView) findViewById(R.id.EULA); SpannableString content = new SpannableString(EULA.getText().toString()); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); EULA.setText(content);/*from w w w .ja v a 2s .c om*/ EULA.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PackageInfo versionInfo = getPackageInfo(); // EULA title String title = RegisterActivity.this.getString(R.string.app_name) + " v " + versionInfo.versionName; // EULA text String message = RegisterActivity.this.getString(R.string.eula_string); android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(RegisterActivity.this) .setTitle(title).setMessage(message).setCancelable(false) .setPositiveButton(R.string.accept, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { EULAAccept = true; // Close dialog dialogInterface.dismiss(); } }).setNegativeButton(android.R.string.cancel, new Dialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { EULAAccept = false; } }); builder.create().show(); } }); // Create an ArrayAdapter using the string array and a default spinner layout ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.Country_array, android.R.layout.simple_spinner_item); // Specify the layout to use when the list of choices appears adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // Apply the adapter to the spinner spinner.setAdapter(adapter); spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { Log.v("item", (String) parent.getItemAtPosition(position)); countryString = (String) parent.getItemAtPosition(position); } @Override public void onNothingSelected(AdapterView<?> parent) { // TODO Auto-generated method stub } }); btnRegister = (Button) findViewById(R.id.btnRegister); btnLinkToLogin = (Button) findViewById(R.id.btnLinkToLoginScreen); // Progress dialog pDialog = new ProgressDialog(this); //pDialog.setCancelable(false); pDialog.setCanceledOnTouchOutside(false); // Session manager session = new SessionManager(getApplicationContext()); // SQLite database handler db = new SQLiteHandler(getApplicationContext()); // Check if user is already logged in or not if (session.isLoggedIn()) { // User is already logged in. Take him to main activity Intent intent = new Intent(RegisterActivity.this, MainActivity.class); startActivity(intent); finish(); } // Register Button Click event btnRegister.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String Firstname = inputFirstname.getText().toString(); String Surname = inputSurname.getText().toString(); String UserID = inputUserID.getText().toString(); String email = inputEmail.getText().toString(); //1 String password = inputPassword.getText().toString(); //1 String password2 = inputPassword2.getText().toString(); if (!Firstname.isEmpty() && !Surname.isEmpty() && !email.isEmpty() && !UserID.isEmpty()) { if (isEmailValid(email)) { if (!UserID.contains(" ")) { if (!countryString.equals("Select country of residence")) { if (EULAAccept.equals(true)) { if (isNetworkAvaliable(getApplicationContext())) { registerUser(Firstname, Surname, UserID, email, countryString); } else { Toast.makeText(getApplicationContext(), "Currently there is no network. Please try later.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please read and accept End User License Agreement.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please select a country of residence.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "In the User ID no spaces are allowed.", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please enter a valid email address!", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(getApplicationContext(), "Please enter your details!", Toast.LENGTH_SHORT) .show(); } } }); // Link to Login Screen btnLinkToLogin.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent i = new Intent(getApplicationContext(), LoginActivity.class); startActivity(i); finish(); } }); }
From source file:io.spw.hello.SectionsPagerAdapter.java
@Override public CharSequence getPageTitle(int position) { Drawable image = mActivity.getResources().getDrawable(imageResIdUnselected[position]); int currentPosition = ((MainActivity) mActivity).mViewPager.getCurrentItem(); if (position == currentPosition) { image = mActivity.getResources().getDrawable(imageResIdSelected[position]); }//from www . ja v a 2s . co m image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicWidth()); SpannableString ss = new SpannableString(" "); ImageSpan imageSpan = new ImageSpan(image, ImageSpan.ALIGN_BOTTOM); ss.setSpan(imageSpan, 0, 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); return ss; }
From source file:com.thatkawaiiguy.meleehandbook.adapter.SearchAdapter.java
private void highlight(String search, String originalText, TextView textView) { int startPos = originalText.toLowerCase(Locale.US).indexOf(search.toLowerCase(Locale.US)); int endPos = startPos + search.length(); if (startPos != -1) { Spannable spannable = new SpannableString(originalText); ColorStateList yellowColor = new ColorStateList(new int[][] { new int[] {} }, new int[] { ContextCompat.getColor(mContext, R.color.overscroll_color) }); TextAppearanceSpan highlightSpan = new TextAppearanceSpan(null, Typeface.BOLD, -1, yellowColor, null); spannable.setSpan(highlightSpan, startPos, endPos, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(spannable);// w ww .jav a 2s . c o m } else textView.setText(originalText); }
From source file:com.marstemp.app.fragments.AboutDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Get app version PackageManager pm = getActivity().getPackageManager(); String packageName = getActivity().getPackageName(); String versionName;/*w ww.j a v a 2s .com*/ try { PackageInfo info = pm.getPackageInfo(packageName, 0); versionName = info.versionName; } catch (PackageManager.NameNotFoundException e) { versionName = VERSION_UNAVAILABLE; } // About. SpannableStringBuilder aboutBody = new SpannableStringBuilder(); aboutBody.append( Html.fromHtml(getString(R.string.about_body, getString(R.string.application_name), versionName))); // Licenses. SpannableString licensesLink = new SpannableString(getString(R.string.about_licenses)); licensesLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showOpenSourceLicenses(getActivity()); } }, 0, licensesLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(licensesLink); // End User License Agreement. SpannableString eulaLink = new SpannableString(getString(R.string.about_eula)); eulaLink.setSpan(new ClickableSpan() { @Override public void onClick(View view) { showEula(getActivity()); } }, 0, eulaLink.length(), 0); aboutBody.append("\n\n"); aboutBody.append(eulaLink); // Show "About" dialog. LayoutInflater layoutInflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View dialogV = layoutInflater.inflate(R.layout.fragment_dialog_about, null); ; TextView aboutBodyView = (TextView) dialogV.findViewById(R.id.dialog_text_tv); aboutBodyView.setText(aboutBody); aboutBodyView.setMovementMethod(new LinkMovementMethod()); dialogV.findViewById(R.id.powered_by_ll).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { WebViewActivity.showInstance(getActivity(), getString(R.string.lbl_maas), Prefs.getInstance().getApiHome()); } }); return new AlertDialog.Builder(getActivity()).setTitle(R.string.action_about).setView(dialogV) .setPositiveButton(R.string.btn_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.dismiss(); } }).create(); }