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


Java Snackbar.setActionTextColor方法代码示例

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


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

示例1: onPostExecute

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Boolean b) {
    if (b) {
        dismiss();
        Toast.makeText(Utils.getContext(), "Umfrage erfolgreich erstellt", Toast.LENGTH_LONG).show();
    } else {
        final Snackbar snackbar = Snackbar.make(findViewById(R.id.wrapper), "Es ist etwas schiefgelaufen, versuche es später erneut", Snackbar.LENGTH_SHORT);
        snackbar.setActionTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
        snackbar.setAction(getContext().getString(R.string.dismiss), new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                snackbar.dismiss();
            }
        });
        snackbar.show();
    }
}
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:18,代码来源:NewSurveyDialog.java

示例2: onSwiped

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
    int position = viewHolder.getAdapterPosition();
    final Savegame savegame = savegameAdapter.get(position);
    savegameAdapter.removeItem(position);
    String deleteText = App.getContext().getString(R.string.savegame_deleted);
    String gameTitle = Games.getFromUuid(savegame.gameUuid).getGameTitle();
    String snackbarText = String.format("%s: %s - %s", deleteText, gameTitle, savegame.getDateString());
    Snackbar snackbar = Snackbar.make(coordinatorLayout, snackbarText, Snackbar.LENGTH_LONG);
    snackbar.setAction(R.string.undo, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            savegameAdapter.addItem(savegame);
        }
    });
    snackbar.setActionTextColor(AndroidResources.getColor(R.color.snackbarActionColor));
    snackbar.show();
}
 
开发者ID:android-gamecollection,项目名称:gamecollection,代码行数:19,代码来源:Hub.java

示例3: show

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
 * 设置snackbar文字和背景颜色
 *
 * @param parent          父视图(CoordinatorLayout或者DecorView)
 * @param text            文本
 * @param duration        显示时长
 * @param textColor       文本颜色
 * @param bgColor         背景色
 * @param actionText      事件文本
 * @param actionTextColor 事件文本颜色
 * @param listener        监听器
 */
private 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:hoangkien0705,项目名称:Android-UtilCode,代码行数:34,代码来源:SnackbarUtils.java

示例4: onPostExecute

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Boolean b) {
    if (b) {
        dismiss();
        Toast.makeText(Utils.getContext(), "Gesendet", Toast.LENGTH_SHORT).show();
    } else {
        final Snackbar snack = Snackbar.make(findViewById(R.id.dialog_entry), Utils.getString(R.string.snackbar_no_connection_info), Snackbar.LENGTH_LONG);
        snack.setActionTextColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
        snack.setAction(getContext().getString(R.string.dismiss), new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                snack.dismiss();
            }
        });
        snack.show();
    }
}
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:18,代码来源:NewEntryDialog.java

示例5: 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

示例6: showSnackBar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void showSnackBar(int stringRes) {
	int firstVisible =
			layoutManager.findFirstCompletelyVisibleItemPosition();
	int lastVisible = layoutManager.findLastCompletelyVisibleItemPosition();
	int count = adapter.getItemCount();
	boolean scroll = count > (lastVisible - firstVisible + 1);

	Snackbar s = Snackbar.make(list, stringRes, LENGTH_LONG);
	s.getView().setBackgroundResource(R.color.briar_primary);
	if (scroll) {
		OnClickListener onClick = new OnClickListener() {
			@Override
			public void onClick(View v) {
				list.smoothScrollToPosition(0);
			}
		};
		s.setActionTextColor(ContextCompat
				.getColor(getContext(),
						R.color.briar_button_positive));
		s.setAction(R.string.blogs_blog_post_scroll_to, onClick);
	}
	s.show();
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:24,代码来源:FeedFragment.java

示例7: 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

示例8: onBackPressed

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
    Snackbar snackbar = Snackbar.make(findViewById(R.id.guess_layout_content), R.string.guess_no_click_back, Snackbar.LENGTH_SHORT);
    snackbar.setActionTextColor(Color.RED);
    snackbar.setAction(R.string.exit_game, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            MainActivity.Instance.finish();
            finish();
        }
    });
    snackbar.show();
}
 
开发者ID:XFY9326,项目名称:CatchSpy,代码行数:14,代码来源:GuessActivity.java

示例9: showSnackBar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void showSnackBar(String text) {
    Snackbar snackbar = Snackbar.make(buttonContainer,
            text,
            Snackbar.LENGTH_INDEFINITE);
    View snackbarView = snackbar.getView();
    snackbarView.setBackgroundColor(ContextCompat.getColor(this, R.color.snackbar_color));
    snackbar.setActionTextColor(ContextCompat.getColor(this, R.color.white));
    TextView textView = snackbarView.findViewById(android.support.design.R.id.snackbar_text);
    textView.setMaxLines(10);
    snackbar.setAction(getString(R.string.dismiss), view1 -> snackbar.dismiss());
    snackbar.show();
}
 
开发者ID:BANKEX,项目名称:smart-asset-iot-android-demo,代码行数:13,代码来源:MainActivity.java

示例10: 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

示例11: show

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
 * 显示SnackBar
 */
public void show() {
    final View view = parent.get();
    if (view == null) return;
    if (messageColor != DEFAULT_COLOR) {
        SpannableString spannableString = new SpannableString(message);
        ForegroundColorSpan colorSpan = new ForegroundColorSpan(messageColor);
        spannableString.setSpan(colorSpan, 0, spannableString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        mWeakReference = new WeakReference<>(Snackbar.make(view, spannableString, duration));
    } else {
        mWeakReference = new WeakReference<>(Snackbar.make(view, message, duration));
    }
    final Snackbar snackbar = mWeakReference.get();
    final View snackView = snackbar.getView();
    if (bgResource != -1) {
        snackView.setBackgroundResource(bgResource);
    } else if (bgColor != DEFAULT_COLOR) {
        snackView.setBackgroundColor(bgColor);
    }
    if (bottomMargin != 0) {
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) snackView.getLayoutParams();
        params.bottomMargin = bottomMargin;
    }
    if (actionText.length() > 0 && actionListener != null) {
        if (actionTextColor != DEFAULT_COLOR) {
            snackbar.setActionTextColor(actionTextColor);
        }
        snackbar.setAction(actionText, actionListener);
    }
    snackbar.show();
}
 
开发者ID:AriesHoo,项目名称:FastLib,代码行数:34,代码来源:SnackBarUtil.java

示例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();
}
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:12,代码来源:UpdateNameTask.java

示例13: onListAdapterInteractionListener

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
@Override
public void onListAdapterInteractionListener(final String eventName, final String data2,
                                             final String data3) {
    if (eventName.equals ("populate") && !eventName.equals ("delete")) {
        listDataSetChanged ();
    }
    if (eventName.equals ("delete")) {
        listDataSetChanged ();
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) getActivity ()
                .findViewById (R.id.coordinatorLayout);
        View.OnClickListener mOnClickListener = new View.OnClickListener () {
            @Override
            public void onClick(View v) {
                NoteUtil noteUtil = new NoteUtil (getActivity ());
                try {
                    JSONObject jsonObjectNote = new JSONObject (data3);
                    Boolean bool = noteUtil.addNoteAtPosition (Long.valueOf (data2),
                            jsonObjectNote, Integer.valueOf (mSectionIndex) + 1);
                    if (DEBUG)
                        Toast.makeText (getActivity (), "Note Added " + bool, Toast.LENGTH_SHORT).show ();
                    populateListViewInBackground ();
                } catch (JSONException e) {
                    e.printStackTrace ();
                    Toast.makeText (getActivity (), R.string.undo_failed_err_str, Toast.LENGTH_SHORT).show ();
                }
            }
        };
        Snackbar snackbar = Snackbar
                .make (coordinatorLayout, R.string.oops_made_a_mistake_str, Snackbar.LENGTH_LONG)
                .setAction (R.string.undo_str, mOnClickListener);
        snackbar.setActionTextColor (Color.RED);
        View snackView = snackbar.getView ();
        snackView.setBackgroundColor (Color.DKGRAY);
        snackbar.show ();
    }
}
 
开发者ID:atulgpt,项目名称:TimeTrix,代码行数:37,代码来源:FragmentStarredNotes.java

示例14: showSnackbar2

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void showSnackbar2() {
    final Snackbar cS = Snackbar.make(Utils.getController().getProfileActivity().getCoordinatorLayout(), R.string.settings_snackbar_username_taken, 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();
}
 
开发者ID:LCA311,项目名称:leoapp-sources,代码行数:12,代码来源:UpdateNameTask.java

示例15: showSnackBar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
private void showSnackBar(String msg) {
    CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.profile_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,代码来源:ProfileActivity.java


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