활동을 경고 대화 상자로 변경하는 데 많은 노력을 기울였습니다. 나는 전에 그것을 달성하지만, 기억이 지금 당장 할 수없는활동을 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을 언급했지만 버튼을 클릭 할 때마다 앱이 다소 충돌합니다 (다시 시작).
감사를 확장 @Arpit CHHABRA 그것은했다. –