2011-10-21 76 views
1

我正在研究一個需要沿着彈出窗口的行的應用程序。我正在考慮兩種不同的設計。其中popUpWindow以普通popUpWindow的形式打開,而不是開始新的活動,另一種是彈出窗口作爲新活動打開的設計。在後者的設計(其中一個新的活動是開放的),我可以把下面的行清單的活動標籤使新窗口的外觀真的很好:設置popUpWindow樣式

android:theme="@android:style/Theme.Dialog" 

但是似乎開始一個新的活動不會爲我的整體設計工作。我的問題是如何將這個「對話框」樣式應用到普通的popUpWindow?

下面是我實例化和顯示popUpWindow代碼:

PopupWindow popUpWindow; 
popUpWindow = new PopupWindow(this); 
popUpWindow = new PopupWindow(popUpView, 250, 325, true); 
popUpWindow.showAtLocation(mainLinearLayout, Gravity.CENTER, 0, 10); 
+0

你可以發佈您的代碼? – ingsaurabh

+0

我已經添加了處理popUpWindow的代碼,這是你想到的嗎? –

回答

3

這裏就是我最後做它實現我想要的東西:

Dialog dialog = new Dialog(MainActivity.this); 
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
    popUpLayout = Globals.layoutInflater.inflate(R.layout.pop_up_layout, 
      null); 
    dialog.setContentView(popUpLayout); 
    dialog.getWindow().setLayout(275, 350); 
    dialog.show();