Answer the question
In order to leave comments, you need to log in
Calling a method in java. What's the difference between this.method() and method() when called inside a class?
There is a method inside the class.
public class RssReaderActivity extends Activity {
private void crossfade()
{
myButton.animate().alpha(1f).setDuration(animationShortDuration).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
step3Button.setVisibility(View.VISIBLE);
}
});
}
...
private View.OnClickListener sayHelloClickedListener = new View.OnClickListener(){
public void onClick(View v){
Integer viewId = (Integer)v.getId();
Resources viewRes = (Resources)v.getResources();
String buttonIdent = (String) viewRes.getResourceEntryName(viewId);
Log.v("OnClickLogger",buttonIdent);
if( buttonIdent.equals(String.valueOf("button_sayHello")) ) {
sayHelloText = (TextView) findViewById(R.id.textView_sayHello);
sayHelloText.setText("Hello Man!");
}
if( buttonIdent.equals(String.valueOf("button_appStep2")) ){
crossfade(); /* понимаю что здесь нельзя использовать this */
}
}
};
Answer the question
In order to leave comments, you need to log in
Java allows you to use class methods from an inner class. If for some reason you want to explicitly specify the object of the called method, for example, in case of a name conflict, you can get a pointer to the container from the inner class by explicitly specifying the name of the container. In your case "RssReaderActivity.this.crossfade()".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question