List of usage examples for android.text.method LinkMovementMethod getInstance
public static MovementMethod getInstance()
From source file:com.android.talkbacktests.testsession.TestSessionFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { final View view = inflater.inflate(R.layout.fragment_test_content, container, false); final BaseTestContent content = TestController.getInstance().getSessionById(mSessionId) .getTestContent(mContentIndex); final TextView description = (TextView) (view.findViewById(R.id.contentContainer) .findViewById(R.id.description)); description.setText(Html.fromHtml(content.getDescription())); description.setMovementMethod(LinkMovementMethod.getInstance()); final TextView subtitle = (TextView) (view.findViewById(R.id.contentContainer).findViewById(R.id.title)); subtitle.setText(content.getSubtitle()); final Button previous = (Button) view.findViewById(R.id.previous); previous.setOnClickListener(this); final Button next = (Button) view.findViewById(R.id.next); next.setOnClickListener(this); assignButtonText(previous, next);//from w ww . j av a2 s . co m final ViewGroup contentArea = (ViewGroup) view.findViewById(R.id.content_area); contentArea.addView(content.getView(inflater, contentArea, getContext())); return view; }
From source file:org.catrobat.catroid.ui.dialogs.LoginRegisterDialog.java
@Override public Dialog onCreateDialog(Bundle bundle) { View rootView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_login_register, null); usernameEditText = (EditText) rootView.findViewById(R.id.username); passwordEditText = (EditText) rootView.findViewById(R.id.password); termsOfUseLinkTextView = (TextView) rootView.findViewById(R.id.register_terms_link); String termsOfUseUrl = getString(R.string.about_link_template, Constants.CATROBAT_TERMS_OF_USE_URL, getString(R.string.register_pocketcode_terms_of_use_text)); termsOfUseLinkTextView.setMovementMethod(LinkMovementMethod.getInstance()); termsOfUseLinkTextView.setText(Html.fromHtml(termsOfUseUrl)); usernameEditText.setText(""); passwordEditText.setText(""); final AlertDialog loginRegisterDialog = new AlertDialog.Builder(getActivity()).setView(rootView) .setTitle(R.string.login_register_dialog_title).setPositiveButton(R.string.login_or_register, null) .setNeutralButton(R.string.password_forgotten, null).create(); loginRegisterDialog.setCanceledOnTouchOutside(true); loginRegisterDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); loginRegisterDialog.setOnShowListener(new OnShowListener() { @Override/*from w ww . j a v a 2 s .c o m*/ public void onShow(DialogInterface dialog) { InputMethodManager inputManager = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); inputManager.showSoftInput(usernameEditText, InputMethodManager.SHOW_IMPLICIT); Button loginRegisterButton = loginRegisterDialog.getButton(AlertDialog.BUTTON_POSITIVE); loginRegisterButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { handleLoginRegisterButtonClick(); } }); Button passwordForgottenButton = loginRegisterDialog.getButton(AlertDialog.BUTTON_NEUTRAL); passwordForgottenButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { handlePasswordForgottenButtonClick(); } }); } }); return loginRegisterDialog; }
From source file:com.none.tom.simplerssreader.view.ReadMoreTextView.java
@SuppressWarnings("SameParameterValue") public void setText(final CharSequence text, final int maxEms) { if (!TextUtils.isEmpty(text) && text.length() > maxEms) { final SpannableStringBuilder ssb = new SpannableStringBuilder(text.subSequence(0, maxEms)); ssb.append('\u2026'); final int textLength = ssb.length(); ssb.append('\n'); ssb.append(getContext().getString(R.string.read_more)); final int readMoreLength = ssb.length() - textLength; ssb.setSpan(new ReadMoreClickableSpan(), textLength, textLength + readMoreLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); super.setText(ssb); setMaxEms(maxEms + readMoreLength); setMovementMethod(LinkMovementMethod.getInstance()); mText = text;/*from ww w. j ava2 s . co m*/ } else { super.setText(text); } }
From source file:com.nextgis.mobile.activity.AboutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); setToolbar(R.id.main_toolbar);// w ww. j a v a 2s. c om mViewPager = (ViewPager) findViewById(com.nextgis.maplibui.R.id.viewPager); PagerAdapter adapter = new TabsAdapter(getSupportFragmentManager()); mViewPager.setAdapter(adapter); mViewPager.addOnPageChangeListener(this); TabLayout tabLayout = (TabLayout) findViewById(com.nextgis.maplibui.R.id.tabs); tabLayout.setupWithViewPager(mViewPager); TextView txtCopyrightText = (TextView) findViewById(R.id.copyright); txtCopyrightText.setText(Html.fromHtml(getString(R.string.copyright))); txtCopyrightText.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:de.tap.easy_xkcd.Activities.AboutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { PrefHelper prefHelper = new PrefHelper(getApplicationContext()); setTheme(prefHelper.getTheme());/* www .j a v a 2 s . co m*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); android.support.v7.widget.Toolbar toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); assert getSupportActionBar() != null; getSupportActionBar().setDisplayHomeAsUpEnabled(true); TypedValue typedValue = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimaryDark, typedValue, true); TypedValue typedValue2 = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, typedValue2, true); toolbar.setBackgroundColor(typedValue2.data); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().setStatusBarColor(typedValue.data); if (!prefHelper.colorNavbar()) getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.ColorPrimaryBlack)); } TextView tvAbout = (TextView) findViewById(R.id.tvAbout); InputStream is = getResources().openRawResource(R.raw.licenses); BufferedReader br = new BufferedReader(new InputStreamReader(is)); StringBuilder sb = new StringBuilder(); String line; try { while ((line = br.readLine()) != null) { sb.append(line); } } catch (IOException e) { Log.e("error:", e.getMessage()); } tvAbout.setText(Html.fromHtml(sb.toString())); tvAbout.setMovementMethod(LinkMovementMethod.getInstance()); }
From source file:com.github.michalbednarski.intentslab.TextFragment.java
private void putTextInView() { if (mText instanceof CharSequence[]) { mFakeLongText.setAdapter(new ArrayAdapter<CharSequence>(getActivity(), 0, (CharSequence[]) mText) { @Override//from w ww. j a va 2s .c o m public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { final TextView textView = new TextView(getContext()); textView.setMovementMethod(LinkMovementMethod.getInstance()); convertView = textView; } ((TextView) convertView).setText(getItem(position)); return convertView; } @Override public boolean areAllItemsEnabled() { return false; } @Override public boolean isEnabled(int position) { return false; } }); mFakeLongText.setVisibility(View.VISIBLE); } else { mXmlTextView.setText((CharSequence) mText); mXmlWrapperView.setVisibility(View.VISIBLE); } mLoaderView.setVisibility(View.GONE); }
From source file:com.eyekabob.VenueInfo.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.venue_info); findViewById(R.id.findLiveMusicButton).setOnClickListener(linksListener); findViewById(R.id.aboutButton).setOnClickListener(linksListener); findViewById(R.id.contactButton).setOnClickListener(linksListener); Venue thisVenue = (Venue) getIntent().getExtras().get("venue"); Map<String, String> params = new HashMap<String, String>(); params.put("venue", thisVenue.getId()); TextView nameView = (TextView) findViewById(R.id.venueNameView); nameView.setText(thisVenue.getName()); TextView infoView = (TextView) findViewById(R.id.venueInfoView); nameView.setText(thisVenue.getName()); String venueDesc = ""; // TODO: Padding instead of whitespace if (!thisVenue.getCity().equals("") && !thisVenue.getStreet().equals("")) { // TODO: I18N venueDesc += "Address:\n " + thisVenue.getStreet() + "\n " + thisVenue.getCity(); }/* www .j ava2 s . com*/ infoView.setText(venueDesc); TextView websiteView = (TextView) findViewById(R.id.venueMoreInfoView); if (!"".equals((thisVenue.getUrl().toString()))) { // TODO: I18N websiteView.setText(Html.fromHtml("<a href=\"" + thisVenue.getUrl() + "\">More Information</a>")); websiteView.setMovementMethod(LinkMovementMethod.getInstance()); } Uri uri = EyekabobHelper.LastFM.getUri("venue.getEvents", params); new RequestTask().execute(uri.toString()); }
From source file:org.iisgcp.waterwalk.fragment.FactFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mImageId = getArguments().getInt(Constants.INTENT_IMAGE_ID); mFactText.setText(Html.fromHtml(getArguments().getString(Constants.INTENT_DESCRIPTION))); mFactText.setMovementMethod(LinkMovementMethod.getInstance()); // First decode with inJustDecodeBounds=true to check dimensions final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true;//from w w w . j a v a 2s.c o m BitmapFactory.decodeResource(getResources(), mImageId, options); int maxWidth; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { maxWidth = getResources().getDisplayMetrics().widthPixels; } else { maxWidth = getResources().getDisplayMetrics().heightPixels; } final int targetWidth = maxWidth; double scale = (double) maxWidth / (double) options.outWidth; final int targetHeight = (int) (options.outHeight * scale); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { mImageView = new ImageView(getActivity()); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(targetWidth, targetHeight); mImageView.setLayoutParams(layoutParams); mLayout.addView(mImageView); } mImageView.setImageDrawable(null); mImageView.setBackgroundColor(getResources().getColor(R.color.gray)); // The ImageFetcher takes care of loading images into our ImageView children asynchronously mImageFetcher = ((FactViewPagerFragment) getParentFragment()).getImageFetcher(); mImageFetcher.setImageSize(targetWidth, targetHeight); }
From source file:org.distantshoresmedia.activities.Main.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from w w w.ja v a2 s.com*/ Main.context = getApplicationContext(); KeyboardDatabaseHandler.initializeDatabaseIfNecessary(this.getApplicationContext()); String html = getResources().getString(R.string.main_body); //html += "<p><i>Version: " + context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName + "</i></p>"; Spanned content = Html.fromHtml(html); TextView description = (TextView) findViewById(R.id.main_description); description.setMovementMethod(LinkMovementMethod.getInstance()); description.setText(content, BufferType.SPANNABLE); final Button setup1 = (Button) findViewById(R.id.main_setup_btn_configure_imes); setup1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivityForResult(new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS), 0); } }); final Button setup2 = (Button) findViewById(R.id.main_setup_btn_set_ime); setup2.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mgr.showInputMethodPicker(); } }); final Activity that = this; final Button setup4 = (Button) findViewById(R.id.main_setup_btn_input_lang); setup4.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { startActivityForResult(new Intent(that, InputLanguageSelection.class), 0); } }); final Button setup5 = (Button) findViewById(R.id.main_setup_btn_update_keyboards); setup5.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { updateKeyboards(); } }); final Button setup6 = (Button) findViewById(R.id.main_setup_btn_keyboard_sharing); setup6.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { sharePressed(); } }); final Button setup7 = (Button) findViewById(R.id.main_setup_btn_bug_reporting); setup7.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { reportBugPressed(); } }); }