gpt4 book ai didi

java - 当我按回我的程序时,我看到一个空白屏幕

转载 作者:行者123 更新时间:2023-12-01 22:36:09 26 4
gpt4 key购买 nike

进入chapter3_1.xml页面后,当我按下手机后退键时,该页面会正常弹出,并将我带到上一个按钮。再按一次,就会出现一个不应该出现的空白页。再次按返回,您将到达原来的按钮。没有错误,没有崩溃。

list

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.th3ramr0d.ar670_1quickreference"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainMenu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


<activity
android:name=".SubMenu1"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.th3ramr0d.ar670_1quickreference.SUBMENU1" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".Chapter3"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.th3ramr0d.ar670_1quickreference.CHAPTER3" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".Chapter3_1"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.th3ramr0d.ar670_1quickreference.CHAPTER3_1" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

</application>

</manifest>

MainMenu.java

 package com.th3ramr0d.ar670_1quickreference;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainMenu extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Button btnChpt3 = (Button) findViewById(R.id.btnChpt3);
btnChpt3.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.th3ramr0d.ar670_1quickreference.CHAPTER3"));
}
});
}
}

SubMenu1.java

 package com.th3ramr0d.ar670_1quickreference;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class SubMenu1 extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.chapter3);

Button btnChpt3 = (Button) findViewById(R.id.btnChpt3_1);
btnChpt3.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.th3ramr0d.ar670_1quickreference.CHAPTER3_1"));
}
});
}

}

Chapter3.java

 package com.th3ramr0d.ar670_1quickreference;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class Chapter3 extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
startActivity(new Intent("com.th3ramr0d.ar670_1quickreference.SUBMENU1"));
}

}

Chapter3_1.java

 package com.th3ramr0d.ar670_1quickreference;

import android.app.Activity;
import android.os.Bundle;

public class Chapter3_1 extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.chapter3_1);
}
}

activity_main.xml

 <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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.th3ramr0d.ar670_1quickreference.MainActivity" >

<Button
android:id="@+id/btnChpt3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chapter 3" />

</LinearLayout>

chapter3.xml

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

<Button
android:id="@+id/btnChpt3_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fuckmylife" />

</LinearLayout>

chapter3_1.xml

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

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is the content of chapter 3_1"
android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

最佳答案

我认为您在应用程序中使用了 fragment 。当您推送 fragment 时,您会将其添加到后退堆栈中,这就是为什么当您按后退按钮时,它将显示一个空白屏幕,这是您在其上显示 fragment View 的框架布局。请参阅link :-

Fragmnet manager

关于java - 当我按回我的程序时,我看到一个空白屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26855707/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com