Child class overrides lambda in parent class
See original GitHub issuepublic abstract class ParentActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentView());
findViewById(R.id.button_parent).setOnClickListener(view -> Toast.makeText(this, "Parent onClick", Toast.LENGTH_LONG).show());
}
public abstract int getContentView();
}
public class MainActivity extends ParentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findViewById(R.id.button_child).setOnClickListener(view -> Toast.makeText(this, "Child onClick", Toast.LENGTH_LONG).show());
}
@Override
public int getContentView() {
return R.layout.activity_main;
}
}
Clicking on button_parent shows a Toast with “Child onClick”
Issue Analytics
- State:
- Created 7 years ago
- Comments:9
Top Results From Across the Web
TypeScript - how to inherit class and override lambda method
This method is called from the base constructor, and needs access to instance properties, so it needs to be a lambda function, so...
Read more >Child class overrides lambda in parent class #109 - GitHub
One solution is to convert the private instance method into a package-private static method, which won't be overridable by child classes. This ...
Read more >How to get child property inside parent class, with lambda?
... prop in the base class, make it overridable and override it in each subclass to return the value that makes sense for...
Read more >Method overriding in Python - The Digital Cat
In Python method overriding occurs simply defining in the child class a method with the same name of a method in the parent...
Read more >Method Overriding in TypeScript - GeeksforGeeks
Example 1: In this example, we will declare two classes and inside the parent class we will declare one method which will be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I opened an issue in the retrolambda project: https://github.com/orfjackal/retrolambda/issues/109
I guess this one here may be closed.
I did some tests building the retrolambda project locally. It appears the bug appears in this commit: https://github.com/orfjackal/retrolambda/commit/bf932457e45817cdee07f34c8c2059db44848e03
I have not done any investigation to understand what part of that commit introduces the bug.