How to switch between screens?

后端 未结 6 1240
梦如初夏
梦如初夏 2020-12-31 20:37

I\'m new in the android develop world. I created simple application and created a simple GUI with one button. If the user presses this button, I want to change the screen

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-31 21:09

    Another way,Button in an XML graphical layout and implement a button click listener together with an onclick method. The onclick method will start a new activity using an intent.

    Now go to your Class

    // Locate the button in activity_main.xml
        button = (Button) findViewById(R.id.buttonClick);
    
        // Capture button clicks
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View arg0) {
    
                // Start NewActivity.class
                Intent myIntent = new Intent(getApplicationContext(),AddYourNewActivityName.class);
                startActivity(myIntent);
            }
        });
    

    Hope this helps .

    For details http://www.vogella.com/tutorials/AndroidIntent/article.html

提交回复
热议问题