我正在尝试在 Fragment 中使用 linkify,但我无法将其实际链接,也找不到有关如何正确使用它的文档。如果有人可以提供帮助,那就太好了!
联系片段.java:
public class ContactFragment extends SherlockFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup group,
Bundle saved) {
View V = inflater.inflate(R.layout.activity_contact_fragment, group, false);
TextView myEmail= (TextView) V.findViewById(R.id.textView1);
myEmail.setText("info@komodostudios.com");
Linkify.addLinks(myEmail, Linkify.EMAIL_ADDRESSES);
return inflater.inflate(R.layout.activity_contact_fragment, group, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
}
activity_contact_fragment.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ContactFragment" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="info@komodostudios.com" />
</RelativeLayout>