android界面跳转

1.主布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context=".MainActivity" >

    <ImageView
        android:id="@+id/main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="40dp"
        android:layout_marginTop="10dp"
        android:contentDescription="@string/app_name"
        android:src="@drawable/mainbody" />
    
    <ImageButton
        android:id="@+id/mainpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="45dp"
        android:layout_marginLeft="13dp"
        android:background="@drawable/bigtab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/main" />
    
      <ImageButton
        android:id="@+id/timepage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="17dp"
        android:layout_marginTop="103dp"
        android:background="@drawable/littletab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/time" />
      
      <ImageButton
        android:id="@+id/calenpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="17dp"
        android:layout_marginTop="160dp"
        android:background="@drawable/littletab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/calen" />
    
      <ImageButton
        android:id="@+id/recelpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="17dp"
        android:layout_marginTop="217dp"
        android:background="@drawable/littletab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/recel" />
      
        <ImageButton
        android:id="@+id/setpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="17dp"
        android:layout_marginTop="274dp"
        android:background="@drawable/littletab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/set" />
    
    

</RelativeLayout>

跳转页布局文件


<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context=".MainActivity" >

     <ImageView
        android:id="@id/main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="40dp"
        android:layout_marginTop="10dp"
        android:contentDescription="@string/app_name"
        android:src="@drawable/mainbody" />
    
    <ImageButton
        android:id="@id/mainpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="46dp"
        android:layout_marginLeft="17dp"
        android:background="@drawable/littletab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/main" />
    
      <ImageButton
        android:id="@id/timepage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="13dp"
        android:layout_marginTop="102dp"
        android:background="@drawable/bigtab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/time" />
      
      <ImageButton
        android:id="@id/calenpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="17dp"
        android:layout_marginTop="160dp"
        android:background="@drawable/littletab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/calen" />
    
      <ImageButton
        android:id="@id/recelpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="17dp"
        android:layout_marginTop="217dp"
        android:background="@drawable/littletab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/recel" />
      
        <ImageButton
        android:id="@id/setpage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="17dp"
        android:layout_marginTop="274dp"
        android:background="@drawable/littletab"
        android:contentDescription="@string/app_name"
        android:src="@drawable/set" />
    
    
    

</RelativeLayout>

主Activity文件

package com.example.time_manager;

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

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageButton button_2 = (ImageButton) findViewById(R.id.timepage);
        button_2.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent_time = new Intent(MainActivity.this,TimeActivity.class);
				startActivity(intent_time);
				
			}
		});
        
        ImageButton button_3 = (ImageButton) findViewById(R.id.calenpage);
        button_3.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent_calen = new Intent(MainActivity.this,CalenActivity.class);
				startActivity(intent_calen);
			}
		});
        
        ImageButton button_4 = (ImageButton) findViewById(R.id.recelpage);
        button_4.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent_recel = new Intent(MainActivity.this,RecelActivity.class);
				startActivity(intent_recel);
			}
		});
        
        ImageButton button_5 = (ImageButton) findViewById(R.id.setpage);
        button_5.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				Intent intent_set = new Intent(MainActivity.this,SetActivity.class);
				startActivity(intent_set);
			}
		});
    }


    @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;
    }
    
}

Android Manifest添加

<activity
    android:name=".TimeActivity"
    android:label="@string/app_name" />


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值