TextView
object.
ClickableSpan
that allows setting a URL string.
TextView
is to display and also sets whether it is stored in a styleable/spannable buffer and whether it is editable.
Next Page ⇒ ⇐ Home Page |
|
|
package com.example.wenchen.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.content.Intent; import android.view.View; import android.widget.TextView; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.URLSpan; public class NextActivity extends AppCompatActivity { /** Called when the activity is first created. */ @Override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.activity_next ); TextView tv = (TextView) findViewById( R.id.tvView ); MainActivity.makeTextViewHyperlink( tv ); tv.setOnClickListener( new View.OnClickListener( ) { @Override public void onClick( View v ) { Intent intent = new Intent( NextActivity.this, MainActivity.class ); startActivity( intent ); } } ); } // Sets a hyperlink style to the textview. public static void makeTextViewHyperlink( TextView tv ) { SpannableStringBuilder ssb = new SpannableStringBuilder( ); ssb.append( tv.getText( ) ); ssb.setSpan( new URLSpan("#"), 0, ssb.length( ), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE ); tv.setText( ssb, TextView.BufferType.SPANNABLE ); } } |
Why do they lock gas station bathrooms? Are they afraid someone will clean them? – George Carlin |