当前位置: 首页>>代码示例>>Java>>正文


Java LinkMovementMethod类代码示例

本文整理汇总了Java中android.text.method.LinkMovementMethod的典型用法代码示例。如果您正苦于以下问题:Java LinkMovementMethod类的具体用法?Java LinkMovementMethod怎么用?Java LinkMovementMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LinkMovementMethod类属于android.text.method包,在下文中一共展示了LinkMovementMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAboutDialog

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
/**
 * @brief Shows the dialog to indicate about info
 * @return The new dialog
 * @details Shows the dialog to indicate about info
 */
private Dialog createAboutDialog()
 {
	//necesario para poder clicar en los links
	final TextView message = new TextView(this);
	final SpannableString s = 
               new SpannableString(this.getText(R.string.about_message));
  Linkify.addLinks(s, Linkify.WEB_URLS);
  message.setText(s);
  message.setMovementMethod(LinkMovementMethod.getInstance());
  
  return new AlertDialog.Builder(this)
  .setTitle(R.string.about_title)
  .setView(message)
  .setPositiveButton(R.string.about_ok,
   new DialogInterface.OnClickListener() {
    
    @Override
    public void onClick(DialogInterface dialog, int which) {
     // Auto-generated method stub
     
    }
   }
    )
  .show();
 }
 
开发者ID:CodyyAndroid,项目名称:LibVNCAndroid,代码行数:31,代码来源:ActivityTabs.java

示例2: setHtmlWithLinkClickHandler

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
public static void setHtmlWithLinkClickHandler(TextView tv, String html,
                                        Action1<String> linkClickHandler) {
    CharSequence sequence = Html.fromHtml(html);
    SpannableStringBuilder strBuilder = new SpannableStringBuilder(sequence);
    URLSpan[] urls = strBuilder.getSpans(0, sequence.length(), URLSpan.class);
    for (URLSpan span : urls) {
        int start = strBuilder.getSpanStart(span);
        int end = strBuilder.getSpanEnd(span);
        int flags = strBuilder.getSpanFlags(span);
        ClickableSpan clickable = new ClickableSpan() {
            public void onClick(View view) {
                linkClickHandler.call(span.getURL());
            }
        };
        strBuilder.setSpan(clickable, start, end, flags);
        strBuilder.removeSpan(span);
    }
    tv.setText(strBuilder);
    tv.setMovementMethod(LinkMovementMethod.getInstance());
}
 
开发者ID:TryGhost,项目名称:Ghost-Android,代码行数:21,代码来源:AppUtils.java

示例3: onCreate

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.NoActionBar);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    ButterKnife.bind(this);

    toolbar.setTitleTextColor(ContextCompat.getColor(this, R.color.white));
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_return);
    toolbar.setNavigationOnClickListener(v -> onBackPressed());
    title.setMovementMethod(LinkMovementMethod.getInstance());
}
 
开发者ID:BANKEX,项目名称:smart-asset-iot-android-demo,代码行数:17,代码来源:AboutActivity.java

示例4: onCreate

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
@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);
        }
    });
}
 
开发者ID:minigridems,项目名称:SERC-ENERYGY-METERING-MOBILE-APP,代码行数:26,代码来源:AboutActivity.java

示例5: setText

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
public void setText(String text) {
    int startIndex = 0;
    while (true) {

        int start = text.indexOf("《");
        int end = text.indexOf("》");
        if (start < 0 || end < 0) {
            append(text.substring(startIndex));
            break;
        }

        append(text.substring(startIndex, start));

        SpannableString spanableInfo = new SpannableString(text.substring(start, end + 1));
        spanableInfo.setSpan(new Clickable(spanableInfo.toString()), 0, end + 1 - start, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        append(spanableInfo);
        //setMovementMethod()该方法必须调用,否则点击事件不响应
        setMovementMethod(LinkMovementMethod.getInstance());
        text = text.substring(end + 1);

        LogUtils.e(spanableInfo.toString());
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:BookContentTextView.java

示例6: onCreateDialog

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
@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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:MessageDialog.java

示例7: convert

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
@Override
protected void convert(BaseViewHolder helper, Status item) {
    helper.addOnClickListener(R.id.tweetText);
    switch (helper.getLayoutPosition()%
            3){
        case 0:
            helper.setImageResource(R.id.img,R.mipmap.animation_img1);
            break;
        case 1:
            helper.setImageResource(R.id.img,R.mipmap.animation_img2);
            break;
        case 2:
            helper.setImageResource(R.id.img,R.mipmap.animation_img3);
            break;
    }
    helper.setText(R.id.tweetName,"Hoteis in Rio de Janeiro");
    String msg="\"He was one of Australia's most of distinguished artistes, renowned for his portraits\"";
    ( (TextView)helper.getView(R.id.tweetText)).setText(SpannableStringUtils.getBuilder(msg).append("landscapes and nedes").setClickSpan(clickableSpan).create());
    ( (TextView)helper.getView(R.id.tweetText)).setMovementMethod(LinkMovementMethod.getInstance());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:21,代码来源:NestAdapter.java

示例8: onStart

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
@Override
public void onStart() {
    super.onStart();
    mState.setOnClickListener(this);

    if(negative == 0)
        mNegative.setVisibility(View.GONE);
    else {
        mNegative.setOnClickListener(this);
        mNegative.setText(negative);
    }

    if(positive == 0)
        mPositive.setVisibility(View.GONE);
    else {
        mPositive.setOnClickListener(this);
        mPositive.setText(positive);
    }

    mTitle.setText(title);
    mText.setMovementMethod(LinkMovementMethod.getInstance());
    mText.setText(Html.fromHtml(getString(text)));
    if(bottomSheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED)
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:26,代码来源:BottomSheetMessage.java

示例9: createSadTabView

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
/**
 * @param context Context of the resulting Sad Tab view.
 * @param suggestionAction Action to be executed when user clicks "try these suggestions".
 * @param reloadButtonAction Action to be executed when Reload button is pressed.
 *                           (e.g., refreshing the page)
 * @return A "Sad Tab" view instance which is used in place of a crashed renderer.
 */
public static View createSadTabView(
        Context context, final OnClickListener suggestionAction,
        OnClickListener reloadButtonAction) {
    // Inflate Sad tab and initialize.
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);
    View sadTabView = inflater.inflate(R.layout.sad_tab, null);

    TextView messageText = (TextView) sadTabView.findViewById(R.id.sad_tab_message);
    messageText.setText(getHelpMessage(context, suggestionAction));
    messageText.setMovementMethod(LinkMovementMethod.getInstance());

    Button reloadButton = (Button) sadTabView.findViewById(R.id.sad_tab_reload_button);
    reloadButton.setOnClickListener(reloadButtonAction);

    return sadTabView;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:25,代码来源:SadTabViewFactory.java

示例10: displayShareInfo

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
private void displayShareInfo(final Share share)
{
	final TextView textView = new TextView(this);
	textView.setPadding(5, 5, 5, 5);

	final Spannable message = new SpannableString("Owner: " + share.getUsername() +
			"\nComments: " + ((share.getDescription() == null) ? "" : share.getDescription()) +
			"\nURL: " + share.getUrl() +
			"\nEntry Count: " + share.getEntries().size() +
			"\nVisit Count: " + share.getVisitCount() +
			((share.getCreated() == null) ? "" : ("\nCreation Date: " + share.getCreated().replace('T', ' '))) +
			((share.getLastVisited() == null) ? "" : ("\nLast Visited Date: " + share.getLastVisited().replace('T', ' '))) +
			((share.getExpires() == null) ? "" : ("\nExpiration Date: " + share.getExpires().replace('T', ' '))));

	Linkify.addLinks(message, Linkify.WEB_URLS);
	textView.setText(message);
	textView.setMovementMethod(LinkMovementMethod.getInstance());

	new AlertDialog.Builder(this).setTitle("Share Details").setCancelable(true).setIcon(android.R.drawable.ic_dialog_info).setView(textView).show();
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:21,代码来源:ShareActivity.java

示例11: onCreate

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    findViewById(R.id.btn_play_again).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          
            PrefManager prefManager = new PrefManager(getApplicationContext());

            prefManager.setFirstTimeLaunch(true);

            startActivity(new Intent(MainActivity.this, WelcomeActivity.class));
            finish();
        }
    });

    TextView textView =(TextView)findViewById(R.id.textView);
    textView.setClickable(true);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    String text = "<a href='https://github.com/Kvaibhav01/IntroApp'> Star or Fork this project on GitHub </a>";
    textView.setText(Html.fromHtml(text));
}
 
开发者ID:Kvaibhav01,项目名称:IntroApp,代码行数:27,代码来源:MainActivity.java

示例12: onClickURL

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
private void onClickURL(){
    MovementMethod contributors_descMovementMethod = contributors_desc.getMovementMethod();
    if ((contributors_descMovementMethod == null) || !(contributors_descMovementMethod instanceof LinkMovementMethod)) {
        if (contributors_desc.getLinksClickable()) {
            contributors_desc.setMovementMethod(LinkMovementMethod.getInstance());
        }
    }
    MovementMethod app_report_issues_descMovementMethod = app_report_issues_desc.getMovementMethod();
    if ((app_report_issues_descMovementMethod == null) || !(app_report_issues_descMovementMethod instanceof LinkMovementMethod)) {
        if (app_report_issues_desc.getLinksClickable()) {
            app_report_issues_desc.setMovementMethod(LinkMovementMethod.getInstance());
        }
    }
    MovementMethod app_license_info_descMovementMethod = app_license_info_desc.getMovementMethod();
    if ((app_license_info_descMovementMethod == null) || !(app_license_info_descMovementMethod instanceof LinkMovementMethod)) {
        if (app_license_info_desc.getLinksClickable()) {
            app_license_info_desc.setMovementMethod(LinkMovementMethod.getInstance());
        }
    }
}
 
开发者ID:Pritom14,项目名称:Password-Storage,代码行数:21,代码来源:AboutUsActivity.java

示例13: displayVideoInfo

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
@Override
public void displayVideoInfo(Video video) {
    if(nonNull(mRootView)){
        mRootView.findViewById(R.id.content).setVisibility(View.VISIBLE);
        mRootView.findViewById(R.id.loading_root).setVisibility(View.GONE);
    }

    safelySetText(mTitleText, video.getTitle());

    if(nonNull(mSubtitleText)){
        Spannable subtitle = OwnerLinkSpanFactory.withSpans(video.getDescription(), true, false, ownerLinkAdapter);

        mSubtitleText.setText(subtitle, TextView.BufferType.SPANNABLE);
        mSubtitleText.setMovementMethod(LinkMovementMethod.getInstance());
    }

    String imageUrl = video.getMaxResolutionPhoto();

    if (nonEmpty(imageUrl) && nonNull(mPreviewImage)) {
        PicassoInstance.with()
                .load(imageUrl)
                .into(mPreviewImage);
    }
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:25,代码来源:VideoPreviewFragment.java

示例14: onCustomiseDialog

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
@Override
protected @NonNull DynamicDialog onCustomiseDialog(@NonNull DynamicDialog alertDialog,
                                                   @Nullable Bundle savedInstanceState) {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_about,
            new LinearLayout(getContext()), false);
    TextView message = view.findViewById(R.id.dialog_about_text);

    message.setText(Html.fromHtml(getString(R.string.about_content)
            .replace("\n", "<br/>")));
    message.setTextSize(TypedValue.COMPLEX_UNIT_SP, TEXT_SIZE);
    message.setLineSpacing(0f, 1.2f);
    message.setMovementMethod(LinkMovementMethod.getInstance());
    message.setLinkTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));

    alertDialog.setView(view);
    return alertDialog;
}
 
开发者ID:pranavpandey,项目名称:dynamic-toasts,代码行数:18,代码来源:AboutDialogFragment.java

示例15: displayPost

import android.text.method.LinkMovementMethod; //导入依赖的package包/类
public void displayPost(CharSequence title, CharSequence author, CharSequence content,
                        String link) {
    View v = LayoutInflater.from(this).inflate(R.layout.post_row, mainlist, false);
    ((TextView) v.findViewById(R.id.title))
            .setText(title);
    ((TextView) v.findViewById(R.id.author)).setText(author);
    if (content != null || link != null) {
        ((TextView) v.findViewById(R.id.content))
                .setMovementMethod(LinkMovementMethod.getInstance());
        v.findViewById(R.id.content).setVisibility(View.VISIBLE);
        if (content != null) {
            ((TextView) v.findViewById(R.id.content)).setText(content);
        } else if (link != null) {
            ((TextView) v.findViewById(R.id.content))
                    .setText(Util.linkToSpan(link));
        }
    }
    mainlist.addView(v);
}
 
开发者ID:PaulKlinger,项目名称:Sprog-App,代码行数:20,代码来源:PoemActivity.java


注:本文中的android.text.method.LinkMovementMethod类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。