【Android】this Vs Activity.this

don't talk nonsense

It's better to use Activity.this all together so there will be no problem

 

[Pit] An error will be reported if this is used in an internal anonymous class

[Fill in] This in the JAVA foundation represents the reference of the current class, and this anonymous class is used at this time in the internal anonymous.

 

【B.T.W】

- Q> What the hell is an inner anonymous class? ?

- Answer> No name, only used once and gone

OnClickListener such as the following code snippet

        private Button btnB ;        
        btnB = (Button) findViewById(R.id.btn_b);
        btnB.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                
            }
        });

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325870503&siteId=291194637