当前位置: 首页>>代码示例>>Java>>正文


Java Snackbar.getView方法代码示例

本文整理汇总了Java中android.support.design.widget.Snackbar.getView方法的典型用法代码示例。如果您正苦于以下问题:Java Snackbar.getView方法的具体用法?Java Snackbar.getView怎么用?Java Snackbar.getView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.Snackbar的用法示例。


在下文中一共展示了Snackbar.getView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: show

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static void show(View parent,
                        CharSequence text,
                        int duration,
                        @ColorInt int textColor,
                        @ColorInt int bgColor,
                        CharSequence actionText,
                        @ColorInt int actionTextColor,
                        View.OnClickListener listener) {
    SpannableString spannableString = new SpannableString(text);
    ForegroundColorSpan colorSpan = new ForegroundColorSpan(textColor);
    spannableString.setSpan(colorSpan, 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    snackbarWeakReference = new WeakReference<>(Snackbar.make(parent, spannableString, duration));
    Snackbar snackbar = snackbarWeakReference.get();
    View view = snackbar.getView();
    view.setBackgroundColor(bgColor);
    if (actionText != null && actionText.length() > 0 && listener != null) {
        snackbar.setActionTextColor(actionTextColor);
        snackbar.setAction(actionText, listener);
    }
    snackbar.show();

}
 
开发者ID:Justson,项目名称:AgentWebX5,代码行数:23,代码来源:AgentWebX5Utils.java

示例2: reportGpsError

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void reportGpsError() {
    if (mSwitch != null) {
        mSwitch.setChecked(false);
    }
    Snackbar snackbar = Snackbar
            .make(findViewById(R.id.rootView), getString(R.string
                    .gps_required), Snackbar.LENGTH_INDEFINITE)
            .setAction(R.string.enable, new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                }
            });

    // Changing message text color
    snackbar.setActionTextColor(Color.RED);

    // Changing action button text color
    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id
            .snackbar_text);
    textView.setTextColor(Color.YELLOW);
    snackbar.show();

}
 
开发者ID:ayushghd,项目名称:iSPY,代码行数:26,代码来源:TrackerActivity.java

示例3: createRefreshSnackbar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
 * 创建 正在刷新... - 上次刷新时间 Snackbar(用 SharedPreferences 保存上次刷新时间)
 *
 * @param view ViewGroup 子类
 * @param str  记录上次刷新时间的标记:统一用TAG
 */
public void createRefreshSnackbar(ViewGroup view, String str) {
    String currentDate = DateUtil.longDateToStrMDHMS(System.currentTimeMillis());
    SharedPreferences spRefreshDate = getActivity().getSharedPreferences(AppDelegate.SP_REFRESH_DATE, Context.MODE_PRIVATE);
    String lastRefreshDate = spRefreshDate.getString(str, currentDate);
    Snackbar snackbar = Snackbar.make(view, "正在刷新...", Snackbar.LENGTH_SHORT);
    snackbar.setAction("上次刷新时间:" + lastRefreshDate, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // 这个点击事件必须加上不然 snackbar_action 就无法显示
            // snackbar.dismiss();
        }
    });
    TextView snackbar_action = (TextView) snackbar.getView().findViewById(R.id.snackbar_action);
    snackbar_action.setTextSize(11f);
    snackbar.setActionTextColor(getColors(R.color.white));
    Snackbar.SnackbarLayout snackBarLayout = (Snackbar.SnackbarLayout) snackbar.getView();
    snackBarLayout.setBackgroundColor(getColors(R.color.color_theme));
    snackBarLayout.setAlpha(0.9f);
    snackbar.show();
    spRefreshDate.edit().putString(str, currentDate).commit();
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:28,代码来源:BaseFragment.java

示例4: changeSnackbarTextColor

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void changeSnackbarTextColor(final Snackbar snackbar, final int textColorId) {
    final View snackbarView = snackbar.getView();
    final TextView textView = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);
    if (textColorId != 0) {
        textView.setTextColor(ContextCompat.getColor(application, textColorId));
    } else { // This is the snackbar's default text color.
        textView.setTextColor(Color.WHITE);
    }
}
 
开发者ID:ParaskP7,项目名称:sample-code-posts,代码行数:10,代码来源:AppSnackbarActions.java

示例5: 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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:10,代码来源:BaseActivity.java

示例6: createRefreshCompleteSnackbar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
 * 创建 刷新成功...  Snackbar
 *
 * @param view ViewGroup 子类
 */
public void createRefreshCompleteSnackbar(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();
}
 
开发者ID:jpaijh,项目名称:TYT,代码行数:13,代码来源:BaseActivity.java

示例7: addView

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
 * 向Snackbar中添加view
 *
 * @param snackbar
 * @param layoutId
 * @param index    新加布局在Snackbar中的位置
 */
public static void addView(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);
}
 
开发者ID:Horrarndoo,项目名称:YiZhi,代码行数:20,代码来源:SnackbarUtils.java

示例8: showErrorSnackBar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static Snackbar showErrorSnackBar(Context mContext, View rootView, Throwable throwable) {
    String message = mContext.getString(R.string.dialog_general_error_message);
    if (throwable != null) {
        message = throwable.getLocalizedMessage();

    }
    Snackbar snack_error = Snackbar.make(rootView, message, Snackbar.LENGTH_LONG);
    View view = snack_error.getView();
    TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
    tv.setTextColor(ContextCompat.getColor(mContext, R.color.material_red));
    return snack_error;
}
 
开发者ID:derohimat,项目名称:SgPSI,代码行数:13,代码来源:DialogFactory.java

示例9: SnackbarAddView

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
 * 向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);
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:21,代码来源:SnackbarUtil.java

示例10: showSnack

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void showSnack(String message) {
    Snackbar snackbar = Snackbar.make(findViewById(R.id.fab), message, Snackbar.LENGTH_LONG);

    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
    snackbar.setDuration(10*1000);
    snackbar.show();
}
 
开发者ID:lvaccaro,项目名称:BitcoinBlockExplorer,代码行数:9,代码来源:MainActivity.java

示例11: setSnackbarColor

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
 * 设置Snackbar文字和背景颜色
 *
 * @param snackbar
 * @param messageColor
 * @param backgroundColor
 */
public static void setSnackbarColor(Snackbar snackbar, int messageColor, int backgroundColor) {
    View view = snackbar.getView();
    if (view != null) {
        view.setBackgroundColor(backgroundColor);
        ((TextView) view.findViewById(R.id.snackbar_text)).setTextColor(messageColor);
    }
}
 
开发者ID:Horrarndoo,项目名称:YiZhi,代码行数:15,代码来源:SnackbarUtils.java

示例12: onReceive

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
    boolean response1 = intent.getBooleanExtra("response",true);
    if((!response1) && (response1 != response)){
        Snackbar sb = Snackbar.make(findViewById(R.id.view_edit_profile1), "Oops, No data connection?", Snackbar.LENGTH_LONG);
        View v = sb.getView();
        v.setBackgroundColor(ContextCompat.getColor(getApplication(), R.color.colorPrimary));
        sb.show();
        submit_btn.setClickable(false);
    }
    else if(response1 ){
        submit_btn.setClickable(true);
    }
    response = response1;
}
 
开发者ID:Socialate,项目名称:furry-sniffle,代码行数:16,代码来源:ViewEditProfileActivity.java

示例13: displaySnackbarMessage

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void displaySnackbarMessage(int stringResId) {
    Snackbar snackbar = Snackbar.make(getActivity().findViewById(R.id.cl_list_container),
            getString(stringResId),
            Snackbar.LENGTH_LONG);
    View snackbarView = snackbar.getView();
    snackbarView.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
    snackbar.show();
}
 
开发者ID:twisstosin,项目名称:UdacityBakingAndroid,代码行数:10,代码来源:RecipeListFragment.java

示例14: doMySearch

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public boolean doMySearch(String search_string) {

      DatabaseReference mFirebaseDatabaseReference = mFireBaseDatabase.getReference();
      Query query =  mFirebaseDatabaseReference.child("Entertainments").orderByChild("name")
                .startAt(search_string)
                .endAt(search_string+"\uf8ff");

        ValueEventListener valueEventListener = new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
               arr = new ArrayList<>();
                for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
                    arr.add(postSnapshot);
                }
                if(arr.size() == 0){

                    Snackbar sb = Snackbar.make(findViewById(R.id.search_acivity), "No results found", Snackbar.LENGTH_LONG);
                    View v = sb.getView();
                    v.setBackgroundColor(ContextCompat.getColor(getApplication(), R.color.colorPrimary));
                    sb.show();
                }else {
                    dataset = new DataSnapshot[arr.size()];
                    for (int i = 0; i < arr.size(); i++) {
                        dataset[i] = arr.get(i);
                    }
                    mAdapter = new MyAdapter(dataset);
                    mRecyclerView.setAdapter(mAdapter);
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        };

        query.addValueEventListener(valueEventListener);
        return true;
    }
 
开发者ID:Socialate,项目名称:furry-sniffle,代码行数:40,代码来源:SearchableActivity.java

示例15: showSnackBar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void showSnackBar(String msg) {
    CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.user_list_coordinator_layout);
    Snackbar snackbar = Snackbar
            .make(coordinatorLayout, msg, Snackbar.LENGTH_LONG);

    // Changing message text color
    snackbar.setActionTextColor(Color.RED);

    // Changing action button text color
    View sbView = snackbar.getView();
    TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setTextColor(Color.WHITE);
    snackbar.show();
}
 
开发者ID:lethalskillzz,项目名称:Andela-ALC-Challenge,代码行数:15,代码来源:UserListActivity.java


注:本文中的android.support.design.widget.Snackbar.getView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。