[英]Problem when I try to open another window from a button the app closes completely "Android Studio"
i'm a student and i'm working on a mobile app.我是一名学生,正在开发一款移动应用程序。 The probleme is that my app was working, but now when i click on the button to open another window it closes.
问题是我的应用程序正在运行,但现在当我单击按钮打开另一个 window 时,它关闭了。 Here is my code: `
这是我的代码:`
public class MainActivity extends AppCompatActivity {
Button b_inscrire_etudiant;
Button b_inscrire_enseignant;
Button b_inscrire_admin;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b_inscrire_etudiant = findViewById(R.id.b_inscrire_etudiant);
b_inscrire_enseignant = findViewById(R.id.b_inscrire_enseignat);
b_inscrire_admin = findViewById(R.id.b_inscrire_admin);
b_inscrire_etudiant.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this , InscriptionEtudiant.class);
startActivity(i);
}
});
b_inscrire_enseignant.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this , InscriptionEnseignant.class);
startActivity(i);
}
});
b_inscrire_admin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MainActivity.this , InscriptionAdmin.class);
startActivity(i);
}
});
}
}
` `
I worked as usual "using Intent" besides it worked well until now.我像往常一样“使用 Intent”工作,但到目前为止它运行良好。
Here is my Manifest file:这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.myusto">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyUsto"
tools:targetApi="31">
<activity
android:name=".InscriptionEnseignant"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".InscriptionEtudiant"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".InscriptionAdmin"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".Connexion"
android:exported="false">
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
ps: I solved the problem, by the way two were missing ps:我解决了问题,顺便少了两个
Thank you for the answers.谢谢你的回答。 It's true, it was missing a part of the code which was not written in the manifest file
是的,它缺少了一部分没有写在清单文件中的代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.