我有一个Alertdialog,样式是Checkbox,我需要在彼此之间加一行
因为我的东西太多了。谢谢你的帮助。
这是我的代码
public Button.OnClickListener IMBL = new Button.OnClickListener() {
public void onClick(View v) {
AfterClick = new boolean[items.length];
for (int i = 0; i < AfterClick.length; i++) {
AfterClick[i] = false;
}
AlertDialog dialog = new AlertDialog.Builder(Daycarddd.this)
.setTitle("skill")
.setMultiChoiceItems(items, AfterClick,
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog,
int indexSelected, boolean isChecked) {
if (isChecked) {
for (int i = 0; i < AfterClick.length; i++) {
if (AfterClick[i]) {
}
}
} else if (seletedItems
.contains(indexSelected)) {
// Else, if the item is already in the
// array, remove it
seletedItems.remove(Integer
.valueOf(indexSelected));
}
}
})
.setPositiveButton("confirm",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int id) {
for(int j=0;j< items.length;j++){
if(AfterClick[j]==true){
if(resultcheck==""){resultcheck=items[j];}else
resultcheck =resultcheck+","+items[j] ;
}
}
checkbox=resultcheck;
resultcheck="";
Toast.makeText(Daycarddd.this,
checkbox,
Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("cancle",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int id) {
}
}).create();
dialog.show();
}
};
要绘制水平线,请使用此布局
<View
android:id="@+id/viewBorder"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"
/>
//在这里膨胀你的自定义对话框
LayoutInflater inflater = getActivity().getLayoutInflater();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
final View view = inflater.inflate(R.layout.custom_dialog, null);
final EditText edTxtAmount = (EditText) view.findViewById(R.id.edTxtOffer);
builder.setTitle("Make Your Offer")
.setView(view)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Clicked 'Okay'
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Clicked 'Cancel'
}
});
return builder.create();
}
//自定义布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/mCheckbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Your Check Box with border"/>
<View
android:id="@+id/viewBorder"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/mCheckbox"
android:background="@android:color/holo_red_dark"/>
//setView(view)将设置您的自定义对话框视图