FirstActivity.java

package archie.android.dialog; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class FirstActivity extends Activity { private Button myButton; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); myButton=(Button) findViewById(R.id.myButton1); myButton.setText("点我"); myButton.setOnClickListener(new MyButtonListener()); } class MyButtonListener implements OnClickListener{ @Override public void onClick(View v) { Intent intent=new Intent(); intent.setClass(FirstActivity.this, AnotherActivity.class); FirstActivity.this.startActivity(intent); } } }

AnotherActivity.java

package archie.android.dialog; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class AnotherActivity extends Activity { private Button myButton2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.another); myButton2=(Button) findViewById(R.id.myButton2); myButton2.setText("回到第一个"); myButton2.setOnClickListener(new MyButtonListener()); } class MyButtonListener implements OnClickListener{ @Override public void onClick(View v) { Intent intent=new Intent(); intent.setClass(AnotherActivity.this, FirstActivity.class); AnotherActivity.this.startActivity(intent); } } }

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="archie.android.dialog" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".FirstActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".AnotherActivity" android:label="@string/another" android:theme="@android:style/Theme.Dialog"/> </application> </manifest>

更多相关文章

  1. android回到桌面的方法
  2. android webview点击返回键回到上一个html
  3. android利用handler回到主线程
  4. android 返回到首页
  5. Android(安卓)Notification的使用
  6. Android(安卓)Notification的使用
  7. Pycharm 查看代码引用时,想跳回到上一步 设置
  8. Android(安卓)Studio - 第四十三期 RecyclerView存在大量Item时,
  9. android api25 点击隐藏BottomSheet需求的Behavior设置技巧

随机推荐

  1. Android HAL模块实现
  2. Android开发: 线程间消息通信 Looper 和H
  3. 用Gradle 构建你的android程序-依赖管理
  4. Android之通知的使用-Notification
  5. Android:自绘动画实践——以Tencent OS录
  6. Android(安卓)MP3音乐播放器总结
  7. Android 开发知识收藏夹(2)
  8. Android(安卓)View与GroupView原理以及其
  9. android XMl 解析神奇xstream 四: 将复杂
  10. Qt for Android 调用android原生接口分享