Wednesday, 5 June 2013

Hyperlink in Android TextView tutorial

By this post i am  gonna teach about How to set Hyperlink effect in Android Text View.


Design Code (XML)


<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:id="@+id/mywidget"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="" />
</RelativeLayout>
Activity Code. 

public class MainActivity extends Activity {
   
   

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        TextView tvMessage = (TextView) findViewById(R.id.textview1);
       
        tvMessage.setText(Html.  
                fromHtml("www.google.com"));
        Linkify.addLinks(tvMessage, Linkify.ALL);

 Hope this helps . Happy Coding.

1 comment:

Anonymous said...

www.easyyar.com is a best jobs site, Search for Job Vacancies IT, Software, Govt., Technical and other jobs.Post your resume now and get your first dream job!

http://www.easyyar.com