zoukankan      html  css  js  c++  java
  • 一个简单的页面跳转


    代码
    package demo.test;

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;

    public class testmain extends Activity {
        
    /** Called when the activity is first created. */
        @Override
        
    public void onCreate(Bundle savedInstanceState) {
            
    super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            Button btn
    =(Button)findViewById(R.id.Button01); 
            
            btn.setOnClickListener(
    new  View.OnClickListener() { 
              
    public void onClick(View view) { 
               Intent intent
    =new Intent();
            intent.setClass(testmain.
    this,testchild.class);
            startActivity(intent);
            finish();
              } 
            });
            
            
            
           
        }
    }
    代码
    package demo.test;


    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    public class testchild extends Activity {
         
    /** Called when the activity is first created. */
        @Override
        
    public void onCreate(Bundle savedInstanceState) {
            
    super.onCreate(savedInstanceState);
            setContentView(R.layout.child2);
       Button btn
    =(Button)findViewById(R.id.Button01); 
            
            btn.setOnClickListener(
    new  View.OnClickListener() { 
              
    public void onClick(View view) { 
               Intent intent
    =new Intent();
            intent.setClass(testchild.
    this,testmain.class);
            startActivity(intent);
            finish();
              } 
            });
        }
    }
    代码
    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package
    ="demo.test"
          android:versionCode
    ="1"
          android:versionName
    ="1.0">
        
    <application android:icon="@drawable/icon" android:label="@string/app_name">
            
    <activity android:name=".testmain"
                      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=".testchild"
                      android:label
    ="@string/app_name">
               
            
    </activity>
        
    </application>


    </manifest> 
  • 相关阅读:
    VS10的一个问题
    有关开发的配置的有用信息
    管理Fragments(转)
    消除SDK更新时的“https://dl-ssl.google.com refused”异常--(转)
    JAVA字符串编码转换常用类
    在 Android 中调用二进制可执行程序(native executable )
    Android NDK 下的宽字符编码转换及icu库的使用(转)
    Linux字符编码转换 UTF8转GB3212
    一键生成JNI头文件方法二
    eclipse中创建NDK和JNI开发环境最简单配置方法
  • 原文地址:https://www.cnblogs.com/gwazy/p/1918991.html
Copyright © 2011-2022 走看看