Guest User

Untitled

a guest
Jul 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. public class BaseActivity extends AppCompatActivity {
  2.  
  3. public static CoordinatorLayout coordinatorLayout;
  4.  
  5. @Override
  6. protected void onCreate(Bundle savedInstanceState) {
  7. super.onCreate(savedInstanceState);
  8. setContentView(R.layout.activity_base);
  9. coordinatorLayout = (CoordinatorLayout) findViewById(R.id
  10. .coordinatorLayout1);
  11. }
  12. }
  13.  
  14. <?xml version="1.0" encoding="utf-8"?>
  15.  
  16. <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
  17. xmlns:tools="http://schemas.android.com/tools"
  18. android:id="@+id/coordinatorLayout1"
  19. android:layout_width="match_parent"
  20. android:layout_height="match_parent"
  21. android:fitsSystemWindows="true"
  22. tools:context="com.example.Activity.BaseActivity">
  23. </android.support.design.widget.CoordinatorLayout>
  24.  
  25. Snackbar snackbar = Snackbar.make(
  26. BaseActivity.coordinatorLayout,
  27. "Helooo....",
  28. Snackbar.LENGTH_LONG
  29. );
  30.  
  31. public void showSnackBar(Activity activity, String message){
  32. View rootView = activity.getWindow().getDecorView().findViewById(android.R.id.content);
  33. Snackbar.make(rootView, message, duration).show();
  34. }
  35.  
  36. private static final String message = "No Internet Connection";
  37.  
  38. public static void message(Activity activity) {
  39. View rootView = activity.getWindow().getDecorView().findViewById(android.R.id.content);
  40. Snackbar.make(rootView, message, Snackbar.LENGTH_LONG).show();
  41. }
Add Comment
Please, Sign In to add comment