本文整理汇总了Java中android.support.design.widget.Snackbar.make方法的典型用法代码示例。如果您正苦于以下问题:Java Snackbar.make方法的具体用法?Java Snackbar.make怎么用?Java Snackbar.make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.Snackbar
的用法示例。
在下文中一共展示了Snackbar.make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showSnackbar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static Snackbar showSnackbar(View view, @StringRes int message,
@StringRes int actionLabel,
View.OnClickListener clickListener) {
Snackbar snackbar = Snackbar.make(view, message, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(actionLabel, clickListener);
snackbar.show();
return snackbar;
}
示例2: initSnackbarDatum
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void initSnackbarDatum() {
snackbarDate = Snackbar.make(findViewById(R.id.snack), getContext().getString(R.string.snackbar_date_invalid), Snackbar.LENGTH_LONG);
snackbarDate.setActionTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
snackbarDate.setAction(getContext().getString(R.string.dismiss), new View.OnClickListener() {
@Override
public void onClick(View v) {
snackbarDate.dismiss();
}
});
}
示例3: getPermissionDeniedSnackbar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static Snackbar getPermissionDeniedSnackbar(final View rootView) {
Snackbar snackbar = Snackbar.make(rootView,
R.string.read_permission_denied,
Snackbar.LENGTH_INDEFINITE);
snackbar.getView().setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
Toast.makeText(rootView.getContext(), R.string.read_permission_denied, Toast.LENGTH_SHORT).show();
return false;
}
});
return snackbar;
}
示例4: EnforceRefresh
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void EnforceRefresh() {
Snackbar snackbar = Snackbar.make(findViewById(R.id.MainContent), R.string.EnforceRef, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.Refresh, new View.OnClickListener() {
@Override
public void onClick(View view) {
((GlobalValues) getApplication()).matrixAdapter.notifyDataSetChanged();
}
});
snackbar.show();
}
示例5: createLoadingCompleteSnackbar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* 创建 加载完成... Snackbar
*
* @param view ViewGroup 子类
*/
public void createLoadingCompleteSnackbar(ViewGroup view) {
Snackbar snackbar = Snackbar.make(view, "加载完成...", Snackbar.LENGTH_SHORT);
Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) snackbar.getView();
snackBarLayout.setBackgroundColor(getColors(R.color.decoView_line1_start_color));
snackBarLayout.setAlpha(0.9f);
snackbar.show();
}
示例6: onProgress
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void onProgress(int current) {
if (getActivity() != null) {
snackbar = Snackbar.make(getActivity().findViewById(R.id.fab), R.string.frag_station_conn_info_loading, Snackbar.LENGTH_INDEFINITE);
snackbar.show();
}
}
示例7: showSnackbar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static void showSnackbar(View container, @NonNull SnackbarType snackbarType,
@StringRes int textStringRes, @Nullable SnackbarDuration duration,
@Nullable BaseTransientBottomBar.BaseCallback<Snackbar> callback) {
duration = (duration == null ? SnackbarDuration.LONG : duration);
Snackbar snackbar = Snackbar.make(container, textStringRes, duration.getDuration());
snackbar.getView().setBackgroundResource(snackbarType.getColorRes());
TextView snackbarText = (TextView) snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
snackbarText.setCompoundDrawablesWithIntrinsicBounds(0, 0,snackbarType.getIconRes(), 0);
snackbarText.setGravity(Gravity.CENTER);
if(callback != null)
snackbar.addCallback(callback);
snackbar.show();
}
示例8: showSnackBar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void showSnackBar(String message) {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content),
message, Snackbar.LENGTH_SHORT);
View sbView = snackbar.getView();
TextView textView = (TextView) sbView
.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(ContextCompat.getColor(this, R.color.white));
snackbar.show();
}
示例9: displaySnackBar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
* function to display snackbar in app screen
* Used during no network connection
*/
private void displaySnackBar(){
Snackbar snackbar = Snackbar.make(findViewById(R.id.activity_main),
getString(R.string.no_network), Snackbar.LENGTH_SHORT);
snackbar.setAction(R.string.setting_text, new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
startActivity(intent);
}
});
snackbar.show();
}
示例10: onActivityResult
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
protected void onActivityResult(int request, int result, Intent data) {
super.onActivityResult(request, result, data);
if (request == REQUEST_INTRODUCTION && result == RESULT_OK) {
Snackbar snackbar = Snackbar.make(list, R.string.introduction_sent,
Snackbar.LENGTH_SHORT);
snackbar.getView().setBackgroundResource(R.color.briar_primary);
snackbar.show();
}
}
示例11: onSharedPreferenceChanged
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key == getString(R.string.pref_master_is_local_key) ||
key == getString(R.string.pref_master_uri_key)) {
if (settingsWereAppliedThisSession() && mSettingsPreferenceFragment.getView() != null) {
Snackbar snackbar = Snackbar.make(mSettingsPreferenceFragment.getView(),
getString(R.string.snackbar_text_restart), Snackbar.LENGTH_INDEFINITE);
View snackBarView = snackbar.getView();
snackBarView.setBackgroundColor(getResources().getColor(android.R.color.holo_orange_dark));
snackbar.show();
}
}
}
示例12: showSnackbar3
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void showSnackbar3() {
final Snackbar cS = Snackbar.make(Utils.getController().getProfileActivity().getCoordinatorLayout(), R.string.error, Snackbar.LENGTH_LONG);
cS.setActionTextColor(Color.WHITE);
cS.setAction(Utils.getString(R.string.snackbar_no_connection_button), new View.OnClickListener() {
@Override
public void onClick(View v) {
cS.dismiss();
}
});
cS.show();
}
示例13: showRetrySnackBar
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static void showRetrySnackBar(Activity activity, String text, View.OnClickListener listener){
Snackbar snackbar = Snackbar.make(activity.findViewById(R.id.content_view), text, Snackbar.LENGTH_INDEFINITE);
if (null != listener) {
snackbar.setAction("RETRY", listener)
.setActionTextColor(SettingsActivity.getPrimaryColor(activity));
}
snackbar.show();
}
示例14: showPermissionMessage
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void showPermissionMessage(int resId) {
final Snackbar snackbar = Snackbar.make(rlRoot, resId, Snackbar.LENGTH_INDEFINITE);
snackbar.setAction(R.string.button_settings, new View.OnClickListener() {
@Override
public void onClick(View v) {
presenter.showAppSystemSettings();
snackbar.dismiss();
}
});
snackbar.show();
}
示例15: requestLocationServices
import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void requestLocationServices() {
Snackbar snackbar = Snackbar.make(
coordinatorLayout,
R.string.error_location_disabled,
Snackbar.LENGTH_INDEFINITE
);
snackbar.setAction(R.string.action_enable, new View.OnClickListener() {
@Override
public void onClick(View view) {
AndroidLocationProvider.requestLocationEnabling(HomeActivity.this);
}
});
snackbar.show();
}