List of usage examples for android.widget TextView setBackgroundDrawable
@Deprecated public void setBackgroundDrawable(Drawable background)
From source file:csic.ceab.movelab.beepath.Util.java
/** * Displays a brief message on the phone screen. Taken from Human Mobility * Project code written by Chang Y. Chung and Necati E. Ozgencil. * /*from ww w. j av a 2s.c o m*/ * @param context * Interface to application environment * @param msg * The message to be displayed to the user */ public static void toast(Context context, String msg) { TextView tv = new TextView(context); tv.setText(msg); Drawable bknd = context.getResources().getDrawable(R.drawable.white_border); tv.setBackgroundDrawable(bknd); tv.setPadding(20, 20, 20, 20); tv.setTextSize(20); Toast t = new Toast(context); t.setDuration(Toast.LENGTH_LONG); t.setView(tv); t.show(); }
From source file:com.danielme.muspyforandroid.activities.base.AbstractActivity.java
/** * <b>Call always after dialog.show!!!!!!!!!</b> * /*from w w w .ja v a2s . c o m*/ * @param alertDialog */ public void dialogStyle(AlertDialog alertDialog) { TextView textView = (TextView) alertDialog.findViewById(android.R.id.message); if (textView != null) { textView.setBackgroundDrawable(null); textView.setTextAppearance(this, R.style.muspydialogmessage); } Button button = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); if (button != null) { button.setBackgroundDrawable(getResources().getDrawable(R.drawable.textbuttonselector)); } button = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); if (button != null) { button.setBackgroundDrawable(getResources().getDrawable(R.drawable.textbuttonselector)); } button = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); if (button != null) { button.setBackgroundDrawable(getResources().getDrawable(R.drawable.textbuttonselector)); } }
From source file:de.kodejak.hashr.fragmentHashFromText.java
public void OnButtonCompareClick() { TextView edOutput = (TextView) getView().findViewById(R.id.edOutput); String strOutput = edOutput.getText().toString(); EditText edCompare = (EditText) getView().findViewById(R.id.edCompare); String strCompare = edCompare.getText().toString(); TextView tvMatch = (TextView) getView().findViewById(R.id.tvCompare); if (strOutput.length() < 1 || strCompare.length() < 1) { return;/*w w w . j a va2 s . c o m*/ } if (strOutput.equals(strCompare)) { tvMatch.setText("Match !"); if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { tvMatch.setBackgroundDrawable(getResources().getDrawable(R.drawable.match_ok_bg)); } else { tvMatch.setBackground(getResources().getDrawable(R.drawable.match_ok_bg)); } tvMatch.setTextColor(Color.WHITE); tvMatch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_check, 0, 0, 0); } else { tvMatch.setText("No match !"); if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { tvMatch.setBackgroundDrawable(getResources().getDrawable(R.drawable.match_notok_bg)); } else { tvMatch.setBackground(getResources().getDrawable(R.drawable.match_notok_bg)); } tvMatch.setTextColor(Color.WHITE); tvMatch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_cancel, 0, 0, 0); } tvMatch.setVisibility(View.VISIBLE); }
From source file:de.kodejak.hashr.fragmentHashFromFile.java
public void OnButtonCompareClick() { TextView edOutput = (TextView) getView().findViewById(R.id.edOutput); String strOutput = edOutput.getText().toString(); EditText edCompare = (EditText) getView().findViewById(R.id.edCompare); String strCompare = edCompare.getText().toString(); TextView tvMatch = (TextView) getView().findViewById(R.id.tvCompare); if (strOutput.length() < 1 || strCompare.length() < 1) { return;// w ww. ja v a 2s . co m } if (strOutput.equals(strCompare)) { tvMatch.setText("Match !"); if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { tvMatch.setBackgroundDrawable(getResources().getDrawable(R.drawable.match_ok_bg)); } else { tvMatch.setBackground(getResources().getDrawable(R.drawable.match_ok_bg)); } tvMatch.setTextColor(Color.WHITE); tvMatch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_check, 0, 0, 0); } else { tvMatch.setText("No match !"); if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { tvMatch.setBackgroundDrawable(getResources().getDrawable(R.drawable.match_notok_bg)); } else { tvMatch.setBackground(getResources().getDrawable(R.drawable.match_notok_bg)); } tvMatch.setTextColor(Color.WHITE); tvMatch.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_cancel, 0, 0, 0); } tvMatch.setVisibility(View.VISIBLE); }
From source file:com.pixellostudio.qqdroid.BaseQuote.java
/** Called when the activity is first created. */ @Override//from w w w . j a v a 2 s . c o m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setActionBarContentView(R.layout.show); getActionBar().setTitle(title); getActionBar().addItem(getActionBar().newActionBarItem(NormalActionBarItem.class) .setDrawable(R.drawable.seemore).setContentDescription("List"), R.id.actionbar_seemore); view = (ListView) findViewById(R.id.ListView); view.setOnCreateContextMenuListener(new OnCreateContextMenuListener() { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { menu.add(0, 1, 0, R.string.sharequote); } }); adapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1); adapter2 = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_list_item_1) { @Override public View getView(int position, View convertView, ViewGroup parent) { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(BaseQuote.this); TextView txt = new TextView(this.getContext()); txt.setTextSize(Float.parseFloat(pref.getString("policesize", "20"))); txt.setText(Html.fromHtml(this.getItem(position))); if (pref.getString("design", "blackonwhite").equals("blackonwhite")) { txt.setTextColor(Color.BLACK); txt.setBackgroundColor(Color.WHITE); txt.setBackgroundDrawable( this.getContext().getResources().getDrawable(R.drawable.quote_gradient_white)); } else if (pref.getString("design", "blackonwhite").equals("whiteonblack")) { txt.setTextColor(Color.WHITE); txt.setBackgroundColor(Color.BLACK); txt.setBackgroundDrawable( this.getContext().getResources().getDrawable(R.drawable.quote_gradient_black)); } return txt; } }; String[] liste = (String[]) getLastNonConfigurationInstance(); if (liste != null && liste.length != 0) { for (int i = 0; i < liste.length; i++) { adapter.add(liste[i]); adapter2.add(liste[i]); } this.setTitle(name); } else { new LoadQuotes().execute(); } view.setAdapter(adapter2); }
From source file:com.coolerfall.uiart.PagerSlidingTabStrip.java
@SuppressWarnings("deprecation") private void setBackgroud(TextView tab) { tab.setBackgroundDrawable(createDrawable()); }
From source file:com.mci.firstidol.view.ActionSheet.java
@SuppressWarnings("deprecation") private View createView() { FrameLayout parent = new FrameLayout(getActivity()); parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg = new View(getActivity()); mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); mBg.setBackgroundColor(Color.argb(136, 0, 0, 0)); mBg.setId(ActionSheet.BG_VIEW_ID);// w w w . ja v a 2 s . co m mBg.setOnClickListener(this); mPanel = new LinearLayout(getActivity()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; mPanel.setLayoutParams(params); mPanel.setOrientation(LinearLayout.VERTICAL); TextView titleView = new TextView(getActivity()); titleView.setText(TextUtils.isEmpty(getTitle()) ? "" : getTitle()); titleView.setGravity(Gravity.CENTER); titleView.setTextColor(Color.GRAY); titleView.setBackgroundDrawable(mAttrs.actionSheetTitleBackground); mPanel.addView(titleView); parent.addView(mBg); parent.addView(mPanel); return parent; }
From source file:git.egatuts.nxtremotecontroller.activity.ControllerActivity.java
public View createTabView(Context context, int resId, String text) { View view = LayoutInflater.from(context).inflate(resId, null); TextView title = (TextView) view.findViewById(R.id.tab_title); title.setText(text);//from ww w .j ava 2s.c o m if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { title.setBackground(this.tabDrawableList.getConstantState().newDrawable()); } else { title.setBackgroundDrawable(this.tabDrawableList.getConstantState().newDrawable()); } title.setTextColor(this.tabColorList); return view; }
From source file:org.sufficientlysecure.keychain.ui.BackupCodeFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.backup_code_fragment, container, false); Bundle args = getArguments();//from w w w .j a v a2 s .c o m mBackupCode = args.getString(ARG_BACKUP_CODE); mMasterKeyIds = args.getLongArray(ARG_MASTER_KEY_IDS); mExportSecret = args.getBoolean(ARG_EXPORT_SECRET); mExecuteBackupOperation = args.getBoolean(ARG_EXECUTE_BACKUP_OPERATION, true); mCodeEditText = new EditText[6]; mCodeEditText[0] = (EditText) view.findViewById(R.id.backup_code_1); mCodeEditText[1] = (EditText) view.findViewById(R.id.backup_code_2); mCodeEditText[2] = (EditText) view.findViewById(R.id.backup_code_3); mCodeEditText[3] = (EditText) view.findViewById(R.id.backup_code_4); mCodeEditText[4] = (EditText) view.findViewById(R.id.backup_code_5); mCodeEditText[5] = (EditText) view.findViewById(R.id.backup_code_6); { TextView[] codeDisplayText = new TextView[6]; codeDisplayText[0] = (TextView) view.findViewById(R.id.backup_code_display_1); codeDisplayText[1] = (TextView) view.findViewById(R.id.backup_code_display_2); codeDisplayText[2] = (TextView) view.findViewById(R.id.backup_code_display_3); codeDisplayText[3] = (TextView) view.findViewById(R.id.backup_code_display_4); codeDisplayText[4] = (TextView) view.findViewById(R.id.backup_code_display_5); codeDisplayText[5] = (TextView) view.findViewById(R.id.backup_code_display_6); // set backup code in code TextViews char[] backupCode = mBackupCode.toCharArray(); for (int i = 0; i < codeDisplayText.length; i++) { codeDisplayText[i].setText(backupCode, i * 5, 4); } // set background to null in TextViews - this will retain padding from EditText style! for (TextView textView : codeDisplayText) { // noinspection deprecation, setBackground(Drawable) is API level >=16 textView.setBackgroundDrawable(null); } } setupEditTextFocusNext(mCodeEditText); setupEditTextSuccessListener(mCodeEditText); mStatusAnimator = (ToolableViewAnimator) view.findViewById(R.id.status_animator); mTitleAnimator = (ToolableViewAnimator) view.findViewById(R.id.title_animator); mCodeFieldsAnimator = (ToolableViewAnimator) view.findViewById(R.id.code_animator); View backupInput = view.findViewById(R.id.button_backup_input); backupInput.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { switchState(BackupCodeState.STATE_INPUT, true); } }); view.findViewById(R.id.button_backup_save).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mShareNotSave = false; startBackup(); } }); view.findViewById(R.id.button_backup_share).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mShareNotSave = true; startBackup(); } }); view.findViewById(R.id.button_backup_back).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { FragmentManager fragMan = getFragmentManager(); if (fragMan != null) { fragMan.popBackStack(); } } }); view.findViewById(R.id.button_faq).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showFaq(); } }); return view; }
From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.AmharicKeyboardView.java
private void handleModifiers(List<String> typographyList) { modifiersContainer.removeAllViews(); for (int i = 0; i < typographyList.size(); i++) { String typography = typographyList.get(i); TextView modifierKey = new TextView(getContext()); modifierKey.setText(typography); modifierKey.setTextColor(Color.WHITE); modifierKey.setIncludeFontPadding(false); modifierKey.setTypeface(mCharTypeface, Typeface.BOLD); modifierKey.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); modifierKey.setBackgroundDrawable( ContextCompat.getDrawable(getContext(), R.drawable.keyboard_modifierkey_bg)); modifierKey.setTextSize(18f);/*from w ww .j a v a 2 s . c o m*/ modifierKey.setGravity(Gravity.CENTER); modifierKey.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mEditText == null) { return; } TextView textView = (TextView) v; if (!mEditText.isFocused()) mEditText.requestFocus(); Editable editableText = mEditText.getText(); int start = mEditText.getSelectionStart(); if (start == 0) return; CharSequence textViewText = textView.getText(); if (mEnableModifierFlag) { mEnableModifierFlag = false; editableText.replace(start - 1, start, textViewText); } else { editableText.insert(start, textViewText); } } }); LayoutParams params = new LayoutParams(0, LayoutParams.MATCH_PARENT, 1); int margin = getCustomSize(1.5f); params.setMargins(margin, margin, margin, margin); modifiersContainer.addView(modifierKey, params); } }