2011-05-19 397 views
1

在我PreferenceActivity我添加了一個按鈕「關於」,按下面的函數被調用的時候:對話框從偏好活動開始點擊的鏈接

public void InstructionsDialog(){ 
    AlertDialog.Builder ad = new AlertDialog.Builder(this); 
    ad.setIcon(R.drawable.icon); 
    ad.setTitle("About"); 
    ad.setView(LayoutInflater.from(this).inflate(R.layout.about_dialog,null)); 

    ad.setPositiveButton("OK", 
    new android.content.DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int arg1) { 
     // OK, go back to Main menu 
    } 
    } 
    ); 

    ad.setOnCancelListener(new DialogInterface.OnCancelListener(){ 
    public void onCancel(DialogInterface dialog) { 
     // OK, go back to Main menu 
    } 
    } 
    ); 

    ad.show(); 
} 

的佈局是這樣的:

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:scrollbars="vertical" 
    android:scrollbarAlwaysDrawVerticalTrack="true" 
    android:id="@+id/instructions_view" > 

<TextView android:id="@+id/TextView01" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:paddingLeft="5px"> 
       </TextView> 
<TextView android:id="@+id/TextView02" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:paddingLeft="5px" 
       android:paddingTop="20px" 
       android:text= 
       "Thank you for downloading this application. Bug reports and request for additional features or languages are welcome."> 
       </TextView>     
<TextView android:id="@+id/TextView03" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:paddingLeft="5px" 
       android:paddingTop="20px" 
       android:text= 
       "This project makes use of the 'Android Wheel' created by Yuri Kankan and is licensed under the Apache License (http://www.apache.org/licenses/LICENSE-2.0.html)"> 
       </TextView> 
<TextView android:id="@+id/TextView04" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:paddingLeft="5px" 
       android:paddingTop="20px" 
       android:layout_gravity="center" 
       android:text="Copyright © 2011, Tricky-Design" 
       ></TextView> 

</LinearLayout> 
</ScrollView>! 

About screen

這是很好的,但我想,在這個對話框中的鏈接是超利NKS。我已閱讀關於使用linkify,但這導致FC。

我希望有人能幫助我。

非常感謝!

回答

3

我做了什麼,使這個可能是以下幾點:http://www.androidpeople.com/android-custom-dialog-example

在我preferenceActivity我創建:

public void aboutScreen() { 
    about about = new about(this); 
    about.show(); 
} 

我用下面的例子做了一個自定義對話框

在這個自定義對話框中,我可以做任何我想做的事情,包括使用linkify使我的鏈接點擊能夠。