Home  >  Article  >  Java  >  Launch new Activity(Intent)

Launch new Activity(Intent)

Linda Hamilton
Linda HamiltonOriginal
2024-09-22 14:15:33237browse

Launch new Activity(Intent)

XML file:

 <Button
           android:id="@+id/btn"
           android:onClick="launchSettings"
           android:text="button"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"/>

java file:

 public void launchSettings(View v){

        //Launch a new activity

        Intent i = new Intent(this,SettingActivity.class);
        startActivity(i);
    }

After adding these functionality you will be able to launch new Activity.

The above is the detailed content of Launch new Activity(Intent). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn