Android Studio - Navigation between activities -


i may doing dumb mistake somewhere, , question may seem silly, but, can't figure out reason why happening.

i have homeactivity imageview , when click on it, need go dummyactivity(created purpose of testing). dummyactivity has textview text, "this dummy page". but, screen doesn't display anything.

i newbie android studio, but, guess doesn't relate it.

here code:

imageview onclick in homeactivity:

 mimageview1 = (imageview) findviewbyid(r.id.imageview_1);  mimageview1.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {              log.d("homeactivity", "imageview 1 clicked");             //startactivity(new intent(homeactivity.this, mainactivity.class));             startactivity(new intent(homeactivity.this, dummyactivity.class));         }     }); 

dummyactivity oncreate():

public class dummyactivity extends appcompatactivity{  @override public void oncreate(bundle savedinstancestate, persistablebundle persistentstate) {     super.oncreate(savedinstancestate, persistentstate);     setcontentview(r.layout.activity_dummy); } } 

activity_dummy.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/textview"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:text="this dummy page"         android:textappearance="?android:attr/textappearancelarge" />    </linearlayout> 

androidmanifest.xml

 <activity         android:name=".dummyactivity"         android:label="dummyactivity"></activity> 

the logcat displays, "imageview 1 clicked", nothing after that. no errors, nothing. doing wrong here?

update: changed backgroundcolor linearlayout , textcolor textview, changes not reflecting. preview in android studio showing layout fine, but, screen on device blank before, black background.

enter image description hereenter image description here

not sure why?

you have overriden wrong oncreate() method. use 1 instead:

public class dummyactivity extends appcompatactivity{     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate, persistentstate);         setcontentview(r.layout.activity_dummy);     } } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -