码迷,mamicode.com
首页 > 移动开发 > 详细

Android窗口跳转

时间:2014-07-30 23:49:05      阅读:360      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   http   color   os   io   for   

1、原始界面

package com.fish.helloworld;

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

public class Forwarding extends Activity {

    private backButton_OnClickListener backButtonListener = new backButton_OnClickListener();
    
    class backButton_OnClickListener implements OnClickListener{
        public void onClick(View v){
            Intent intent = new Intent();
            intent.setClass(Forwarding.this, MainActivity.class);
            startActivity(intent);
            finish();
        }
    }
     
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_forwarding);
        
        final Button backButton = (Button)findViewById(R.id.button1);
        backButton.setOnClickListener(backButtonListener);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.forwarding, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

 

2、AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.fish.helloworld"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="17"
        android:targetSdkVersion="17" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
        </activity>
        <activity
            android:name=".Forwarding"
            android:label="@string/title_activity_forwarding" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

 

3、

Android窗口跳转,布布扣,bubuko.com

Android窗口跳转

标签:android   style   blog   http   color   os   io   for   

原文地址:http://www.cnblogs.com/sshoub/p/3879482.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!