Skip to content

Instantly share code, notes, and snippets.

@isfaaghyth
Created September 26, 2018 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isfaaghyth/4c41dfa1954593ba2e7fabbabd875268 to your computer and use it in GitHub Desktop.
Save isfaaghyth/4c41dfa1954593ba2e7fabbabd875268 to your computer and use it in GitHub Desktop.
1. buat layout untuk notif error (contoh: error.xml):
<LinearLayout
android:id="@+id/layoutError"
...>
<TextView
...
android:id="@+id/txtErr"
android:text="error!"/>
</LinearLayout>
2. include kedalam activity_main, misal:
<RelativeLayout
...>
<include layout="@layout/error"/>
</RelativeLayout>
3. pada baseActivity, lakukan seperti ini,
class BaseActivity {
protected void onError(String message) {
if (layoutError == null) return;
layoutError.setVisibility(View.VISIBLE);
txtErr.setText(message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment