uri - How to start new activity by clicking Link in TextView -
i have viewactivity textview in wich set spanned text resource txt file.
viewactivity:
spanned textsp = android.text.html.fromhtml(text); tvtv = (textview)findviewbyid(r.id.tvtv); tvtv.settext(textsp); linkify.addlinks(tvtv, linkify.web_urls);
i create link id information written in article handle textview link click in android app. necessary clicking on link, download secondacitvity (with other textview) of application (not browser).
secondactivity:
protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); setcontentview(r.layout.statya); //пытаемся перейти со ссылки uri data = getintent().getdata(); string data2 = data.getlastpathsegment(); textview tvstatya = (textview)findviewbyid(r.id.tvstatya); tvstatya.settext(data2); }
}
put onclick in xml this
<textview android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onclick="clickfunction"/>
then in java
public void clickfunction(view v) { intent intent = new intent(this, nextactivity.class); startactivity(intent); }
Comments
Post a Comment