问题描述:

I had a lot of activities in the manifest activity 1, 2, 3, 4, 5, to 6. Activity 1 is MainActivity, while the activity 2 is the application menu. Of activity 1 to 2> 3> 4> 5> 6 all is well. But when in the activity 2 there is new button exit when I pressed the button always go back to the previous activity, as well as pressing the onBackPressed.

sorry my English bad

Activity 2

public class menu extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Button btn1 =(Button)findViewById(R.id.button1);

btn1.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View arg0) {

// TODO Auto-generated method stub

Intent i = new Intent(menu.this, profil1.class);

startActivity(i);

}

});

//etc

Button btn7 =(Button)findViewById(R.id.button7);

btn7.setOnClickListener(new View.OnClickListener() {

//exit aplication

@Override

public void onClick(View arg0) {

// TODO Auto-generated method stub

finish();

}

});

}

public void onBackPressed() {

super.onBackPressed();

finish();

}

}

Activity 3, exit button on all activity equal

`public class profil1 extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.profil_3);

//etc

Button btn14 =(Button)findViewById(R.id.button14);

btn14.setOnClickListener(new View.OnClickListener() {

//back to menu

@Override

public void onClick(View arg0) {

// TODO Auto-generated method stub

Intent i = new Intent(profil1.this, menu.class);

startActivity(i);

finish();

}

});

}

}`

this is manifest

 `<application

android:allowBackup="true"

android:icon="@drawable/ic_launcher"

android:label="@string/app_name"

android:theme="@style/AppTheme" >

<activity

android:name="com.example.calculate.MainActivity"

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="com.example.calculate.menu"

android:label="@string/app_name">

</activity>

<activity

android:name="com.example.calculate.profil1"

android:label="@string/app_name">

</activity>

//etc

</application>

</manifest>

`

相关阅读:
Top