當前位置: 首頁>>代碼示例>>Java>>正文


Java Button.setTextColor方法代碼示例

本文整理匯總了Java中android.widget.Button.setTextColor方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.setTextColor方法的具體用法?Java Button.setTextColor怎麽用?Java Button.setTextColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.Button的用法示例。


在下文中一共展示了Button.setTextColor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getButton

import android.widget.Button; //導入方法依賴的package包/類
private Button getButton(String text, int position) {

        // 動態生成選擇按鈕
        final Button button = new Button(mContext);
        button.setText(text);
        button.setTag(position);
        button.setTextColor(mBuilder.getItemTextColor());
        button.setTextSize(mBuilder.getItemTextSize());
        button.setLayoutParams(new LinearLayout.LayoutParams(AbsListView.LayoutParams
                .MATCH_PARENT, mBuilder.getItemHeight()));
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {

                if (mBuilder.getOnItemListener() != null) {

                    selectPosition = Integer.parseInt(button.getTag().toString());
                    mBuilder.getOnItemListener().onItemClick(button, selectPosition);

                }
            }
        });

        return button;
    }
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:27,代碼來源:NormalSelectionDialog.java

示例2: setMdBtnStytle

import android.widget.Button; //導入方法依賴的package包/類
/**
 * 設置MD風格樣式
 */
public static void setMdBtnStytle(BuildBean bean) {
    Button btnPositive =
            bean.alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
    Button btnNegative =
            bean.alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    Button btnNatural =
            bean.alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
    if (btnPositive != null && btnNegative != null) {
        btnPositive.setTextSize(bean.btnTxtSize);
        btnNegative.setTextSize(bean.btnTxtSize);
        btnNatural.setTextSize(bean.btnTxtSize);
        if (bean.btn1Color != 0)
            btnPositive.setTextColor(getColor(null, bean.btn1Color));
        if (bean.btn2Color != 0)
            btnNegative.setTextColor(getColor(null, bean.btn2Color));
        if (bean.btn3Color != 0)
            btnNatural.setTextColor(getColor(null, bean.btn3Color));
    }
    Window window = bean.alertDialog.getWindow();
    window.setGravity(bean.gravity);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:25,代碼來源:ToolUtils.java

示例3: getEditTextDialog

import android.widget.Button; //導入方法依賴的package包/類
public AlertDialog getEditTextDialog(Context context, String title, final OnClickOkBtnListener mOnClickOkBtnListener) {
    this.mContext = context;
    et = (EditText) LayoutInflater.from(context).inflate(R.layout.layout_edittext, null);
    et.setSingleLine(true);
    AlertDialog mAlertDialog = new AlertDialog.Builder(mContext).setTitle(title)
            .setView(et)
            .setPositiveButton(mContext.getString(R.string.ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    String input = et.getText().toString();
                    if (null != mOnClickOkBtnListener) {
                        mOnClickOkBtnListener.onClickOk(input);
                    }

                }
            })
            .setNegativeButton(mContext.getString(R.string.cancel), null).show();
    Button btn1 = mAlertDialog.getButton(mAlertDialog.BUTTON_POSITIVE);
    btn1.setTextColor(context.getResources().getColor(R.color.colorPrimary));
    Button btn2 = mAlertDialog.getButton(mAlertDialog.BUTTON_NEGATIVE);
    btn2.setTextColor(context.getResources().getColor(R.color.colorPrimary));
    return mAlertDialog;
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:23,代碼來源:DialogUtils.java

示例4: setNegativeButton

import android.widget.Button; //導入方法依賴的package包/類
/**
        * set negative button
        *
        * @param text the name of button
        */
       public void setNegativeButton(String text, final View.OnClickListener listener)
{
           Button button = new Button(mContext);
           LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
	LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
           button.setLayoutParams(params);
           button.setBackgroundResource(R.drawable.material_card);
           button.setText(text);
           button.setTextColor(Color.argb(222, 0, 0, 0));
           button.setTextSize(14);
           button.setGravity(Gravity.CENTER);
           button.setPadding(0, 0, 0, dip2px(8));
           button.setOnClickListener(listener);
           if (mButtonLayout.getChildCount() > 0)
    {
               params.setMargins(20, 0, 10, dip2px(BUTTON_BOTTOM));
               button.setLayoutParams(params);
               mButtonLayout.addView(button, 1);
           }
    else
    {
               button.setLayoutParams(params);
               mButtonLayout.addView(button);
           }
       }
 
開發者ID:stytooldex,項目名稱:pius1,代碼行數:31,代碼來源:MaterialDialog.java

示例5: setButtonState

import android.widget.Button; //導入方法依賴的package包/類
public void setButtonState(Button button, boolean state)
{
    /* 팔로우 중인 유저인 경우 */
    if (state)
    {
        button.setText("팔로우 중");
        button.setBackgroundResource(R.drawable.view_follow_enable);
        button.setTextColor(context.getResources().getColor(android.R.color.white));
    }
    else
    {
        button.setText("팔로잉");
        button.setBackgroundResource(R.drawable.view_follow_disable);
        button.setTextColor(context.getResources().getColor(android.R.color.black));
    }
}
 
開發者ID:icaynia,項目名稱:pracler,代碼行數:17,代碼來源:FindUserAdapter.java

示例6: beautyButtonGray

import android.widget.Button; //導入方法依賴的package包/類
protected void beautyButtonGray(Button mButton, String str, OnClickListener mOnClickListener) {
    mButton.setText(str);
    mButton.setTextSize(16.0f);
    mButton.setOnClickListener(mOnClickListener);
    SDKUtils.setBackground(mButton, this.crMgmt.getStatusDrawable("common_btn_gray_pressed", "common_btn_gray_normal", true));
    mButton.setTextColor(this.crMgmt.createSelector("#868b8f", "#000000"));
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:8,代碼來源:BasicActivity.java

示例7: initView

import android.widget.Button; //導入方法依賴的package包/類
private void initView() {
    sobot_btn_take_photo = (Button) findViewById(ResourceUtils.getIdByName(getContext(), "id",
            "sobot_btn_take_photo"));
    sobot_btn_cancel = (Button) findViewById(ResourceUtils.getIdByName(getContext(), "id",
            "sobot_btn_cancel"));
    sobot_pop_layout = (LinearLayout) findViewById(ResourceUtils.getIdByName(getContext(), "id",
            "sobot_pop_layout"));
    sobot_btn_take_photo.setText(ResourceUtils.getIdByName(getContext(),"string","sobot_clear_history_message"));
    sobot_btn_take_photo.setTextColor(getContext().getResources()
            .getColor(ResourceUtils.getIdByName(getContext(), "color",
                    "sobot_text_delete_hismsg_color")));
    sobot_btn_take_photo.setOnClickListener(this);
    sobot_btn_cancel.setOnClickListener(this);
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:15,代碼來源:ClearHistoryDialog.java

示例8: viewForEmptyDataSet

import android.widget.Button; //導入方法依賴的package包/類
@Override
    public Button viewForEmptyDataSet(RelativeLayout layout,PHEmptyDataSet.TapNoDataType type) {
        Button btn = new Button(this);

        btn.setLayoutParams(new ViewGroup.LayoutParams(200,200));
//        Bitmap bitmap = BitmapFactory.decodeResource(res,R.drawable.m123);
        Drawable draw = new BitmapDrawable(getResources(),BitmapFactory.decodeResource(getResources(),R.drawable.m123));
        btn.setBackground(draw);
        btn.setText("goog");
        btn.setTextColor(Color.RED);
        btn.setTextSize((float)8.0);
        return btn;
    }
 
開發者ID:HeterPu,項目名稱:PHEmptyDataSetForAndroid,代碼行數:14,代碼來源:MainActivity.java

示例9: showTimeDifference

import android.widget.Button; //導入方法依賴的package包/類
private static void showTimeDifference(Button delayView, Integer timeDifference, Context context) {
    apply(delayView, VISIBLE);
    delayView.setText(timeDifference + "'");
    if (timeDifference > 0) {
        delayView.setTextColor(getTimeDifferenceColor(context, ViewsUtils.COLORS.RED));
    } else {
        delayView.setTextColor(getTimeDifferenceColor(context, ViewsUtils.COLORS.GREEN));
    }
}
 
開發者ID:albertogiunta,項目名稱:justintrain-client-android,代碼行數:10,代碼來源:FavouriteSolutionsItem.java

示例10: initView

import android.widget.Button; //導入方法依賴的package包/類
protected void initView(Context context) {
    mContext = context;
    LayoutInflater.from(mContext).inflate(R.layout.card_share, this);
    shareTV = (TextView) findViewById(R.id.share_msg);
    cancelBtn = (Button) findViewById(R.id.share_cancel);
    confirmBtn = (Button) findViewById(R.id.share_confirm);
    cancelBtn.setOnClickListener(myOnClickListener);
    confirmBtn.setOnClickListener(myOnClickListener);
    cancelBtn.setTextColor(getResources().getColor(R.color.text_color_import));
    refreshText();

}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:13,代碼來源:IntroCard.java

示例11: refreshWordSelector

import android.widget.Button; //導入方法依賴的package包/類
public void refreshWordSelector()	{
LinkedList<String> listMatched = minputMethodCaller.matchFuncVars(mstrBuffered);
	mwordSelectionContainer.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, mnInputBtnHeight));		
mlLayoutWordSelectionBtnHolder.removeAllViews();
for (int idx = 0 ; idx < listMatched.size(); idx ++)	{
	String str = listMatched.get(idx);
	Button btn = new Button(getContext());
	btn.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, mnInputBtnHeight));
	btn.setTag(str);
	btn.setText(str);
	btn.setTextSize(TypedValue.COMPLEX_UNIT_PX, mfTextSize);
	int nTextColor = Color.RED;
	if (idx > 0)	{
		nTextColor = Color.GREEN;
	}
	btn.setTextColor(nTextColor);
	btn.setBackgroundResource(R.drawable.btn_background);
	btn.setOnClickListener(new OnClickListener()	{

		@Override
		public void onClick(View v) {
			minputMethodCaller.onClickSelectedWord((String)v.getTag());
		}
		
	});
	mlLayoutWordSelectionBtnHolder.addView(btn);
}	
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:29,代碼來源:AMInputMethod.java

示例12: getButton

import android.widget.Button; //導入方法依賴的package包/類
private Button getButton(String text, int position) {

        // 動態生成選擇按鈕
        final Button button = new Button(mContext);
        button.setText(text);
        button.setTag(position);
        button.setTextColor(mBuilder.getItemTextColor());
        button.setTextSize(mBuilder.getItemTextSize());
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams
                .MATCH_PARENT, mBuilder.getItemHeight());
        button.setLayoutParams(lp);
        button.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
        button.setPadding(UiUtils.dp2px(mContext,10),0,UiUtils.dp2px(mContext,10),0);
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {

                if (mBuilder.getOnItemListener() != null) {

                    selectPosition = Integer.parseInt(button.getTag().toString());
                    mBuilder.getOnItemListener().onItemClick(button, selectPosition);

                }
            }
        });

        return button;
    }
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:30,代碼來源:MDSelectionDialog.java

示例13: generateTopBarTextButton

import android.widget.Button; //導入方法依賴的package包/類
/**
 * 生成一個文本按鈕,並設置文字
 *
 * @param text 按鈕的文字
 * @return 返回生成的按鈕
 */
private Button generateTopBarTextButton(String text) {
    Button button = new Button(getContext());
    button.setBackgroundResource(0);
    button.setMinWidth(0);
    button.setMinHeight(0);
    button.setMinimumWidth(0);
    button.setMinimumHeight(0);
    button.setPadding(mTopBarTextBtnPaddingHor, 0, mTopBarTextBtnPaddingHor, 0);
    button.setTextColor(mTopBarTextBtnTextColor);
    button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTopBarTextBtnTextSize);
    button.setGravity(Gravity.CENTER);
    button.setText(text);
    return button;
}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:21,代碼來源:QMUITopBar.java

示例14: setupMyRequests

import android.widget.Button; //導入方法依賴的package包/類
private void setupMyRequests() {
    Button btn1 = getDialog().findViewById(R.id.btn_1);
    Button btn2 = getDialog().findViewById(R.id.btn_2);
    Button btn3 = getDialog().findViewById(R.id.btn_3);

    if (mGoalCompleteResult != Goal.GoalCompleteResult.Pending) {
        btn1.setText(getString(R.string.fail));
        btn1.setTextColor(ContextCompat.getColor(getContext(), R.color.red));
        btn1.setTag(Goal.GoalCompleteResult.Failed);
        btn1.setOnClickListener(updateAction);

        btn2.setVisibility(View.VISIBLE);
        btn2.setText(getString(R.string.pass));
        btn2.setTextColor(ContextCompat.getColor(getContext(), R.color.green));
        btn2.setTag(Goal.GoalCompleteResult.Success);
        btn2.setOnClickListener(updateAction);

        btn3.setVisibility(View.VISIBLE);
        btn3.setText(getString(R.string.remind_friend));
        btn3.setTextColor(ContextCompat.getColor(getContext(), R.color.colorAccent));
        btn3.setOnClickListener(remindAction);
    } else {
        btn1.setText(getString(R.string.accept));
        btn1.setTextColor(ContextCompat.getColor(getContext(), R.color.green));
        btn1.setTag(Goal.GoalCompleteResult.Ongoing);
        btn1.setOnClickListener(updateAction);

        btn2.setVisibility(View.GONE); //No decline for now until server adds implemention
        btn3.setVisibility(View.GONE);
    }
}
 
開發者ID:Q115,項目名稱:Goalie_Android,代碼行數:32,代碼來源:GoalsDetailedDialog.java

示例15: themeButton

import android.widget.Button; //導入方法依賴的package包/類
public void themeButton(Button btn){
       if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
		btn.setTextColor(getTextColor());
		btn.setBackgroundColor(getButtonBackgroundColor());
	}
}
 
開發者ID:HoraApps,項目名稱:Liz,代碼行數:7,代碼來源:ThemeHelper.java


注:本文中的android.widget.Button.setTextColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。