當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。