从首选项活动开始的对话框,带有可点击的链接
在我的 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。
我希望有人能帮助我。
多谢!
In my PreferenceActivity I've added a button "About", when pressed the following function is called:
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();
}
The layout look like this:
<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>!
Which is good, but I would like that the links in this dialog are hyper links. I've read about using linkify but this results in FC.
I hope somebody can help me.
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了实现这一点,我所做的如下:
我使用以下示例创建了一个自定义对话框: http://www.androidpeople.com/android-custom-dialog-example
在我创建的偏好活动中:
在这个自定义对话框中我可以做任何我想做的事情,包括使用 linkify 让我的链接单击有能力的。
What I've done to make this possible is the following:
I've made a custom dialog using the following example: http://www.androidpeople.com/android-custom-dialog-example
In my preferenceActivity I created:
Inside this custom dialog I can do whatever i want, including using linkify to make my links click able.