I have an interface:
public interface ICustomObjectListingViews {
View createCustomObjectListingView(MyDBObject myDBObject);
}
Then :
public abstract class AbstractICustomObjectListingViews implements ICustomObjectListingViews {
@Override
public View createCustomObjectListingView(MyDBObject myDBObject) {
return null;
}
}
I then try to implement the interface by extending the abstract class :
public class MyCustomObjectListingView extends AbstractICustomObjectListingViews {
@Override
public VIew createCustomObjectListingView(MyDBObject myDBObject) {
Log.v("MyApp", ">>>> " + myDBObject.get_myObjectDescription());
TextView textView = new TextView(mContext);
textView.setText(myDBObject.get_myObjectDescription());
return textView;
}
}
I use MyObject to map my database results:
public class MyDBObject {
public MyDBObject() {
}
private String _myObjectDescription;
public void set_myObjectDescription(String _myObjectDescription) {
this._myObjectDescription = _myObjectDescription;
}
public String get_myObjectDescription() {
return _myObjectDescription;
}
}
I, however, get a null pointer whenever I try to call MyCustomObjectListingView
's implementation of createCustomObjectListingView(MyDBObject myDBObject)
.
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String MyDBObject.get_myObjectDescription()' on a null object reference
at :
Log.v("MyApp", ">>>> " + myDBObject.get_myObjectDescription());
This is how I call it:
MyDBObject myObject = new MyObject();
myObject.set_myObjectDescription("HELLO WORLD");
ICustomObjectListingViews iCustomObjectListingViews = new MyCustomObjectListingView();
iCustomObjectListingViews.createCustomObjectListingView(myObject);
What am I getting wrong? How should I call an overriding class' overriden method? How can I make the above attempt work?
Thank you all in advance.