диалоговое окно началось с предпочтительной активности со ссылками, доступными по клику - PullRequest
1 голос
/ 20 мая 2011

В моей 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>!

Об экране

Это хорошо, но мне бы хотелось, чтобы ссылки в этом диалоге были гиперссылками. Я читал об использовании linkify, но это приводит к FC.

Надеюсь, кто-нибудь сможет мне помочь.

Большое спасибо!

1 Ответ

3 голосов
/ 22 мая 2011

Чтобы сделать это возможным, я сделал следующее:

Я создал специальный диалог на следующем примере: http://www.androidpeople.com/android-custom-dialog-example

В своем предпочтении я создал действие:

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

Внутри этого пользовательского диалога я могу делать все, что захочу, в том числе с помощью linkify, чтобы мои ссылки могли кликать.

...