AlertDialog.Builder builder = new AlertDialog.Builder(
SignUpActivity.this);
final ArrayList<String> choiceList = new ArrayList(
Arrays.asList(getResources().getStringArray(
R.array.CountryCodes)));
FontHelper.applyFont(this, findViewById(R.id.llmainview),
"AVENIRLTSTD-BOOK_0.OTF");
int selected = -1; // does not select anything
builder.setAdapter(new ArrayAdapter<String>(SignUpActivity.this,
R.layout.dialog_layout, R.id.textView1, choiceList),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
country_code = "" + choiceList.get(which);
edt_country.setText("+" + country_code);
Log.error("vggg", "" + choiceList.get(which));
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
StateListDrawable selector = new StateListDrawable();
selector.addState(new int[] { android.R.attr.state_pressed }, getResources().getDrawable(android.R.color.transparent));
selector.addState(new int[] {}, getResources().getDrawable(android.R.color.transparent));
alert.getListView().setSelector(selector);
alert.getListView().setCacheColorHint(
getResources().getColor(android.R.color.transparent));
alert.getListView().setBackgroundColor(
getResources().getColor(android.R.color.transparent));
alert.show();
这是列表行 xml 文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowid"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:text="TextView"
android:textColor="@color/rowtextcolor" />
<View
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#9faeb6" />
我希望这对你有用并给我 1+