java - A button with 3 pages, the 3rd one didn't work -


i have page has button, when click it, goes page button, when click button takes third page, doesn't! tried make mainactive2.java , pageone2.java didn't work! help!

active_main.xml

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="#1d72c3"     android:gravity="center" >      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_centerhorizontal="true"         android:gravity="center"         android:orientation="vertical"         android:textstyle="italic" >          <scrollview             android:layout_width="fill_parent"             android:layout_height="fill_parent" >              <linearlayout                 android:layout_width="fill_parent"                 android:layout_height="wrap_content"                 android:orientation="vertical" >                  <button                     android:id="@+id/abus"                     android:layout_width="fill_parent"                     android:layout_height="55dp"                     android:layout_alignparentright="true"                     android:layout_alignparenttop="true"                     android:gravity="center"                     android:text="about us"                     android:textcolor="#ffffff"                     android:textsize="20sp"                     android:textstyle="italic" />             </linearlayout>         </scrollview>     </linearlayout>  </relativelayout> 

abus.xml

<?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:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="#1d72c3"     android:gravity="center" >      <linearlayout             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:layout_centerhorizontal="true"             android:gravity="center"             android:textstyle="italic"             android:orientation="vertical" >               <scrollview                 android:layout_width="fill_parent"                 android:layout_height="fill_parent" >                  <linearlayout                     android:layout_width="fill_parent"                     android:layout_height="wrap_content"                     android:orientation="vertical">                      <button                         android:id="@+id/abus2"                         android:layout_width="fill_parent"                         android:layout_height="55dp"                         android:layout_alignparentright="true"                         android:layout_alignparenttop="true"                         android:gravity="center"                         android:text="about us"                         android:textcolor="#ffffff"                         android:textsize="20sp"                         android:textstyle="italic" />                 </linearlayout>             </scrollview>               </linearlayout> </relativelayout> 

abus2.xml

<?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:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="#1d72c3"     android:gravity="center" >      <linearlayout         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_centerhorizontal="true"         android:gravity="center"         android:textstyle="italic"         android:orientation="vertical" >          <scrollview             android:layout_width="fill_parent"             android:layout_height="fill_parent" >             <linearlayout                android:layout_width="fill_parent"                android:layout_height="wrap_content"                android:orientation="vertical">                 <textview                    android:layout_width="fill_parent"                    android:layout_height="fill_parent"                    android:gravity="center"                    android:textstyle="italic"                    android:textcolor="#ffffff"                    android:textsize="18sp"                    android:text="hello" />             </linearlayout>         </scrollview>               </linearlayout> </relativelayout> 

mainactivity.java

package com.d.da;   import android.app.activity; import android.content.context; import android.content.intent; import android.os.bundle; import android.widget.button; import android.view.view; import android.view.view.onclicklistener;  public class mainactivity extends activity {      button button1;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         addlisteneronbutton();     }      public void addlisteneronbutton() {         final context context = this;         button1 = (button) findviewbyid(r.id.abus);          button1.setonclicklistener(new onclicklistener() {              @override             public void onclick(view arg0) {                  intent intent = new intent(context, pageone.class);                 startactivity(intent);              }          });      }  } 

pageone.java

package com.d.da;  import android.app.activity; import android.os.bundle; import android.widget.button;  public class pageone extends activity {      button button1;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.abus);     } } 

you didn't add onclicklistener button on second activity

edit:

package com.d.da;  import android.app.activity; import android.os.bundle; import android.widget.button;  public class pageone extends activity {      button button2;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.abus);          addlisteneronbutton();     }       public void addlisteneronbutton() {         final context context = this;         button2 = (button) findviewbyid(r.id.abus2);         button2.setonclicklistener(new onclicklistener() {              @override             public void onclick(view arg0) {                 intent intent = new intent(context, mainactivity2.class);                 startactivity(intent);             }         });      } } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -