1. 定义布局文件:alertdialog_item.xml,因为列表的每一项的样式都是从布局文件设置的,注意的是布局文件是一个TextView
<?xml version="1.0" encoding="utf-8"?>
<TextViewxmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/alertdialog_item"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:textColor="#000000"
android:background="#668B8B"
android:textSize="28px" >
</TextView>
2. 设置AlertDialog的总体样式,比如说割线的高度,这时候在style.xml配置
<!-- 自定义AlertDialog的样式 -->
<stylename="AlertDialogCustom">
<item name="android:dividerHeight">5dp</item>
<itemname="android:width">100dp</item>
</style>
3. 在Activity上设置相应的AlertDialog
String[] menu_names =new String[]{"进入","取消","删除","删除全部"};
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this,R.style.AlertDialogCustom));
builder.setAdapter(newArrayAdapter(WeiXunListActivity.this, R.layout.alertdialog_item,menu_names),null);
builder.create().show();
4. 显示效果如下
![](https://img-my.csdn.net/uploads/201206/29/1340941500_9705.jpg)