I have programmed a few buttons on my main.xml and in my java. But what I want to know is that lets say I tap the button it brings me to another page of buttons. How do I program those buttons? I tried creating another java but that will not work.
            Asked
            
        
        
            Active
            
        
            Viewed 1,635 times
        
    -3
            
            
        - 
                    http://www.google.co.in/#sclient=psy-ab&hl=en&source=hp&q=on+button+click+start+activity+in+android&pbx=1&oq=on+button+click+start+activity+in+android&aq=0j&aqi=g-j1&aql=&gs_sm=1&gs_upl=55918l55918l1l57024l1l1l0l0l0l0l117l117l0.1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=5caab28acf873349&biw=1280&bih=923 – Samir Mangroliya Feb 27 '12 at 18:33
- 
                    http://stackoverflow.com/questions/4186021/how-to-start-a-new-activity-when-click-on-button – JanOlMajti Feb 27 '12 at 18:38
1 Answers
2
            
            
        In myMenu.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Button bButton1 = (Button) findViewById(R.id.button1);
    bButton1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            startActivity(new Intent("com.jom.tutbasics.TUTORIALONE"));
        }
    });
In AndroidManifest.xml
 <activity android:name=".tutorialOne"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.Dialog">
        <intent-filter>
            <action android:name="com.jom.tutbasics.TUTORIALONE" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
In tutorialOne.java
 public class tutorialOne extends Activity implements OnCheckedChangeListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tutorial1);
            ...
and tutorial1.xml whatever you want to be in the opened page.
 
    
    
        JanOlMajti
        
- 1,387
- 4
- 22
- 34
 
    