Last active
August 29, 2015 14:25
-
-
Save exallium/0afaea77e95adca44ae1 to your computer and use it in GitHub Desktop.
flat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* within adapter class */ | |
private static class ItemDeletate<T> { | |
private final T item; | |
private boolean isViewed; | |
public ItemDelegate(T item) { | |
this.item = item; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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