How To Define A Method Called In MainActivity From Another Class?
Solution 1:
Try checking OOPs concept for inheritance and overriding. As MainAcitivity is a parent class and TextC child, you get access of parent functions in child and not other way around. what you are trying to do is impossible unless you figure out the exact structure you are looking for.
May be you are looking to declare changeText2() function as public or protected in MainActicity and then override its implementation in child class if needed at all.
Solution 2:
TextC class should be your parent class of the MainActivity like
public class MainActivity extends TextC
meanwhile TextC should be extend to AppCompactActivity and it should be abstact like shown in below.
public abstract class TextC extends AppCompatActivity
if you do like this then you can access to functions present in TextC and change the name of the TextC and make it as BaseClass or something to make sense
Post a Comment for "How To Define A Method Called In MainActivity From Another Class?"