0
我知道如何使用預定義的XML創建自定義對話框。如何避免LinearLayout上的重疊按鈕?
我想用LinearLayout和按鈕動態地創建一個對話框。
我試過下面的代碼,但它似乎我的按鈕重疊。我如何防止這種情況?
public void createMenu(MenuItem item){
Dialog menuDiag = new Dialog(Home.this);
menuDiag.setTitle("Browse");
LinearLayout linearLayout = new LinearLayout(menuDiag.getContext());
LinearLayout.LayoutParams params;
Button button;
categoryList = parse.getPlayList();
for(int i=0;i<categoryList.size();i++){
params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
button = new Button(menuDiag.getContext());
button.setText(categoryList.get(i).getTitle());
button.setBackgroundResource(iconCheck(categoryList.get(i).getTitle()));
button.setLayoutParams(params);
menuDiag.addContentView(button, params);
}
params = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
menuDiag.addContentView(linearLayout, params);
menuDiag.show();
}
發佈問題屏幕快照 – waqaslam 2012-04-20 19:33:23