本文整理汇总了Java中android.widget.TextView.setMovementMethod方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setMovementMethod方法的具体用法?Java TextView.setMovementMethod怎么用?Java TextView.setMovementMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setMovementMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 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();
}
示例2: onCreate
import android.widget.TextView; //导入方法依赖的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);
}
});
}
示例3: initializeLinks
import android.widget.TextView; //导入方法依赖的package包/类
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());
}
示例4: onCreateDialog
import android.widget.TextView; //导入方法依赖的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();
}
示例5: onCreateView
import android.widget.TextView; //导入方法依赖的package包/类
@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;
}
示例6: maybeShowCompatWarningDialog
import android.widget.TextView; //导入方法依赖的package包/类
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();
}
}
示例7: setData
import android.widget.TextView; //导入方法依赖的package包/类
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());
}
}
示例8: showDialogAbout
import android.widget.TextView; //导入方法依赖的package包/类
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());
}
}
示例9: onCreateView
import android.widget.TextView; //导入方法依赖的package包/类
@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);
}
示例10: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
@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());
}
}
}
});
}
示例11: addLinkMovementMethod
import android.widget.TextView; //导入方法依赖的package包/类
private static final void addLinkMovementMethod(TextView t) {
MovementMethod m = t.getMovementMethod();
if ((m == null) || !(m instanceof LinkMovementMethod)) {
if (t.getLinksClickable()) {
t.setMovementMethod(LinkMovementMethod.getInstance());
}
}
}
示例12: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
@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());
}
示例13: createAndShowDialog
import android.widget.TextView; //导入方法依赖的package包/类
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));
}
}
}
示例14: onCreate
import android.widget.TextView; //导入方法依赖的package包/类
@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);
}
示例15: configureLinksBehavior
import android.widget.TextView; //导入方法依赖的package包/类
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;
}
});
}