Skip to content

Instantly share code, notes, and snippets.

@exallium
Last active August 29, 2015 14:25
Show Gist options
  • Save exallium/0afaea77e95adca44ae1 to your computer and use it in GitHub Desktop.
Save exallium/0afaea77e95adca44ae1 to your computer and use it in GitHub Desktop.
flat
/* within adapter class */
private static class ItemDeletate<T> {
private final T item;
private boolean isViewed;
public ItemDelegate(T item) {
this.item = item;
}
}
public class MyFragment extends Fragment {
private MyInterface myInterface = null;
public interface MyInterface {
void function1();
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
myInterface = (MyInterface) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement MyFragment.MyInterface");
}
}
@Override
public void onActivityCreated(/* ... */) {
myInterface.function1();
}
}
/* ... */
public class MyActivity extends Activity implements MyFragment.MyInterface {
@Override
public void function1() {
/* ... */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment