2017-04-05 99 views
0

我正在使用活動作爲對話框。我希望對話框出現在其他活動上,但不會隱藏它。作爲對話框的活動隱藏第一個活動

這是我的情況,對話活動總是隱藏我的主要活動。

這是代碼:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="tfg.marcos.coachtrain.views.DashBoardActivity"> 

    <EditText 
     android:id="@+id/etDesdeFecha" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:inputType="date" 
     android:maxLength="40" 
     android:textSize="25sp" /> 

    <EditText 
     android:id="@+id/etHastaFecha" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:hint="Hasta Fecha" 
     android:inputType="date" 
     android:maxLength="40" 
     android:textSize="25sp" /> 

    <EditText 
     android:id="@+id/etRepetirCada" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:hint="Repetir cada" 
     android:inputType="number" 
     android:maxLength="40" 
     android:textSize="25sp" /> 
</LinearLayout> 

我編程方式添加主題具有因,如果我加入到這個manifest.xml中我的應用程序崩潰:

setTheme(android.R.style.Theme_Holo_Light_Dialog); 

這說明我在對話活動屏幕中心和黑色。

謝謝!

+0

'我正在使用活動作爲對話框 - 任何爲什麼'Dialog'或'DialogFragment'不能使用的原因? –

+0

因爲我想添加活動功能並且對話框不允許給我。對話框功能不夠我想 – garciam202

+0

試試這個android:theme =「@ android:style/Theme.Holo.Light.Dialog.NoActionBar」> – Mundroid

回答

1

您不能同時在屏幕上顯示2個活動,這就是爲什麼我們有片段。你應該使用一個DialogFragment,從那裏你可以得到任何你需要的Activity/context。

0

最後,我用一個fragmentdialog做到了這一點,並將其包含在我自己的佈局中。謝謝