Code example for View

Methods: setAlphasetVisibility

     * Sets the alpha of a view in a manner that is safe to use before API version 11. 
     * If alpha isn't supported, just make the view invisible if the alpha is so low 
     * that it may as well be. 
    public static void setViewAlpha(View v, float alpha) {
        v.setVisibility((alpha > 0.001) ? View.VISIBLE : View.INVISIBLE);
     * Shows a toast in a circumstance where the context might be null.  This can very 
     * rarely happen when toasts are done from async tasks and the context is finished 
     * before the task completes, resulting in a crash.  This prevents the crash at the  
     * cost of the toast not being shown. 
    public static void safeToast(Context c, int rid, int duration) {
        if (c != null) {
            Toast.makeText(c, rid, duration).show();