Java Code Examples for android.widget.TextView#setLinksClickable()

The following examples show how to use android.widget.TextView#setLinksClickable() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: CapturePacket   File: HelpFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    Toolbar toolbar =  view.findViewById(R.id.tool_bar);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            FragmentActivity activity = getActivity();
            if (activity != null) {
                activity.getSupportFragmentManager()
                        .popBackStackImmediate();
            }
        }
    });
    TextView textView = view.findViewById(R.id.tv_content);
    textView.setAutoLinkMask(Linkify.WEB_URLS);
    textView.setLinkTextColor(0xffFF4081);
    textView.setLinksClickable(true);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 2
@Override
protected void configureLinksBehavior(TextView text) {
    text.setLinksClickable(false);

    text.setMovementMethod(new LinkMovementMethod(){
        @Override
        public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
            if (isSelectionMode) return true;

            if (Patterns.WEB_URL.matcher(buffer.toString()).matches()) {
                getParentFragment().launchWebView(buffer.toString());
                return true;
            }
            itemView.onTouchEvent(event);
            return false;
        }
    });
}
 
Example 3
@Override
protected void configureLinksBehavior(TextView text) {
    text.setLinksClickable(false);

    text.setMovementMethod(new LinkMovementMethod(){
        @Override
        public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) {
            if (isSelectionMode) return true;

            if (Patterns.WEB_URL.matcher(buffer.toString()).matches()) {
                getParentFragment().launchWebView(buffer.toString());
                return true;
            }
            itemView.onTouchEvent(event);
            return false;
        }
    });
}
 
Example 4
private View inflateRowItem(String title, String value) {
    View view;
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.detailed_poi_tagitem, null);

    //LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.rowContainer);
    TextView titleTextView = (TextView) view.findViewById(R.id.rowTitle);
    TextView valueTextView = (TextView) view.findViewById(R.id.rowValue);
    titleTextView.setText(title);
    valueTextView.setText(value);
    //Linking content
    if (title.toLowerCase().equals("email") || title.toLowerCase().equals("contact:email")) {
        Linkify.addLinks(valueTextView, Linkify.EMAIL_ADDRESSES);
        valueTextView.setLinksClickable(true);
    }
    if (title.toLowerCase().equals("website") || title.toLowerCase().equals("contact:website")) {
        Linkify.addLinks(valueTextView, Linkify.WEB_URLS);
        valueTextView.setLinksClickable(true);
    }
    if (title.toLowerCase().equals("phone") || title.toLowerCase().equals("phone:mobile") || title.toLowerCase().equals("contact:mobile") || title.toLowerCase().equals("contact:phone")) {
        Linkify.addLinks(valueTextView, Linkify.PHONE_NUMBERS);
        valueTextView.setLinksClickable(true);
    }
    return view;
}
 
Example 5
public static void showProDialog(final Context context) {
    AlertDialog builder = new AlertDialog.Builder(context)
            .setTitle(R.string.pro_user_only)
            .setMessage(R.string.get_pro)
            .setPositiveButton(R.string.login, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    Intent intent = new Intent(context, NGIDLoginActivity.class);
                    context.startActivity(intent);
                }
            })
            .setNegativeButton(android.R.string.cancel, null)
            .show();

    TextView message = builder.findViewById(android.R.id.message);
    if (message != null) {
        message.setMovementMethod(LinkMovementMethod.getInstance());
        message.setLinksClickable(true);
    }
}
 
Example 6
Source Project: ChatKit   File: MessagesListAdapter.java    License: Apache License 2.0 5 votes vote down vote up
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 7
Source Project: ChatKit   File: MessageHolders.java    License: Apache License 2.0 5 votes vote down vote up
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 (!MessagesListAdapter.isSelectionModeEnabled) {
                result = super.onTouchEvent(widget, buffer, event);
            }
            itemView.onTouchEvent(event);
            return result;
        }
    });
}
 
Example 8
public TextView generate(Context context) {
    TextView textView = new TextView(context);
    textView.setText(hint);
    textView.setAutoLinkMask(Linkify.WEB_URLS);
    textView.setLinksClickable(true);
    textView.setLinkTextColor(Color.YELLOW);
    Linkify.addLinks(textView, Linkify.WEB_URLS);
    return textView;
}
 
Example 9
private void showHelp() {
	CharSequence title = Logger.fmt("%s v%s", ThisApplication.name(),
			ThisApplication.version());
	CharSequence info = Html.fromHtml(getString(R.string.info_about));

	TextView tv = (TextView) getLayoutInflater().inflate(
			R.layout.dialog_message, null);
	tv.setLinksClickable(true);
	tv.setMovementMethod(LinkMovementMethod.getInstance());
	tv.setText(info);

	new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT)
			.setTitle(title).setView(tv)
			.setNeutralButton(R.string.action_ok, null).show();
}
 
Example 10
private TextView getAttributionOverlay(Context context) {
    attributionOverlay = new TextView(context);
    attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"));
    attributionOverlay.setShadowLayer(1,-1,-1, Color.WHITE);
    attributionOverlay.setLinksClickable(true);
    attributionOverlay.setMovementMethod(LinkMovementMethod.getInstance());
    return attributionOverlay;
}
 
Example 11
private TextView getAttributionOverlay(Context context) {
    attributionOverlay = new TextView(context);
    attributionOverlay.setText(Html.fromHtml("© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a> contributors"));
    attributionOverlay.setShadowLayer(1, -1, -1, Color.WHITE);
    attributionOverlay.setLinksClickable(true);
    attributionOverlay.setMovementMethod(LinkMovementMethod.getInstance());
    return attributionOverlay;
}
 
Example 12
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = View.inflate(context, R.layout.adapter_act_player, null);
    }
    final CheckBox cb_item = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.cb_item);
    TextView tv_name = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_name);
    TextView tv_time = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_time);
    TextView tv_status = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_status);
    TextView tv_desc = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_desc);
    TextView tv_more = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.tv_more);
    View v_margin_bottom = com.youzu.clan.base.widget.ViewHolder.get(convertView, R.id.v_margin_bottom);

    cb_item.setTag(position);
    final ActPlayer child = (ActPlayer) getItem(position);
    if (child != null) {
        if (child.isChecked) {
            cb_item.setChecked(true);
        } else {
            cb_item.setChecked(false);
        }
        tv_name.setText(child.getUsername());
        tv_name.setTextColor(_themeColor);
        tv_time.setText(child.getDateline());

        if (child.getVerified().equals("1")) {
            //用户是否通过审核,0:等待审核,1:已通过审核,2:打回完善资料
            tv_status.setTextColor(_themeColor);
            tv_status.setText(R.string.z_act_manage_check_success);
        } else if (child.getVerified().equals("2")) {
            tv_status.setTextColor(context.getResources().getColor(R.color.z_txt_c_act_publish_step_n));
            tv_status.setText(R.string.z_act_manage_check_fail);
        } else {
            tv_status.setTextColor(context.getResources().getColor(R.color.z_txt_c_act_publish_step_n));
            tv_status.setText(R.string.z_act_manage_check_null);
        }

        if (child.mode == 0) {//没有更多
            tv_desc.setText(child.desc);
            tv_more.setVisibility(View.GONE);
            v_margin_bottom.setVisibility(View.VISIBLE);
        } else {
            tv_more.setVisibility(View.VISIBLE);
            v_margin_bottom.setVisibility(View.GONE);
        }
        if (child.mode == 1) {//有更多,收起状态
            tv_desc.setText(child.desc_short);
            tv_more.setText(R.string.z_act_manage_player_info_more);
        }
        if (child.mode == 2) {//有更多,展开状态
            tv_desc.setText(child.desc);
            tv_more.setText(R.string.z_act_manage_player_info_less);
        }

        tv_desc.setLinksClickable(true);
        tv_desc.setMovementMethod(LinkMovementMethod.getInstance());

        cb_item.setOnCheckedChangeListener(new MyOnCheckedChangeListener(cb_item, position));
        tv_more.setOnClickListener(new MyOnTvMoreClickListener(tv_desc, child));
    }
    return convertView;
}
 
Example 13
Source Project: Noyze   File: HelpActivity.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Generates our layout in-code. Only called once, then
 * we'll be sure to recycle these {@link View}s.
 */
public final View makeLayout() {

	// Layout Parameters.
          DisplayMetrics dm = new DisplayMetrics();
          WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
          wm.getDefaultDisplay().getMetrics(dm);
          final int[] mWindowDims = new int[] { dm.widthPixels, dm.heightPixels };
	final int mWindowWidth = mWindowDims[0],
			  mMaxWidth = mContext.getResources().getDimensionPixelSize(R.dimen.max_menu_width);
	final int gutter = mContext.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
	final FrameLayout.LayoutParams mParams = new FrameLayout.LayoutParams(
		((mWindowWidth > mMaxWidth) ? mMaxWidth : android.view.ViewGroup.LayoutParams.MATCH_PARENT),
		android.view.ViewGroup.LayoutParams.MATCH_PARENT);
	final RelativeLayout.LayoutParams mTextParams = new RelativeLayout.LayoutParams(
		android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
	mTextParams.addRule(RelativeLayout.CENTER_IN_PARENT);
	mParams.gravity = Gravity.CENTER;
	
	// Main text and image.
	final TextView text = new TextView(mContext);
          text.setTextColor(Color.DKGRAY);
	text.setId(R.id.help_text);
	text.setLayoutParams(mTextParams);
	text.setGravity(Gravity.CENTER_HORIZONTAL);
	text.setMovementMethod(LinkMovementMethod.getInstance());
	text.setLinksClickable(true);
	final int mTextSize = mContext.getResources()
		.getDimensionPixelSize(R.dimen.help_text_size);
	text.setTextSize(mTextSize);
	
	text.setCompoundDrawablePadding((gutter/2));
	text.setPadding(gutter, gutter, gutter, gutter);
	
	// Allow the View to Scroll vertically if necessary.
	final ScrollView scroll = new ScrollView(mContext);
	scroll.setLayoutParams(mParams);
	scroll.setFillViewport(true);
	scroll.setSmoothScrollingEnabled(true);
	scroll.setVerticalScrollBarEnabled(false);
	final RelativeLayout layout = new RelativeLayout(mContext);
	mParams.topMargin = mParams.bottomMargin = mContext.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin);
          mParams.leftMargin = mParams.rightMargin = mContext.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
	layout.setLayoutParams(mParams);
	layout.addView(text);
	scroll.addView(layout);
	
	return scroll;
}
 
Example 14
Source Project: Noyze   File: HelpActivity.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Generates our layout in-code. Only called once, then
 * we'll be sure to recycle these {@link View}s.
 */
public final View makeLayout() {

	// Layout Parameters.
          DisplayMetrics dm = new DisplayMetrics();
          WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
          wm.getDefaultDisplay().getMetrics(dm);
          final int[] mWindowDims = new int[] { dm.widthPixels, dm.heightPixels };
	final int mWindowWidth = mWindowDims[0],
			  mMaxWidth = mContext.getResources().getDimensionPixelSize(R.dimen.max_menu_width);
	final int gutter = mContext.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
	final FrameLayout.LayoutParams mParams = new FrameLayout.LayoutParams(
		((mWindowWidth > mMaxWidth) ? mMaxWidth : android.view.ViewGroup.LayoutParams.MATCH_PARENT),
		android.view.ViewGroup.LayoutParams.MATCH_PARENT);
	final RelativeLayout.LayoutParams mTextParams = new RelativeLayout.LayoutParams(
		android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
	mTextParams.addRule(RelativeLayout.CENTER_IN_PARENT);
	mParams.gravity = Gravity.CENTER;
	
	// Main text and image.
	final TextView text = new TextView(mContext);
          text.setTextColor(Color.DKGRAY);
	text.setId(R.id.help_text);
	text.setLayoutParams(mTextParams);
	text.setGravity(Gravity.CENTER_HORIZONTAL);
	text.setMovementMethod(LinkMovementMethod.getInstance());
	text.setLinksClickable(true);
	final int mTextSize = mContext.getResources()
		.getDimensionPixelSize(R.dimen.help_text_size);
	text.setTextSize(mTextSize);
	
	text.setCompoundDrawablePadding((gutter/2));
	text.setPadding(gutter, gutter, gutter, gutter);
	
	// Allow the View to Scroll vertically if necessary.
	final ScrollView scroll = new ScrollView(mContext);
	scroll.setLayoutParams(mParams);
	scroll.setFillViewport(true);
	scroll.setSmoothScrollingEnabled(true);
	scroll.setVerticalScrollBarEnabled(false);
	final RelativeLayout layout = new RelativeLayout(mContext);
	mParams.topMargin = mParams.bottomMargin = mContext.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin);
          mParams.leftMargin = mParams.rightMargin = mContext.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin);
	layout.setLayoutParams(mParams);
	layout.addView(text);
	scroll.addView(layout);
	
	return scroll;
}