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

Android 界面跳转

时间:2015-08-21 18:44:26      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

package com.example.tianchu;

import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class DialogActivity extends Activity {
    RelativeLayout linear = null;
      
      
      @Override
        protected void  onCreate(Bundle savedInstanceState) {  
             super.onCreate(savedInstanceState);
 
             super.requestWindowFeature(Window.FEATURE_NO_TITLE);
 
             super.setContentView(R.layout.daactivity_main);
 
               this.linear =  (RelativeLayout) super.findViewById(R.id.tianchu);                
               this.linear.setOnClickListener(new  OnClickListener() {  
 
                    @Override
                      public void  onClick(View v) {                              
                        //  TODO Auto-generated method stub  
                           Toast.makeText(DialogActivity.this, "你点击了这个弹出窗口咯",
 
                                         Toast.LENGTH_SHORT).show();
 
                    }
 
             });
 
      }
      public boolean  onTouchEvent(MotionEvent event) {               
          //  TODO Auto-generated method stub                
          this.finish();//  结束本Activity  
          return super.onTouchEvent(event);

   }

}

package com.example.tianchu;

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

public class MainActivity extends Activity {

    protected void  onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);
          super.requestWindowFeature(Window.FEATURE_NO_TITLE);//  去掉顶部标题  
        super.setContentView(R.layout.activity_main);

          Button  mybut = (Button) super.findViewById(R.id.button1);               
          mybut.setOnClickListener(new  OnClickListener() {  

               public void  onClick(View v) {                              //  TODO Auto-generated method stub  
                      Toast.makeText(MainActivity.this, "弹出了一个窗口哦",

                                    Toast.LENGTH_SHORT).show();
                        Intent  intent = new Intent(MainActivity.this,  
                                    DialogActivity.class);

                      MainActivity.this.startActivity(intent);

               }

        });

 }

    

}

 

 

17:51:53  2015-08-21

 

Android 界面跳转

标签:

原文地址:http://www.cnblogs.com/wang251/p/4748586.html

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