Place a link in an android cardview connected to the database in Firebase

1

 public void setLink(String link)
{TextView post_link = (TextView)mView.findViewById(R.id.linkText);
 post_link.setText(link);}

I am creating a recycleview list and within them a cardview connected to my firebase database. but as I do to place a (link) in each cardview that directs me to certain web , it can be a "Go" button. this url to go to "go" should be connected to firebase, so that it is updated according to the needs

    
asked by Elihat Caceres 03.01.2017 в 20:01
source

1 answer

0

There are several methods, if you have a link in your TextView , you can simply enable the links using the method setLinksClickable () :

myTextView.setLinksClickable(true);

for example:

public void setLink(String link)
{ 
  TextView post_link = (TextView)mView.findViewById(R.id.linkText);
   post_link.setLinksClickable(true);
   post_link.setText(link);

}

in this way all the "links" will be sensitive!

This form can also be configured directly in TextView :

<TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="http://stackoverflow.com"

        android:autoLink="web"
        android:linksClickable="true"/>

The other way is through an Intent when clicking on the view:

post_link.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    String url = "http://stackoverflow.com";
                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(url));
                    startActivity(i);
                }
            });
    
answered by 03.01.2017 / 20:23
source