• Activity到另一个Acivity


    res/main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <Button 
    			android:id="@+id/btn1"
    			android:layout_x="118dip" 
    			android:text="Button" 
    			android:layout_width="wrap_content" 
    			android:layout_height="wrap_content"  
    			android:layout_y="145dip"></Button>
    <TextView 
    			android:text="这是第一个Activity" 
    			android:layout_width="fill_parent" 
    			android:id="@+id/textView1" 
    			android:layout_height="wrap_content" 
    			android:layout_x="5dip" 
    			android:layout_y="92dip"></TextView>
    </AbsoluteLayout>

    res/ex03_09_01.xml

    <?xml version="1.0" encoding="utf-8"?>
    <AbsoluteLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent">
        <TextView android:text="这是第二个Activity" 
        		  android:layout_width="wrap_content" 
        		  android:layout_height="wrap_content" 
        		  android:layout_x="122dip" 
        		  android:layout_y="96dip" 
        		  android:id="@+id/tv2"></TextView>
        <Button android:layout_x="116dip" 
        		android:text="Button" 
        		android:layout_width="wrap_content" 
        		android:layout_height="wrap_content" 
        		android:layout_y="130dip" 
        		android:id="@+id/btn2"></Button>
    </AbsoluteLayout>

    src/EX03_09.java

    package gphone.ex03_09;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    
    public class EX03_09 extends Activity {
    	Button btn1=null;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            btn1=(Button)findViewById(R.id.btn1);
            btn1.setOnClickListener(new Button.OnClickListener(){
    
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				Intent intent=new Intent();
    				intent.setClass(EX03_09.this,EX03_09_01.class);
    				startActivity(intent);
    				EX03_09.this.finish();
    			}
            	
            });
        }
    }

    src/EX03_09_01.java

    package gphone.ex03_09;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    
    public class EX03_09_01 extends Activity{
    	Button btn2=null;
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		// TODO Auto-generated method stub
    		super.onCreate(savedInstanceState);
    		this.setContentView(R.layout.ex036_09_01);
    		
    		btn2=(Button)findViewById(R.id.btn2);
    		btn2.setOnClickListener(new Button.OnClickListener(){
    
    			@Override
    			public void onClick(View v) {
    				// TODO Auto-generated method stub
    				Intent intent=new Intent();
    				intent.setClass(EX03_09_01.this,EX03_09.class);
    				startActivity(intent);
    				EX03_09_01.this.finish();
    				
    			}
    			
    		});
    		
    	}
    	
    }
  • 相关阅读:
    简述Javascript中call apply
    tomato固件 路由简单玩 BT 电驴 amule highId python 其实dd wrt也一样 含 amule_2.2.61_mipsel.ipk下载
    Ubuntu10.10 下usb鼠标不动了
    Struts2源码分析 初步1 如何入手以及做了哪些初始化
    ubuntu eclipse easyexplore 替代品 open explorer
    struts2 src study 准备工作 和 略谈 如何读开源代码(Java)
    python 解析XML expat方式
    正则表达式基础 多选结构 加不加括号大不同
    UVa1586,Molar Mass
    UVa12100,Printer Queue
  • 原文地址:https://www.cnblogs.com/AlexCheng/p/2120048.html
Copyright © 2020-2023  润新知