When we implements an interface in a class, its abstract methods are implemented in the class.Lets see the example.
First we created an interface ApplicationInterface
ApplicationInterface .java
public interface ApplicationInterface {
public void activityStarted();
public void activityAborted();
public void activityStopped();
public void activityDone();
}
public class MainActivity extends Activity implements ApplicationInterface {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
// these are the methods implemented using interface
@Override
public void activityStarted() {
// TODO Auto-generated method stub
}
@Override
public void activityAborted() {
// TODO Auto-generated method stub
}
@Override
public void activityStopped() {
// TODO Auto-generated method stub
}
@Override
public void activityDone() {
// TODO Auto-generated method stub
}
}
Comments
Post a Comment