use of android.support.design.widget.Snackbar in project smartmodule by carozhu.
the class BaseFragment method showDefaultSnackbar.
public void showDefaultSnackbar(String tips) {
Snackbar mysnackbar = Snackbar.make(getRootView(), tips, Snackbar.LENGTH_SHORT);
View view = mysnackbar.getView();
if (view != null) {
view.setBackgroundColor(ContextCompat.getColor(context, R.color.md_blue_grey_500));
((TextView) view.findViewById(R.id.snackbar_text)).setTextColor(ContextCompat.getColor(context, R.color.white));
}
mysnackbar.show();
}
use of android.support.design.widget.Snackbar in project smartmodule by carozhu.
the class BaseSimpleAppCompatActivity method showDefaultSnackbar.
public void showDefaultSnackbar(String tips) {
Snackbar mysnackbar = Snackbar.make(getRootView(), tips, Snackbar.LENGTH_SHORT);
View view = mysnackbar.getView();
if (view != null) {
view.setBackgroundColor(ContextCompat.getColor(context, R.color.md_blue_grey_500));
((TextView) view.findViewById(R.id.snackbar_text)).setTextColor(ContextCompat.getColor(context, R.color.white));
}
mysnackbar.show();
}
use of android.support.design.widget.Snackbar in project JustAndroid by chinaltz.
the class AbSnackbarUtil method SnackbarAddView.
/**
* 向Snackbar中添加view
*
* @param snackbar
* @param layoutId
* @param index 新加布局在Snackbar中的位置
*/
public static void SnackbarAddView(Snackbar snackbar, int layoutId, int index) {
View snackbarview = snackbar.getView();
Snackbar.SnackbarLayout snackbarLayout = (Snackbar.SnackbarLayout) snackbarview;
View add_view = LayoutInflater.from(snackbarview.getContext()).inflate(layoutId, null);
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
p.gravity = Gravity.CENTER_VERTICAL;
snackbarLayout.addView(add_view, index, p);
}
use of android.support.design.widget.Snackbar in project LiveLessons by douglascraigschmidt.
the class PermissionRequest method showRationale.
/**
* Convenience method that shows an about dialog for this application. It
* has been placed in this ViewUtils class so that it can be easily accessed
* from any activity.
*/
private void showRationale() {
String msg;
// rationales.
if (mRationaleId == R.string.permission_rationale) {
String permissionStrings = "";
for (final String permission : mPermissions) {
permissionStrings += "\n" + permission;
}
msg = mActivity.getString(R.string.permission_rationale) + permissionStrings;
} else {
// App supplied rationale.
msg = mActivity.getString(mRationaleId);
}
if (mLayout != null) {
Snackbar snackbar = Snackbar.make(mLayout, msg, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.permissions_ok_button, new View.OnClickListener() {
@Override
public void onClick(View view) {
/// Submit the request.
ActivityCompat.requestPermissions(mActivity, mPermissions, mRequestCode);
}
});
snackbar.show();
} else {
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mActivity);
// Set dialog title.
alertDialogBuilder.setTitle("Permission Request");
// Set dialog message.
alertDialogBuilder.setMessage(msg);
alertDialogBuilder.setCancelable(true);
alertDialogBuilder.setPositiveButton(R.string.permissions_ok_button, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
/// Submit the request.
ActivityCompat.requestPermissions(mActivity, mPermissions, mRequestCode);
}
});
// Create alert dialog.
final AlertDialog alertDialog = alertDialogBuilder.create();
// Show it.
alertDialog.show();
}
}
Aggregations