2013-10-01 46 views
-2

我想在這裏顯示一個對話框,就像這個應用程序一樣。我該如何做?我嘗試過一個對話框的自定義佈局,但它看起來不像xml輸出。 enter image description here在android中顯示一個活動作爲對話框

+0

可能會將填充添加到活動的佈局。否則你可以使用DialogFragment :) –

回答

1

要麼使用DialogFragment或使用AlertDialog如下:

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
View layout = inflater.inflate(R.layout.yourLayoutId, (ViewGroup) findViewById(R.id.yourLayoutRoot)); 
AlertDialog.Builder builder = new AlertDialog.Builder(this).setView(layout); 
AlertDialog alertDialog = builder.create(); 
alertDialog.show(); 
+1

它不回答這個問題,因爲這不是一個活動。 –

0

您可以在Activity聲明添加到您的清單。

<activity android:theme="@android:style/Theme.Dialog" />

0

在活動也許將這個在您的mainfest要顯示的對話框將幫助您:

android:theme="@android:style/Theme.Holo.Light.Dialog" 
0

設置你的活動主題的對話

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

然後在您的活動中不要設置任何視圖,只需創建一個對話框與您要顯示的視圖

相關問題