when click button "start party" want android app switch "activity_before_party.xml", when click on button, app stops. have tried many things nothing worked... seems minor problem in opinion. help
this part of "activity_home.xml" (the main page):
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#226b6e" tools:context="com.example.emili.partymate.home" tools:layout_editor_absolutey="81dp" tools:layout_editor_absolutex="0dp"> <button android:id="@+id/idstartparty" android:layout_width="260dp" android:layout_height="61dp" android:backgroundtint="@color/start_party_color" android:text="start party!" android:textcolor="#ffffff" android:textsize="22sp" android:onclick="theclick" app:layout_constraintbottom_totopof="@+id/viewlogs" app:layout_constrainthorizontal_bias="0.496" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_totopof="parent" app:layout_constraintvertical_bias="0.285" />
this "home.java" :
package com.example.emili.partymate; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.view; import android.widget.button; import android.content.intent; public class home extends appcompatactivity { button startparty; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_home); startparty = (button) findviewbyid(r.id.idstartparty); } public void theclick(view v){ intent = new intent(this,beforeparty.class); startactivity(i); } }
this "beforeparty.java"
package com.example.emili.partymate; import android.support.v7.app.appcompatactivity; import android.os.bundle; public class beforeparty extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_before_party); } }
and finally, part of "activity_before_party.xml" (the page want switch to):
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_before_party" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#226b6e" tools:context=".beforeparty">
please post error well, otherwise hard find problem. have not register beforeparty
activity in androidmanifest
.
should that:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.your.packename"> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme"> <activity android:name=".home"> <intent-filter> <action android:name="android.intent.action.main"/> <category android:name="android.intent.category.launcher"/> </intent-filter> </activity> </application> <activity android:name=".beforeparty" /> </manifest>
but again, guess. provide more details , can help.
Comments
Post a Comment