Java Code Examples for android.widget.TextView.setMovementMethod()

The following are Jave code examples for showing how to use setMovementMethod() of the android.widget.TextView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: orgzly-android   File: WhatsNewDialog.java   View Source Code Vote up 6 votes
/**
 * Display dialog with changes.
 */
public static AlertDialog create(Context context) {
    @SuppressLint("InflateParams") final View layoutView =
            ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
                    .inflate(R.layout.dialog_whats_new, null, false);

    TextView view = ((TextView) layoutView.findViewById(R.id.dialog_whats_new_intro));
    view.setText(MiscUtils.fromHtml(context.getString(R.string.whats_new_intro)));
    view.setMovementMethod(LinkMovementMethod.getInstance());

    return new AlertDialog.Builder(context)
            .setTitle(R.string.whats_new_title)
            .setPositiveButton(R.string.ok, null)
            .setView(layoutView)
            .create();
}
 
Example 2
Project: SERC-ENERYGY-METERING-MOBILE-APP   File: AboutActivity.java   View Source Code Vote up 6 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);


    // about_page_textview has links specified by putting <a> tags in the string
    // resource.  By default these links will appear but not
    // respond to user input.  To make them active, you need to
    // call setMovementMethod() on the TextView object.
    TextView aboutPageText = (TextView) findViewById(R.id.about_page_textview);
    aboutPageText.setMovementMethod(LinkMovementMethod.getInstance());

    // This makes the image clickable
    ImageView img = (ImageView)findViewById(R.id.about_page_image);
    img.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setData(Uri.parse("http://serc.strathmore.edu/"));
            startActivity(intent);
        }
    });
}
 
Example 3
Project: PeSanKita-android   File: RegistrationProgressActivity.java   View Source Code Vote up 6 votes
private void initializeLinks() {
  TextView        failureText     = (TextView) findViewById(R.id.sms_failed_text);
  String          pretext         = getString(R.string.registration_progress_activity__signal_timed_out_while_waiting_for_a_verification_sms_message);
  String          link            = getString(R.string.RegistrationProblemsActivity_possible_problems);
  SpannableString spannableString = new SpannableString(pretext + " " + link);

  spannableString.setSpan(new ClickableSpan() {
    @Override
    public void onClick(View widget) {
      new AlertDialog.Builder(RegistrationProgressActivity.this)
              .setTitle(R.string.RegistrationProblemsActivity_possible_problems)
              .setView(R.layout.registration_problems)
              .setNeutralButton(android.R.string.ok, null)
              .show();
    }
  }, pretext.length() + 1, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

  failureText.setText(spannableString);
  failureText.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 4
Project: GitHub   File: MessageDialog.java   View Source Code Vote up 6 votes
@SuppressLint("InflateParams")
@Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
	View dialogView = LayoutInflater.from(getActivity())
			.inflate(R.layout.dialog_message, null);

	TextView messageView = (TextView) dialogView.findViewById(R.id.message);
	messageView.setMovementMethod(LinkMovementMethod.getInstance());
	messageView.setText(Html.fromHtml(getArguments().getString(ARG_MESSAGE)));

	AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.AppTheme_AlertDialog);
	builder.setTitle(getArguments().getString(ARG_TITLE))
			.setIcon(getArguments().getInt(ARG_ICON))
			.setView(dialogView)
			.setPositiveButton(R.string.OK, new OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.dismiss();
				}
			});

	return builder.create();
}
 
Example 5
Project: KernelAdiutor-Mod   File: DescriptionFragment.java   View Source Code Vote up 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 6
Project: GravityBox   File: GravityBoxSettings.java   View Source Code Vote up 6 votes
private void maybeShowCompatWarningDialog() {
    final int stage = mPrefs.getInt("compat_warning_stage", 0);
    if (stage < 2) {
        final TextView msgView = new TextView(getActivity());
        msgView.setText(R.string.compat_warning_message);
        msgView.setMovementMethod(LinkMovementMethod.getInstance());
        final int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16,
                getResources().getDisplayMetrics());
        msgView.setPadding(padding, padding, padding, padding);
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.compat_warning_title);
        builder.setView(msgView);
        builder.setPositiveButton(stage == 0 ? R.string.compat_warning_ok_stage1 :
                R.string.compat_warning_ok_stage2, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                mPrefs.edit().putInt("compat_warning_stage", (stage + 1)).commit();
            }
        });
        builder.setNegativeButton(android.R.string.cancel, null);
        mDialog = builder.create();
        mDialog.show();
    }
}
 
Example 7
Project: ConnectU   File: AnunciosViewActivity.java   View Source Code Vote up 5 votes
void setData() {
    TextView title = (TextView) findViewById(R.id.a_title_view);
    TextView type = (TextView) findViewById(R.id.a_type_view);
    TextView subject = (TextView) findViewById(R.id.a_location_view);
    TextView time = (TextView) findViewById(R.id.a_time_view);
    TextView text = (TextView) findViewById(R.id.htexto);
    TextView teacher = (TextView) findViewById(R.id.profesor);

    if (Build.VERSION.SDK_INT >= 21) {
        getWindow().setNavigationBarColor(Color.parseColor(ColorHelper.getColor(data.getType().charAt(0))));
        getWindow().setStatusBarColor(Color.parseColor(ColorHelper.getColor(data.getType().charAt(0))));
    }

    title.setText(data.getTitle());
    type.setText(data.getType());
    subject.setText(data.getSubject());
    text.setText((CharSequence) Html.fromHtml(Uri.parse(data.getText()).toString()));
    text.setMovementMethod(LinkMovementMethod.getInstance());
    teacher.setText(data.getTeacher());

    String ndate = TimeParserHelper.parseTimeDate(getBaseContext(), data.getDate(true));
    if (ndate.length() != 0) {
        time.setText(ndate);
    } else {
        time.setText(data.getDate());
    }

}
 
Example 8
Project: Wallpapers-Android-Clean-Architecture   File: OnBoardingActivity.java   View Source Code Vote up 5 votes
private void showDialogAbout() {
    final SpannableString m = new SpannableString(getString(R.string.dialog_about_text));
    Linkify.addLinks(m, Linkify.WEB_URLS);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.title_about);
    builder.setMessage(m);
    builder.setPositiveButton(R.string.dialog_ok, null);
    AlertDialog alertDialog = builder.show();

    TextView textView = alertDialog.findViewById(android.R.id.message);
    if (textView != null) {
        textView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}
 
Example 9
Project: ShangHanLun   File: TipsWindow.java   View Source Code Vote up 5 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mGroup = (ViewGroup) getActivity().getWindow().getDecorView();
    view = inflater.inflate(R.layout.tips_window, null);
    textView = (TextView) view.findViewById(R.id.tipsview);
    textView.setMovementMethod(LocalLinkMovementMethod
            .getInstance());
    textView.setText(getTipsString());
    mGroup.addView(view);
    return super.onCreateView(inflater, container, savedInstanceState);
}
 
Example 10
Project: UartBridge   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    setContentView(R.layout.activity_main);

    mHandler = new MyHandler(this);

    display = (TextView) findViewById(R.id.outputMonitor);
    display.setMovementMethod(new ScrollingMovementMethod());

    editText = (EditText) findViewById(R.id.outputSendText);
    Button sendButton = (Button) findViewById(R.id.buttonSend);
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!editText.getText().toString().equals("")) {
                String data = editText.getText().toString();
                if (usbService != null) { // if UsbService was correctly binded, Send data
                    display.append(data);
                    usbService.write(data.getBytes());
                }
            }
        }
    });
}
 
Example 11
Project: qmui   File: QMUILinkify.java   View Source Code Vote up 5 votes
private static final void addLinkMovementMethod(TextView t) {
    MovementMethod m = t.getMovementMethod();

    if ((m == null) || !(m instanceof LinkMovementMethod)) {
        if (t.getLinksClickable()) {
            t.setMovementMethod(LinkMovementMethod.getInstance());
        }
    }
}
 
Example 12
Project: Canvas-Vision   File: LicenseActivity.java   View Source Code Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.license_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_license);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(getResources().getString(R.string.License));
    TextView t = (TextView) findViewById(R.id.license);
    t.setMovementMethod(LinkMovementMethod.getInstance());
    TextView t2 = (TextView) findViewById(R.id.license2);
    t2.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 13
Project: urdu-font-comparator-app   File: Utils.java   View Source Code Vote up 5 votes
private static void createAndShowDialog(Context context, String title,
                                        SpannableString message, boolean showOkButton) {

    Linkify.addLinks(message, Patterns.WEB_URL, null, new Linkify.MatchFilter() {
        @Override
        public boolean acceptMatch(CharSequence seq, int start, int end) {
            return Linkify.sUrlMatchFilter.acceptMatch(seq, start, end);
        }
    }, null);

    final Dialog dialog = new LovelyInfoDialog(context)
            .setTopColorRes(R.color.colorPrimaryLight)
            .setTitle(title)
            .setIcon(R.drawable.ic_info_outline)
            .setMessage(message)
            .show();

    TextView tvMessage = (TextView) dialog.findViewById(R.id.ld_message);
    if (tvMessage != null) {
        tvMessage.setMovementMethod(LinkMovementMethod.getInstance());
        tvMessage.setLinkTextColor(ContextCompat.getColor(context, R.color.blue));
    }

    if (showOkButton) {
        Button btnOk = (Button) dialog.findViewById(R.id.ld_btn_confirm);
        if (btnOk != null) {
            btnOk.setText(R.string.button_ok);
            btnOk.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryDark));
        }
    }
}
 
Example 14
Project: crossword   File: HelpActivity.java   View Source Code Vote up 5 votes
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    // Get preferences
    SharedPreferences preferences =
        PreferenceManager.getDefaultSharedPreferences(this);
    boolean dark = preferences.getBoolean(Main.PREF_DARK, false);

    if (dark)
        setTheme(R.style.AppDarkTheme);

    setContentView(R.layout.help);

    TextView view = (TextView)findViewById(R.id.help);
    String text = RawTextReader.read(this, R.raw.help);
    if (view != null)
    {
        view.setMovementMethod(LinkMovementMethod.getInstance());
        view.setText(Html.fromHtml(text));
    }

    // Enable back navigation on action bar
    ActionBar actionBar = getActionBar();
    if (actionBar != null)
        actionBar.setDisplayHomeAsUpEnabled(true);
}
 
Example 15
Project: FinalProject   File: MessagesListAdapter.java   View Source Code Vote up 5 votes
protected void configureLinksBehavior(final TextView text) {
    text.setLinksClickable(false);
    text.setMovementMethod(new LinkMovementMethod() {
        @Override
        public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
            boolean result = false;
            if (!isSelectionModeEnabled) {
                result = super.onTouchEvent(widget, buffer, event);
            }
            itemView.onTouchEvent(event);
            return result;
        }
    });
}
 
Example 16
Project: SDHtmlTextView   File: MainActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String html=loadStringFromAssetFile(this,"example.html");
    TextView tv = (TextView) findViewById(R.id.twxt);
    int col=tv.getSolidColor();
    HtmlSpanner htmlSpanner=new HtmlSpanner();
    htmlSpanner.setBackgroundColor(col);
    tv.setText(htmlSpanner.fromHtml(html));
    tv.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 17
Project: crossword   File: Main.java   View Source Code Vote up 5 votes
private boolean onAboutClick(MenuItem item)
{
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.about);

    DateFormat dateFormat = DateFormat.getDateTimeInstance();
    String format = getString(R.string.version);

    String message =
        String.format(Locale.getDefault(),
                      format, BuildConfig.VERSION_NAME,
                      dateFormat.format(BuildConfig.BUILT));
    builder.setMessage(message);

    // Add the button
    builder.setPositiveButton(android.R.string.ok, null);

    // Create the AlertDialog
    Dialog dialog = builder.show();

    // Set movement method
    TextView text = (TextView) dialog.findViewById(android.R.id.message);
    if (text != null)
        text.setMovementMethod(LinkMovementMethod.getInstance());

    return true;
}
 
Example 18
Project: Markwon   File: Markwon.java   View Source Code Vote up 5 votes
/**
 * Helper method to apply parsed markdown. Please note, that if images or tables are used
 *
 * @param view {@link TextView} to set markdown into
 * @param text parsed markdown
 * @see #scheduleDrawables(TextView)
 * @see #scheduleTableRows(TextView)
 * @since 1.0.0
 */
public static void setText(@NonNull TextView view, CharSequence text) {

    unscheduleDrawables(view);
    unscheduleTableRows(view);

    // update movement method (for links to be clickable)
    view.setMovementMethod(LinkMovementMethod.getInstance());
    view.setText(text);

    // schedule drawables (dynamic drawables that can change bounds/animate will be correctly updated)
    scheduleDrawables(view);
    scheduleTableRows(view);
}
 
Example 19
Project: fragmentnav   File: FmBase.java   View Source Code Vote up 4 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View childView = inflater.inflate(R.layout.fm_fn_test, container, false);
    childView.setTag(getClass().getSimpleName());
    ((TextView) childView.findViewById(R.id.tv_title)).setText(getClass().getSimpleName());
    tvLog = (TextView) childView.findViewById(R.id.tv_log);
    tvLog.setMovementMethod(new ScrollingMovementMethod());

    Button actionBtn = (Button) childView.findViewById(R.id.test_btn);
    Action action = (Action) getArguments().getSerializable(KEY_ACTION);
    if(action != null){
        actionBtn.setText(action.text);
    } else {
        actionBtn.setText("Back To Enter");
    }

    actionBtn.setOnClickListener(this);

    childView.post(new Runnable() {
        @Override
        public void run() {
            showFragmentState();
        }
    });

    Androids.setOnClickListener(childView, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.btn_goback:
                    finish();
                    break;
                case R.id.test_btn2:
                    openPermissionSettnig();
                    break;
            }

        }
    }, R.id.btn_goback, R.id.test_btn2);
    return childView;
}
 
Example 20
Project: SystemUITuner2   File: About.java   View Source Code Vote up 4 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_about, container, false);

    if ( getActivity() instanceof MainActivity){
        activity = (MainActivity) getActivity();
    }

    //define version TextViews
    TextView versionName = view.findViewById(R.id.vername);
    TextView versionNum = view.findViewById(R.id.vernum);
    TextView buildDate = view.findViewById(R.id.build_date);
    TextView imageCredit = view.findViewById(R.id.image_credit);
    TextView appCredit = view.findViewById(R.id.app_credit);
    TextView spanishCredit = view.findViewById(R.id.spanish_credit);

    imageCredit.setMovementMethod(LinkMovementMethod.getInstance());
    appCredit.setMovementMethod(LinkMovementMethod.getInstance());
    spanishCredit.setMovementMethod(LinkMovementMethod.getInstance());

    try { //add version info to TextViews
        PackageInfo pInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
        String version = pInfo.versionName;
        int verCode = pInfo.versionCode;
        versionName.append(" " + version);
        versionNum.append(String.valueOf(" " + verCode));

        Date buildD = new Date(BuildConfig.TIMESTAMP);
        buildDate.append(" " + String.valueOf(buildD));
    } catch (Exception e) {
        Log.e("SysUITuner/E", e.getMessage());
    }

    Button donate = view.findViewById(R.id.donate_paypal);
    donate.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.setThings.donate();
        }
    });

    return view;
}