[英]Android Dialog Custom Layout for ArrayAdapter
我有一個工作正常的對話框。 但是,我想更改文本的大小和對話框的樣式。 有沒有創建自定義對話框的快速方法? 我嘗試應用一個主題來執行此操作,但是它只會更改標題文本,而不會更改文本較大且對話框大小太大的單個元素。 謝謝。
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();
試試這個
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();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.