this作为方法参数什么含义?

闪耀 发布于 2014/03/29 14:27
阅读 799
收藏 0
packagecom.xjj.alarmclocksnoozers.runnershigh;
002   
003 importnet.youmi.android.AdManager;
004 importnet.youmi.android.diy.AdObject;
005 importnet.youmi.android.offers.OffersAdSize;
006 importnet.youmi.android.offers.OffersBanner;
007 importnet.youmi.android.offers.OffersManager;
008 importnet.youmi.android.spot.SpotManager;
009   
010 importcom.umeng.analytics.MobclickAgent;
011 importcom.xjj.alarmclocksnoozers.runnershigh.R;
012 importcom.xjj.ad.XjjAdManager;
013   
014 importandroid.app.Activity;
015 importandroid.app.AlertDialog;
016 importandroid.app.Dialog;
017 importandroid.content.Intent;
018 importandroid.graphics.Color;
019 importandroid.graphics.PorterDuff;
020 importandroid.media.MediaPlayer;
021 importandroid.net.Uri;
022 importandroid.os.Bundle;
023 importandroid.os.Handler;
024 importandroid.view.Gravity;
025 importandroid.view.View;
026 importandroid.view.Window;
027 importandroid.view.WindowManager;
028 importandroid.widget.FrameLayout;
029 importandroid.widget.Toast;
030   
031 publicclassMenuextendsActivity {
032     MediaPlayer menuLoop;
033     privateToast loadMessage;
034     privateRunnable gameLauncher;
035     privateIntent gameIntent;
036     privateHandler mHandler;
037     privateandroid.widget.Button mPlayButton;
038       
039     @Override
040     publicvoidonCreate(Bundle savedInstanceState) {
041   
042         requestWindowFeature(Window.FEATURE_NO_TITLE);  
043         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
044           
045         super.onCreate(savedInstanceState);
046         setContentView(R.layout.menu); 
047           
048   
049         loadMessage = Toast.makeText(getApplicationContext(),"loading game...", Toast.LENGTH_SHORT );
050         loadMessage.setGravity(Gravity.CENTER|Gravity.CENTER,0,0);
051           
052         gameIntent =newIntent (this, main.class);
053         mPlayButton = (android.widget.Button)findViewById(R.id.startButton);
054         mPlayButton.setClickable(true);
055         mPlayButton.setEnabled(true);
056         gameLauncher =newRunnable() {
057               
058             publicvoidrun() {
059                 mPlayButton.setClickable(false);
060                 mPlayButton.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
061                 startActivityForResult(gameIntent,0);
062             }
063         };
064           
065         mHandler =newHandler();
066           
067           
068           
069         /*
070         menuLoop = MediaPlayer.create(getApplicationContext(), R.raw.menu);  
071         menuLoop.setLooping(true);
072         menuLoop.seekTo(0);
073         menuLoop.setVolume(0.5f, 0.5f);
074         menuLoop.start();
075         */
076           
077         XjjAdManager.insertAd(this);
078           
079         SpotManager.getInstance(this).showSpotAds(this);
080     }
081       
082     publicvoidplayGame(View view) {
083   
084         // Loading Toast
085         loadMessage.show();
086         Settings.SHOW_FPS =false;
087         mHandler.post(gameLauncher);
088     }
089       
090     publicvoidplayGameWithFPS(View view) {
091   
092         // Loading Toast
093         loadMessage.show();
094         Settings.SHOW_FPS =true;
095         mHandler.post(gameLauncher);
096     }
097       
098     publicvoidshowScore(View view) {
099         Intent myIntent =newIntent (this, HighScoreActivity.class);
100         startActivity (myIntent);
101     }
102       
103     publicvoidshowInfo(View view) {
104         Intent myIntent =newIntent (this, Info.class); <SPAN style="BACKGROUND-COLOR: #e56600"><SPAN style="BACKGROUND-COLOR: #64451d"><SPAN style="COLOR: #e56600"></SPAN></SPAN></SPAN> startActivity (myIntent);
105     }
106       
107     protectedvoidonActivityResult (intrequestCode,intresultCode, Intent data) {
108         if(resultCode ==1) {
109             showDialog(1);
110             mHandler.postDelayed(newRunnable() {
111                   
112                 publicvoidrun() {
113                     mPlayButton.setClickable(true);
114                     mPlayButton.getBackground().clearColorFilter();
115                 }
116             },10000);
117         }else{
118             mPlayButton.setClickable(true);
119             mPlayButton.getBackground().clearColorFilter();
120         }
121           
122     }
123       
124     publicvoiddonate(View view) {
125         Intent browserIntent =newIntent("android.intent.action.VIEW", Uri.parse(Settings.URL_DONATE));
126         startActivity(browserIntent);
127     }
128       
129     protectedDialog onCreateDialog(intid) {
130         returnnewAlertDialog.Builder(this)
131           .setTitle("Error while changing view")
132           .setMessage("System needs some time to free memory. Please try again in 10 seconds.")
133           .setCancelable(true)
134           .create();
135     }
136       
137     @Override
138     publicvoidonDestroy() {
139         super.onDestroy();
140           
141         OffersManager.getInstance(this).onAppExit();
142     }
143       
144     publicvoidonResume() {
145         super.onResume();
146         MobclickAgent.onResume(this);
147     }
148   
149     publicvoidonPause() {
150         super.onPause();
151         MobclickAgent.onPause(this);
152     }
153 } <STRONG><SPAN style="BACKGROUND-COLOR: #003399"></SPAN></STRONG>

请问这段代码里方法圆括号里的this 是什么含义啊,

packagecom.xjj.alarmclocksnoozers.runnershigh;

002   
003 importnet.youmi.android.AdManager;
004 importnet.youmi.android.diy.AdObject;
005 importnet.youmi.android.offers.OffersAdSize;
006 importnet.youmi.android.offers.OffersBanner;
007 importnet.youmi.android.offers.OffersManager;
008 importnet.youmi.android.spot.SpotManager;
009   
010 importcom.umeng.analytics.MobclickAgent;
011 importcom.xjj.alarmclocksnoozers.runnershigh.R;
012 importcom.xjj.ad.XjjAdManager;
013   
014 importandroid.app.Activity;
015 importandroid.app.AlertDialog;
016 importandroid.app.Dialog;
017 importandroid.content.Intent;
018 importandroid.graphics.Color;
019 importandroid.graphics.PorterDuff;
020 importandroid.media.MediaPlayer;
021 importandroid.net.Uri;
022 importandroid.os.Bundle;
023 importandroid.os.Handler;
024 importandroid.view.Gravity;
025 importandroid.view.View;
026 importandroid.view.Window;
027 importandroid.view.WindowManager;
028 importandroid.widget.FrameLayout;
029 importandroid.widget.Toast;
030   
031 publicclassMenuextendsActivity {
032     MediaPlayer menuLoop;
033     privateToast loadMessage;
034     privateRunnable gameLauncher;
035     privateIntent gameIntent;
036     privateHandler mHandler;
037     privateandroid.widget.Button mPlayButton;
038       
039     @Override
040     publicvoidonCreate(Bundle savedInstanceState) {
041   
042         requestWindowFeature(Window.FEATURE_NO_TITLE);  
043         getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
044           
045         super.onCreate(savedInstanceState);
046         setContentView(R.layout.menu); 
047           
048   
049         loadMessage = Toast.makeText(getApplicationContext(),"loading game...", Toast.LENGTH_SHORT );
050         loadMessage.setGravity(Gravity.CENTER|Gravity.CENTER,0,0);
051           
052         gameIntent =newIntent (this, main.class);
053         mPlayButton = (android.widget.Button)findViewById(R.id.startButton);
054         mPlayButton.setClickable(true);
055         mPlayButton.setEnabled(true);
056         gameLauncher =newRunnable() {
057               
058             publicvoidrun() {
059                 mPlayButton.setClickable(false);
060                 mPlayButton.getBackground().setColorFilter(Color.GRAY, PorterDuff.Mode.MULTIPLY);
061                 startActivityForResult(gameIntent,0);
062             }
063         };
064           
065         mHandler =newHandler();
066           
067           
068           
069         /*
070         menuLoop = MediaPlayer.create(getApplicationContext(), R.raw.menu);  
071         menuLoop.setLooping(true);
072         menuLoop.seekTo(0);
073         menuLoop.setVolume(0.5f, 0.5f);
074         menuLoop.start();
075         */
076           
077         XjjAdManager.insertAd(this);
078           
079         SpotManager.getInstance(this).showSpotAds(this);
080     }
081       
082     publicvoidplayGame(View view) {
083   
084         // Loading Toast
085         loadMessage.show();
086         Settings.SHOW_FPS =false;
087         mHandler.post(gameLauncher);
088     }
089       
090     publicvoidplayGameWithFPS(View view) {
091   
092         // Loading Toast
093         loadMessage.show();
094         Settings.SHOW_FPS =true;
095         mHandler.post(gameLauncher);
096     }
097       
098     publicvoidshowScore(View view) {
099         Intent myIntent =newIntent (this, HighScoreActivity.class);
100         startActivity (myIntent);
101     }
102       
103     publicvoidshowInfo(View view) {
104         Intent myIntent =newIntent (this, Info.class); <SPAN style="BACKGROUND-COLOR: #e56600"><SPAN style="BACKGROUND-COLOR: #64451d"><SPAN style="COLOR: #e56600"></SPAN></SPAN></SPAN> startActivity (myIntent);
105     }
106       
107     protectedvoidonActivityResult (intrequestCode,intresultCode, Intent data) {
108         if(resultCode ==1) {
109             showDialog(1);
110             mHandler.postDelayed(newRunnable() {
111                   
112                 publicvoidrun() {
113                     mPlayButton.setClickable(true);
114                     mPlayButton.getBackground().clearColorFilter();
115                 }
116             },10000);
117         }else{
118             mPlayButton.setClickable(true);
119             mPlayButton.getBackground().clearColorFilter();
120         }
121           
122     }
123       
124     publicvoiddonate(View view) {
125         Intent browserIntent =newIntent("android.intent.action.VIEW", Uri.parse(Settings.URL_DONATE));
126         startActivity(browserIntent);
127     }
128       
129     protectedDialog onCreateDialog(intid) {
130         returnnewAlertDialog.Builder(this)
131           .setTitle("Error while changing view")
132           .setMessage("System needs some time to free memory. Please try again in 10 seconds.")
133           .setCancelable(true)
134           .create();
135     }
136       
137     @Override
138     publicvoidonDestroy() {
139         super.onDestroy();
140           
141         OffersManager.getInstance(this).onAppExit();
142     }
143       
144     publicvoidonResume() {
145         super.onResume();
146         MobclickAgent.onResume(this);
147     }
148   
149     publicvoidonPause() {
150         super.onPause();
151         MobclickAgent.onPause(this);
152     }
153 } <STRONG><SPAN style="BACKGROUND-COLOR: #003399"></SPAN></STRONG>

请问这段代码里方法圆括号里的this 是什么含义啊,this作为方法参数什么含义?

加载中
0
xyxo
xyxo

囧,Java的 this关键字一样的意思~~~

http://my.oschina.net/panjavay/blog/112842

你的Android app 无法就是特指当前的activity(实际上,也就是一个Java类~~╮(╯_╰)╭)~~

返回顶部
顶部