2013-03-24 2 views
0

나는 linkage ina Fragment를 사용하려고하는데 실제로 링크 시키려고 할 수없고 그것을 올바르게 사용하는 방법에 대한 나의 문서를 찾을 수 없다. 누군가가 위대한 일을 도울 수 있다면!안드로이드 조각 Linkify in

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("[email protected]"); 
     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="[email protected]" /> 

</RelativeLayout> 
+0

대신 return V;이어야합니다. myEmail.setMovementMethod (LinkMovementMethod.getInstance()); Add this – Raghunandan

+0

아무 것도 바뀌지 않습니다 – GreekOphion

+0

은 표시되는 텍스트입니까 ?? – Raghunandan

답변

2

당신은 onCreateView 방법에서 잘못된 View를 반환한다. return inflater.inflate(R.layout.activity_contact_fragment, group, false);