首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android片段中的Linkify

Android片段中的Linkify
EN

Stack Overflow用户
提问于 2013-03-24 14:43:54
回答 1查看 405关注 0票数 0

我试图在片段中使用linkify,但我不能让它真正地链接起来,我也找不到我的文档来说明如何正确使用它。如果有人能帮上忙那就太好了!

ContactFragment.java:

代码语言:javascript
复制
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:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-24 15:04:31

您从onCreateView方法返回了错误的View。应该是return V;而不是return inflater.inflate(R.layout.activity_contact_fragment, group, false);

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15595901

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档