@SuppressWarnings("unchecked")
public <T extends Fragment> T getFragment(int id) {
T result = (T)getFragmentManager().findFragmentById(id);
if (result == null) {
throw new IllegalArgumentException("fragment 0x" + Integer.toHexString(id)
+ " doesn't exist");
}
return result;
}
/**
* Convenient version of {@link #findViewById(int)}, which throws
* an exception if the view doesn't exist.
*/
@SuppressWarnings("unchecked")
public <T extends View> T getView(int id) {
T result = (T)findViewById(id);
if (result == null) {
throw new IllegalArgumentException("view 0x" + Integer.toHexString(id)
+ " doesn't exist");
}
return result;
}