2017-05-03 13 views
1

활동을 경고 대화 상자로 변경하는 데 많은 노력을 기울였습니다. 나는 전에 그것을 달성하지만, 기억이 지금 당장 할 수없는활동을 AlertDialog로 변경할 수 없습니다.

여기 앱의 테마입니다 :

실제 활동이 포함되어 여기

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
    <item name="android:windowBackground">@color/background</item> 

</style> 

내가 경고 대화 상자로 변경하기 위해 노력하고있어, 활동의 이상 (버튼, 선형 레이아웃, 텍스트보기).

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
tools:context="com.famiddle.android.thechanakyanitiplus.NotificationCenter"> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/notification_center_title" 
    android:gravity="center_horizontal" 
    android:textColor="@color/colorAccent" 
    android:layout_marginTop="8dp" /> 

</ScrollView> 

그것은 자바 파일의 (NotificationCenter.java)

public class NotificationCenter extends AppCompatActivity { @Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    // To remove status bar 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
     //  WindowManager.LayoutParams.FLAG_FULLSCREEN); 

    setContentView(R.layout.activity_notification_center);}} 

이 활동 시작 버튼 :

LinearLayout notificationManager = (LinearLayout) findViewById(R.id.notification_manager); 
    notificationManager.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      startActivity(new Intent(getApplicationContext(), NotificationCenter.class)); 

     } 
    }); 

마지막으로, AndroidManifest를 파일 :

<activity 
     android:name=".NotificationCenter" 
     android:theme="@style/Theme.AppCompat.Dialog" 
     android:excludeFromRecents="true"> 

    </activity> 

I을 다른 주제로 시도 했어. 여기에 언급 된 Android Activity as a dialog을 언급했지만 버튼을 클릭 할 때마다 앱이 다소 충돌합니다 (다시 시작).

답변

0

나 한테 물어 보면 아주 간단합니다. 이 테마를 사용해 부모 테마를 확인하십시오 :

테마 .AppCompat.Light.Dialog. 이것이 활동을 AlertDialog로 바꾸는 데 필요한 것입니다. 어두운 테마가 필요한 경우 "빛"을 제거하십시오. 또한 앱의 테마와 일치하는 '항목'을 더 추가했습니다. 이것이 도움이되기를 바랍니다.

<!-- NOTIFICATION MANAGER THEME --> 
<style name="AppDialogTheme" parent="Theme.AppCompat.Light.Dialog"> 
    <!-- Customize your theme here. --> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
    <item name="android:windowBackground">@color/background</item> 
</style> 
+0

감사를 확장 @Arpit CHHABRA 그것은했다. –

0

본 적이 있습니까? link?

달성하려는 목표에 대해 더 자세히 알 수 있습니까?

+0

내가 제목에 언급 한 바와 같이 –

+0

하지만 AlertDialog에 활동을 켜 링크를 확인하기 위해 노력하고있어이 ... – koherent

+0

내 활동이 APPCOMPAT에게 –