In onCreate
, you already operating inside an instance of InterfaceScreen
. It's called this
. You don't need to create a new instance.
Instead of
myAnimal.eat(String1);
myAnimal.sleep(String2);
just say
this.eat(String1);
this.sleep(String2);
or even better
eat(String1);
sleep(String2);
Also, variables typically start with a lowercase letter: string1
and string2
. Classes start with an uppercase letter.
The NullPointerException
was happening because your new instance wasn't getting correct tv1
and tv2
references. In Android, we don't make instances of our Activity
s.