2014-11-11 2 views
0

После того, как вы перейдете на страницу chapter3_1.xml, которая отлично подтягивается, когда я нажимаю на свою заднюю клавишу телефона, и она возвращает меня к предыдущей кнопке. нажмите еще раз, и есть пустая страница, которая не должна быть там. нажмите еще раз, и вы перейдете к исходной кнопке. ошибок нет.Когда я нажимаю на свою программу, я получаю пустой экран

манифеста

<?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> 

ответ

2

Я думаю, что вы используете фрагмент в вашем аппликаций п. И когда вы нажимаете фрагмент, вы добавляете его в задний стек, поэтому, когда вы нажимаете кнопку «Назад», он отображает пустой экран, который является рамкой, на которой вы показываете фрагмент. Направить link :-

Fragmnet manager

+0

Я думаю, что я собираюсь придерживаться учебных пособий по YouTube, вместо того, чтобы немного учиться и переходить в полноценные проекты. Большое спасибо за помощь! – dtrodriguez

1

В манифесте, в деятельности вы должны установить родителя, как это:

android:parentActivityName="com.some.myproject.ParentActivityToThisActivity" 

Но он не может работать с API 14, API 15 следует использовать или новейший.

+0

так в основном использовать это, чтобы установить каждое действие в соответствующий родитель? – dtrodriguez

+0

Вкратце - да. Я использую такой метод, и он работает. Как я помню, у меня была тревога о проблеме с api 14, но в моем текущем проекте я использую min API 15. Разум может быть другим в вашем приложении, просто гадать, но он должен помочь. – Dudeist

Смежные вопросы