我正在嘗試創建Alertdialog並以編程方式向圖形添加3個togglebuttons。以編程方式使用切換按鈕創建警報對話框
我試着開始與一個切換按鈕,由於某種原因的警告對話框中是非常小的(就在圖像)和按鈕本身看起來怪異(圖像比按鈕大)..
這裏是我的代碼,做發現任何錯誤?
LinearLayout ll = new LinearLayout(mActivity);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
ToggleButton tb;
for(int i=0;i<cards.size();i++){
Card card = cards.get(i);
tb = new ToggleButton(mActivity);
tb.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
tb.setButtonDrawable(card.getDrawable(mActivity));
ll.addView(tb);
}
AlertDialog.Builder builder;
AlertDialog alertDialog;
builder = new AlertDialog.Builder(mActivity);
builder.setView(ll);
alertDialog = builder.create();
alertDialog.show();
你能發表一張圖片嗎?也可以嘗試添加'builder.setTitle(「我的標題」);',也許給它一個標題會使它看起來像正常大小。 – FoamyGuy 2012-07-15 23:56:56
給一個標題確實有幫助,但下面的答案解決了它 – Snake 2012-07-16 17:32:29