• android用Intent实现Activity跳转 java程序员


    package com.example.intenttest;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.view.Menu;
    import android.view.View;
    import android.widget.Button;
    
    public class MainActivity extends Activity {
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.main);
    		Button btn1=(Button)findViewById(R.id.b1);
    		btn1.setOnClickListener(new Button.OnClickListener()
    		{
    			public void onClick(View view)
    			{
    				Intent intent=new Intent();
    				intent.setClass(MainActivity.this,Test.class);
    				startActivity(intent);
    				MainActivity.this.finish();
    			}
    		});
    	}
    
    	@Override
    	public boolean onCreateOptionsMenu(Menu menu) {
    		// Inflate the menu; this adds items to the action bar if it is present.
    		getMenuInflater().inflate(R.menu.main, menu);
    		return true;
    	}
    
    }
    



     

    package com.example.intenttest;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.view.Menu;
    import android.view.View;
    import android.widget.Button;
    
    public class Test extends Activity {
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.test);
    		Button btn2=(Button)findViewById(R.id.b2);
    		btn2.setOnClickListener(new Button.OnClickListener()
    		{
    			public void onClick(View view)
    			{
    				Intent intent=new Intent();
    				intent.setClass(Test.this,MainActivity.class);
    				startActivity(intent);
    				Test.this.finish();
    			}
    		});
    	}
    	@Override
    	public boolean onCreateOptionsMenu(Menu menu) {
    		// Inflate the menu; this adds items to the action bar if it is present.
    		getMenuInflater().inflate(R.menu.main, menu);
    		return true;
    	}
    
    }
    


     

  • 相关阅读:
    Salesforce 大量数据部署的最佳实践
    Salesforce 数据备份和恢复小知识
    Salesforce 导入导出数据简介
    GDPR 和个人信息保护的小知识
    代码审查要点简介
    Salesforce 外部对象
    Python scipy.sparse.csr_matrix()[csc_matrix()]
    Deep Compression
    Pascal voc api
    Python内置模块-xml模块
  • 原文地址:https://www.cnblogs.com/java20130725/p/3215869.html
Copyright © 2020-2023  润新知