0

I have 2 classes. I want to do that I can call method from value to MainActivity , I don't know if I need to use interface (I don't know how to use interface)

MainActivity class:

public class MainActivity extends Activity {
    public void name() { 
        if (Check(display_ContactsName, C) == true) {

        }
     }
 }

value class:

public class Values extends MainActivity {
    private boolean Check(String Name, Cursor C) {

    } 
}
MPelletier
  • 16,256
  • 15
  • 86
  • 137

1 Answers1

1
Values class extends MainActivity so no need to create interface.You can call any method of MainActivty directly just using method name.Even you can override any method of MainActivty in your Values class.

public class MainActivity extends Activity 
{
public String caption="";

//Method 1           
public void setCaption(String caption)
{
this.caption=caption
}
//Method 2           
public String getCaption()
{
return caption;
}

}

public class Values extends MainActivity 
{
setCaption("Test Application");
Toast.makeText(getApplicationContext(),getCaption(),Toast.LENGTH_SHORT).show();
}
Brijesh Patel
  • 676
  • 1
  • 5
  • 13
  • i update answer please check it out.. if you still need help,reply me, i like to clear your doubts. – Brijesh Patel Sep 23 '13 at 13:12
  • and if I want to do all the getters and setters in the values and the starters on the mainactivity??? –  Sep 23 '13 at 14:06