Android Second activity does not load -


sorry english.

i'm trying use second activity in android, doesn't load. it's code jump it. below, can see code. thanks.

1- first activity

public class mainactivity extends activity  {  button button; @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      setcontentview(r.layout.activity_main);      addlisteneronbutton();   public void addlisteneronbutton() {      final context context = this;      button = (button) findviewbyid(r.id.btenviardados);      button.setonclicklistener(new onclicklistener() {          @override         public void onclick(view v) {             system.out.println("helooo");             intent intent = new intent(mainactivity.this, com.example.seven.reader.activity_janela1.class);               startactivity(intent);             system.out.println("ebadasdadas");          }      });  } 

2- second activity

public class activity_janela1 extends activity   {  public void oncreate(bundle saveinstacestate) {     super.oncreate(saveinstacestate);     setcontentview(r.layout.activity_janela1);   }} 

3- first layout

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearlayout1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" >   <textview     android:id="@+id/textview1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="i&apos;m screen 1 (main.xml)"     android:textappearance="?android:attr/textappearancelarge" />  <button     android:id="@+id/btenviardados"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="click me screen" /> 

4- second layout

 <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"  android:id="@+id/linearlayout1"  android:layout_width="wrap_content"  android:layout_height="wrap_content" >  <linearlayout     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:id="@+id/layoutformulario"     android:orientation="vertical">  </linearlayout>  <textview     android:id="@+id/textview1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="im screen 2 (main2.xml)"     android:textappearance="?android:attr/textappearancelarge" /> 

5- androidmanifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.seven.reader" android:versioncode="1" android:versionname="1.0" >  <uses-sdk android:minsdkversion="10" />  <application     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name" >     <activity         android:label="@string/app_name"         android:name=".mainactivity" >         <intent-filter >             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity>     <activity         android:label="@string/app_name"         android:name="com.example.seven.reader.activity_janela1" >     </activity>  </application>  </manifest> 

you have created method within oncreate. remove , leave in oncreate.

///public void addlisteneronbutton() {    button = (button) findviewbyid(r.id.btenviardados);  button.setonclicklistener(new onclicklistener() {      @override     public void onclick(view v) {         system.out.println("helooo");         intent intent = new intent(mainactivity.this, com.example.seven.reader.activity_janela1.class);           startactivity(intent);         system.out.println("ebadasdadas");      }  }); 

you misunderstanding how use methods , scope. recommend read on these things.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -