Question

I am trying to use linkify ina Fragment and I can't get it to actually linkify and I can't find my documentation on how to use it correctly. If someone could help that would be great!

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>
Was it helpful?

Solution

You are returning the wrong View from onCreateView method. It should be return V; instead of return inflater.inflate(R.layout.activity_contact_fragment, group, false);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top