- 论坛徽章:
- 0
|
您好:
一般this,都是指 物件本身。
但是在 Android的範例中
ibWeixin.setOnClickListener(onClick的方法名稱); 中 ,他用 this
那這一個this是指 物件本身嗎? 它會自動 指到onclick嗎?
這該如何解釋呢?
謝謝!- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.activity_main);
-
- ibWeixin=(ImageButton) findViewById(R.id.tab_bottom_weixin);
- ibWeixin.setOnClickListener(this); //設定按鈕的click Listener
-
- ibFriend=(ImageButton) findViewById(R.id.tab_bottom_friend);
- ibFriend.setOnClickListener(this);
-
- setDefaultFragment();
- }
- public void onClick(View v){
- FragmentManager fm = getFragmentManager();
- ....
- }
复制代码 |
|