How to Go to New Screen/Page in Android Studio? -
i have quick question regarding android studio.
so first of new thing don't me wrong if make mistake.
so doing have created title screen app called "canada quiz". , below title have "start" button. , done far have attached code this: once start button clicked hide it. question.
how make once clicked should hide start button , show question , true , false button. have this. want questions appear person taps start button. , in content_main.xml have phone model witch displays start button , canada quiz. please me out possible
thank you!
package com.example.nilesh.myapplication; import android.os.bundle; import android.support.v4.view.viewpager; import android.support.v7.app.appcompatactivity; import android.view.view; import android.view.menu; import android.view.menuitem; import android.widget.button; import java.util.arraylist; public class mainactivity extends appcompatactivity { private button startbutton; private button truebutton; private button falsebutton; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); startbutton = (button) findviewbyid(r.id.startbutton); arraylist <string> questions = new arraylist<string>(); string firstque = " canada located in north america? "; string secondque = " ontario largest provice in canada? "; string thridque = " toronto largest city in canada? "; string fourque = " canada has 3 professional basketball teams. "; string fiveque = " canada has 11 provinces , 3 territories. "; string sixque = " justin trudeau not canada's prime minister. "; final string [] allquestions = {firstque,secondque,thridque,fourque,fiveque,sixque}; startbutton.setonclicklistener(new view.onclicklistener() { public void onclick (view v) { startbutton.setvisibility(view.invisible); } }); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_main, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle clicks on home/up button, long // specify parent activity in androidmanifest.xml. int id = item.getitemid(); //noinspection simplifiableifstatement if (id == r.id.action_settings) { return true; } return super.onoptionsitemselected(item); } public button gettruebutton() { return truebutton; } public void settruebutton(button truebutton) { this.truebutton = truebutton; } public button getfalsebutton() { return falsebutton; } public void setfalsebutton(button falsebutton) { this.falsebutton = falsebutton; } }
note cannot see true button , false button content_main.xml file....
to go next screen, use code:
intent intent = new intent(mainactivity.this, nextactivity.class); startactivity(intent);
Comments
Post a Comment