performance - Android app builds, but crashes in emulator -


my app keeps crashing , have no idea causing this. app builds, keeps crashing in emulator.

i tried change mainactivity, still it's not working.

main activity.java

public class mainactivity extends appcompatactivity implements view.onclicklistener {  button btlogout; edittext etname, etpsn;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_login);      etname = (edittext) findviewbyid(r.id.etname);     etpsn = (edittext) findviewbyid(r.id.etpsn);      btlogout = (button) findviewbyid(r.id.btlogout);     btlogout.setonclicklistener(this); }  @override public void onclick(view v) {     switch (v.getid()){         case r.id.btlogout:              break;         default : break;     } } } 

activity_main.xml

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:textsize="20sp"     android:text="name"/> <edittext     android:id="@+id/etname"     android:layout_width="match_parent"     android:layout_marginbottom="20dp"     android:layout_height="40dp" /> <textview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:textsize="20sp"     android:text="psn"/> <edittext     android:id="@+id/etpsn"     android:layout_width="match_parent"     android:layout_marginbottom="20dp"     android:layout_height="40dp" /> <button     android:id="@+id/btlogout"     android:text="logout"     android:layout_width="match_parent"     android:layout_height="50dp"     android:textalignment="gravity"     android:gravity="center|center_vertical"     android:textsize="20dp"     android:textstyle="bold"     android:capitalize="characters" /> </linearlayout> 

you must using setcontentview(r.layout.activity_main);

instead

setcontentview(r.layout.activity_login); 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -