标签:
1 package com.example.metrox.l7; 2 3 import android.content.Intent; 4 import android.support.v7.app.AppCompatActivity; 5 import android.os.Bundle; 6 import android.view.View; 7 import android.widget.Button; 8 import android.widget.TextView; 9 10 public class MainActivity extends AppCompatActivity { 11 12 @Override 13 protected void onCreate(Bundle savedInstanceState) { 14 super.onCreate(savedInstanceState); 15 setContentView(R.layout.activity_main); 16 ((TextView) findViewById(R.id.taskView)).setText(String.format("任务ID:%d\n,当前实例ID:%s",getTaskId(),toString())); 17 findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { 18 @Override 19 public void onClick(View view) { 20 startActivity(new Intent(MainActivity.this,MainActivity.class)); 21 } 22 }); 23 24 findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() { 25 @Override 26 public void onClick(View view) { 27 startActivity(new Intent( MainActivity.this,Baty.class)); 28 } 29 }); 30 } 31 }
1 package com.example.metrox.l7; 2 3 import android.content.Intent; 4 import android.support.v7.app.AppCompatActivity; 5 import android.os.Bundle; 6 import android.view.View; 7 import android.widget.TextView; 8 9 public class Baty extends AppCompatActivity { 10 11 @Override 12 protected void onCreate(Bundle savedInstanceState) { 13 super.onCreate(savedInstanceState); 14 setContentView(R.layout.activity_baty); 15 ((TextView) findViewById(R.id.textView)).setText(String.format("任务ID:%d\n,当前实例ID:%s",getTaskId(),toString())); 16 17 findViewById(R.id.startm).setOnClickListener(new View.OnClickListener() { 18 @Override 19 public void onClick(View view) { 20 startActivity(new Intent(Baty.this,MainActivity.class)); 21 } 22 }); 23 } 24 }
1 <?xml version="1.0" encoding="utf-8"?> 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="com.example.metrox.l7"> 4 5 <application 6 android:allowBackup="true" 7 android:icon="@mipmap/ic_launcher" 8 android:label="@string/app_name" 9 android:supportsRtl="true" 10 android:theme="@style/AppTheme"> 11 <activity 12 android:name=".MainActivity" 13 android:label="Mian" 14 android:launchMode="sin"> 15 <intent-filter> 16 <action android:name="android.intent.action.MAIN" /> 17 18 <category android:name="android.intent.category.LAUNCHER" /> 19 </intent-filter> 20 </activity> 21 <activity android:name=".Baty" android:label="Baty"></activity> 22 </application> 23 24 </manifest>
标签:
原文地址:http://www.cnblogs.com/linhongquan/p/5571209.html