我有一个工作正常的对话框。但是,我想更改对话框的文本和样式的大小。有没有创建自定义对话框的快速方法?我尝试应用一个主题来实现它,但它只更改标题文本,但不更改文本很大且对话框大小太大的单个元素。感谢。
AlertDialog.Builder builderSingle = new AlertDialog.Builder(getActivity());
builderSingle.setTitle("Select Item");
final ArrayAdapter<String> arrayAdapter = listAllItems(getActivity());
builderSingle.setNegativeButton(
"cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builderSingle.setAdapter(
arrayAdapter,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String strName = arrayAdapter.getItem(which);
}
});
builderSingle.show();
答案 0 :(得分:0)
尝试这个
Listview lst_state;
TextView text_t ;
LayoutInflater inflater = mactivity.getLayoutInflater();
View alertLayout = inflater.inflate(R.layout.listview, null);
lst_state = (ListView) alertLayout.findViewById(R.id.listview_show_like_member_we);
text_t = (TextView) alertLayout.findViewById(R.id.text_title);
text_t.setText("State");
lst_state.setAdapter(adapter_state);
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setView(alertLayout);
alert.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
final AlertDialog dialog = alert.create();
lst_state.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
location_t_district.setText(arrayList_state.get(position).getStatename));
dialog.dismiss();
}
});
dialog.show();