【发布时间】:2013-03-24 06:43:53
【问题描述】:
我正在尝试在 Fragment 中使用 linkify,但我无法将其实际链接化,也找不到有关如何正确使用它的文档。如果有人可以提供帮助,那就太好了!
ContactFragment.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>
【问题讨论】:
-
myEmail.setMovementMethod(LinkMovementMethod.getInstance());添加这个
-
这不会改变任何事情
-
文字显示了吗??
标签: android android-fragments linkify