当前位置: 代码迷 >> Android >> 为什么要用 this·解决方法
  详细解决方案

为什么要用 this·解决方法

热度:85   发布时间:2016-05-01 22:00:08.0
为什么要用 this·。。。
请问这里FfffActivity.this.getRequestedOrientation()
中的 为什么不能FfffActivity.getRequestedOrientation()
非要价格this 就是这样 FfffActivity.this.getRequestedOrientation()
 一 一+

==================================================
public class FfffActivity extends Activity {
/** Called when the activity is first created. */
private Button change = null;

private ImageView img = null;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.change = (Button) findViewById(R.id.change);
this.img = (ImageView) findViewById(R.id.img);

}

private class MyOnClickListenerImp1 implements OnClickListener {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub

if (FfffActivity.this.getRequestedOrientation()) {

}
========================================================




------解决方案--------------------
内部类。不用的话,this指的就是那个Listener。楼主java基础不扎实。
------解决方案--------------------
this. 有问题找java老湿给你解释吧.
------解决方案--------------------
请问这里FfffActivity.this.getRequestedOrientation()
中的 为什么不能FfffActivity.getRequestedOrientation() 
非要价格this 就是这样 FfffActivity.this.getRequestedOrientation()
 一 一+

若FfffActivity.getRequestedOrientation(), getRequestedOrientation()这个方法就成静态了;属于类的静态方法,可以这个使用;
加this,就是当前类的对象了,对象.getRequestedOrientation();


------解决方案--------------------
探讨

……
若FfffActivity.getRequestedOrientation(), getRequestedOrientation()这个方法就成静态了;属于类的静态方法,可以这个使用;
加this,就是当前类的对象了,对象.getRequestedOrientation();
  相关解决方案