DialogFrament是Android sdk中的对话框基类,开发人员可以针对此类进行扩展。他可以扩展出Android中的多种对话框,比如alertdialog,listdialog,radiodialog等。android已经为开发人员提供了简单的对话框,本篇要讲的是对话框的扩展部分。本例是根据sdk开发文档而来。
1.建立textdialog
在layout文件夹下面,建立textdialog的xml文档。在xml文档中,我们只定义了一个textview。
1 <?xml version="1.0" encoding="utf-8"?> 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent" 5 android:orientation="vertical" > 6 7 <TextView 8 android:id="@+id/text" 9 android:layout_width="fill_parent" 10 android:layout_height="wrap_content" /> 11 12 </LinearLayout>