List of usage examples for android.widget TextView setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.arcgis.android.samples.localdata.localrasterdata.FileBrowserFragment.java
private void createFileListAdapter() { adapter = new ArrayAdapter<Item>(getActivity(), android.R.layout.select_dialog_item, android.R.id.text1, fileList) {/*from w w w . ja v a 2s . c om*/ @Override public View getView(int position, View convertView, ViewGroup parent) { // creates view View view = super.getView(position, convertView, parent); TextView textView = (TextView) view.findViewById(android.R.id.text1); // put the image on the text view int drawableID = 0; if (fileList.get(position).icon != -1) { // If icon == -1, then directory is empty drawableID = fileList.get(position).icon; } textView.setCompoundDrawablesWithIntrinsicBounds(drawableID, 0, 0, 0); textView.setEllipsize(null); int dp3 = (int) (3 * getResources().getDisplayMetrics().density + 0.5f); textView.setCompoundDrawablePadding(dp3); textView.setBackgroundColor(Color.LTGRAY); return view; } }; }
From source file:com.gh4a.IssueActivity.java
private void fillData() { new LoadCommentsTask(this).execute(); Typeface boldCondensed = getApplicationContext().boldCondensed; ListView lvComments = (ListView) findViewById(R.id.list_view); // set details inside listview header LayoutInflater infalter = getLayoutInflater(); LinearLayout mHeader = (LinearLayout) infalter.inflate(R.layout.issue_header, lvComments, false); mHeader.setClickable(false);/*w w w . j a v a2s .c o m*/ lvComments.addHeaderView(mHeader, null, false); RelativeLayout rlComment = (RelativeLayout) findViewById(R.id.rl_comment); if (!isAuthorized()) { rlComment.setVisibility(View.GONE); } TextView tvCommentTitle = (TextView) mHeader.findViewById(R.id.comment_title); mCommentAdapter = new CommentAdapter(IssueActivity.this, new ArrayList<Comment>(), mIssue.getNumber(), mIssue.getState(), mRepoOwner, mRepoName); lvComments.setAdapter(mCommentAdapter); ImageView ivGravatar = (ImageView) mHeader.findViewById(R.id.iv_gravatar); aq.id(R.id.iv_gravatar).image(GravatarUtils.getGravatarUrl(mIssue.getUser().getGravatarId()), true, false, 0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN); ivGravatar.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getUser().getLogin(), null); } }); TextView tvExtra = (TextView) mHeader.findViewById(R.id.tv_extra); TextView tvState = (TextView) mHeader.findViewById(R.id.tv_state); TextView tvTitle = (TextView) mHeader.findViewById(R.id.tv_title); TextView tvDescTitle = (TextView) mHeader.findViewById(R.id.desc_title); tvDescTitle.setTypeface(getApplicationContext().boldCondensed); tvDescTitle.setTextColor(Color.parseColor("#0099cc")); tvCommentTitle.setTypeface(getApplicationContext().boldCondensed); tvCommentTitle.setTextColor(Color.parseColor("#0099cc")); tvCommentTitle .setText(getResources().getString(R.string.issue_comments) + " (" + mIssue.getComments() + ")"); TextView tvDesc = (TextView) mHeader.findViewById(R.id.tv_desc); tvDesc.setMovementMethod(LinkMovementMethod.getInstance()); TextView tvMilestone = (TextView) mHeader.findViewById(R.id.tv_milestone); ImageView ivComment = (ImageView) findViewById(R.id.iv_comment); if (Gh4Application.THEME == R.style.DefaultTheme) { ivComment.setImageResource(R.drawable.social_send_now_dark); } ivComment.setBackgroundResource(R.drawable.abs__list_selector_holo_dark); ivComment.setPadding(5, 2, 5, 2); ivComment.setOnClickListener(this); tvExtra.setText(mIssue.getUser().getLogin() + "\n" + pt.format(mIssue.getCreatedAt())); tvState.setTextColor(Color.WHITE); if ("closed".equals(mIssue.getState())) { tvState.setBackgroundResource(R.drawable.default_red_box); tvState.setText("C\nL\nO\nS\nE\nD"); } else { tvState.setBackgroundResource(R.drawable.default_green_box); tvState.setText("O\nP\nE\nN"); } tvTitle.setText(mIssue.getTitle()); tvTitle.setTypeface(boldCondensed); boolean showInfoBox = false; if (mIssue.getAssignee() != null) { showInfoBox = true; TextView tvAssignee = (TextView) mHeader.findViewById(R.id.tv_assignee); tvAssignee.setText(mIssue.getAssignee().getLogin() + " is assigned"); tvAssignee.setVisibility(View.VISIBLE); tvAssignee.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getAssignee().getLogin(), null); } }); ImageView ivAssignee = (ImageView) mHeader.findViewById(R.id.iv_assignee); aq.id(R.id.iv_assignee).image(GravatarUtils.getGravatarUrl(mIssue.getAssignee().getGravatarId()), true, false, 0, 0, aq.getCachedImage(R.drawable.default_avatar), AQuery.FADE_IN); ivAssignee.setVisibility(View.VISIBLE); ivAssignee.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { getApplicationContext().openUserInfoActivity(IssueActivity.this, mIssue.getAssignee().getLogin(), null); } }); } if (mIssue.getMilestone() != null) { showInfoBox = true; tvMilestone.setText( getResources().getString(R.string.issue_milestone) + ": " + mIssue.getMilestone().getTitle()); } else { tvMilestone.setVisibility(View.GONE); } String body = mIssue.getBodyHtml(); if (!StringUtils.isBlank(body)) { HttpImageGetter imageGetter = new HttpImageGetter(this); body = HtmlUtils.format(body).toString(); imageGetter.bind(tvDesc, body, mIssue.getNumber()); } LinearLayout llLabels = (LinearLayout) findViewById(R.id.ll_labels); List<Label> labels = mIssue.getLabels(); if (labels != null && !labels.isEmpty()) { showInfoBox = true; for (Label label : labels) { TextView tvLabel = new TextView(this); tvLabel.setSingleLine(true); tvLabel.setText(label.getName()); tvLabel.setTextAppearance(this, R.style.default_text_small); tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor())); tvLabel.setPadding(5, 2, 5, 2); int r = Color.red(Color.parseColor("#" + label.getColor())); int g = Color.green(Color.parseColor("#" + label.getColor())); int b = Color.blue(Color.parseColor("#" + label.getColor())); if (r + g + b < 383) { tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_dark)); } else { tvLabel.setTextColor(getResources().getColor(android.R.color.primary_text_light)); } llLabels.addView(tvLabel); View v = new View(this); v.setLayoutParams(new LayoutParams(5, LayoutParams.WRAP_CONTENT)); llLabels.addView(v); } } else { llLabels.setVisibility(View.GONE); } TextView tvPull = (TextView) mHeader.findViewById(R.id.tv_pull); if (mIssue.getPullRequest() != null && mIssue.getPullRequest().getDiffUrl() != null) { showInfoBox = true; tvPull.setVisibility(View.VISIBLE); tvPull.setOnClickListener(this); } if (!showInfoBox) { RelativeLayout rl = (RelativeLayout) mHeader.findViewById(R.id.info_box); rl.setVisibility(View.GONE); } }
From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java
private void confirmSendLog() { CommonLogUtil.flushLog(mContext, mGp); mThemeColorList = ThemeUtil.getThemeColorList(getActivity()); createTempLogFile();/*from ww w .ja v a2s . co m*/ final Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.confirm_send_log_dlg); dialog.setCanceledOnTouchOutside(false); LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.confirm_send_log_dlg_title_view); title_view.setBackgroundColor(mThemeColorList.dialog_title_background_color); TextView title = (TextView) dialog.findViewById(R.id.confirm_send_log_dlg_title); title.setTextColor(mThemeColorList.text_color_dialog_title); TextView msg = (TextView) dialog.findViewById(R.id.confirm_send_log_dlg_msg); msg.setTextColor(mThemeColorList.text_color_info); msg.setBackgroundColor(mThemeColorList.dialog_msg_background_color); final Button btn_ok = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_ok_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_cancel_btn); final Button btn_preview = (Button) dialog.findViewById(R.id.confirm_send_log_dlg_preview); CommonDialog.setDlgBoxSizeLimit(dialog, false); btn_preview.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { Intent intent = new Intent(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse("file://" + mGp.getLogDirName() + "temp_log.txt"), "text/plain"); startActivity(intent); } }); btn_ok.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { sendLogFileToDeveloper(mGp.getLogDirName() + "temp_log.txt"); dialog.dismiss(); } }); btn_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { dialog.dismiss(); } }); dialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); dialog.show(); }
From source file:com.kanazawaevent.view.layout.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from www . ja v a 2 s. com TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; // ???? EventLocation location = EventLocation.ordinalOf(i); tabTitleView.setBackgroundColor(ColorUtil.getBack(getContext(), location.getColor())); } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Creates the image cache text view./* w w w . j a va 2 s . co m*/ * * @return the text view */ private TextView createCacheText() { TextView cacheText = new TextView(this); cacheText.setPadding(10, 5, 0, 5); cacheText.setText("Image Cache:"); cacheText.setBackgroundColor(Color.DKGRAY); return cacheText; }
From source file:com.gh4a.IssueCreateActivity.java
public void fillLabels() { final Typeface boldCondensed = getApplicationContext().boldCondensed; final Typeface condensed = getApplicationContext().condensed; for (final Label label : mAllLabel) { final View rowView = getLayoutInflater().inflate(R.layout.row_issue_create_label, null); View viewColor = (View) rowView.findViewById(R.id.view_color); viewColor.setBackgroundColor(Color.parseColor("#" + label.getColor())); //viewColor.setPadding(10, 10, 10, 10); final TextView tvLabel = (TextView) rowView.findViewById(R.id.tv_title); tvLabel.setTypeface(condensed);//from w w w.jav a 2 s . com tvLabel.setText(label.getName()); tvLabel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mSelectedLabels.contains(label)) { mSelectedLabels.remove(label); tvLabel.setTypeface(condensed); tvLabel.setBackgroundColor(0); if (Gh4Application.THEME == R.style.LightTheme) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } } else { mSelectedLabels.add(label); tvLabel.setTypeface(boldCondensed); tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor())); int r = Color.red(Color.parseColor("#" + label.getColor())); int g = Color.green(Color.parseColor("#" + label.getColor())); int b = Color.blue(Color.parseColor("#" + label.getColor())); if (r + g + b < 383) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } } } }); if (mEditMode) { if (mSelectedLabels.contains(label)) { tvLabel.setTypeface(boldCondensed); tvLabel.setBackgroundColor(Color.parseColor("#" + label.getColor())); int r = Color.red(Color.parseColor("#" + label.getColor())); int g = Color.green(Color.parseColor("#" + label.getColor())); int b = Color.blue(Color.parseColor("#" + label.getColor())); if (r + g + b < 383) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } } else { tvLabel.setTypeface(condensed); tvLabel.setBackgroundColor(0); if (Gh4Application.THEME == R.style.LightTheme) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } } } mLinearLayoutLabels.addView(rowView); } }
From source file:com.somethoughts.chinmay.game.Dice.DiceFragment.java
void spin() { if (inProgress) { Toast.makeText(getActivity(), "Please Wait", Toast.LENGTH_SHORT).show(); return;//from w w w. j a v a 2 s . c om } Typeface custom_font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/myfnt.ttf"); final TextView textView = (TextView) view.findViewById(R.id.dice_result_textview); final TextView textViewrun = (TextView) view.findViewById(R.id.result_textView_run); final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.dice_progressBar); progressBar.setIndeterminate(false); progressBar.setMax(3000); textView.setTypeface(custom_font); textViewrun.setTypeface(custom_font); progressBar.setVisibility(View.VISIBLE); countDownTimer = new CountDownTimer(3000, 250) { @Override public void onTick(long l) { inProgress = true; Random random = new Random(); progressBar.setProgress(3000 - (int) l); Log.v("Progress", Integer.toString(progressBar.getProgress())); textViewrun.setVisibility(View.VISIBLE); textViewrun.setText("Waiting"); textView.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark)); textView.setText(Integer.toString(random.nextInt(6) + 1)); } @Override public void onFinish() { inProgress = false; view.setBackgroundColor(getResources().getColor(R.color.colorWin)); textViewrun.setText("Here you go"); progressBar.setProgress(3000); return; } }.start(); }
From source file:org.mixare.MixListView.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // mixCtx = MixView.ctx; dataView = MixView.dataView;/*from w w w. ja va2s . c o m*/ ctx = this; mixContext = dataView.getContext(); switch (list) { case 1: adapter = new ListItemAdapter(this); //adapter.colorSource(getDataSource()); getListView().setTextFilterEnabled(true); setListAdapter(adapter); break; case 2: selectedItem = new Vector<Marker>(); listViewMenu = new Vector<SpannableString>(); DataHandler jLayer = dataView.getDataHandler(); /*add all marker items to a title and a URL Vector*/ for (int i = 0; i < jLayer.getMarkerCount(); i++) { Marker ma = jLayer.getMarker(i); if (ma.isActive()) { listViewMenu.add(new SpannableString(ma.getTitle())); selectedItem.add(ma); } } if (dataView.isFrozen()) { TextView searchNotificationTxt = new TextView(this); searchNotificationTxt.setVisibility(View.VISIBLE); searchNotificationTxt.setText(getString(DataView.SEARCH_ACTIVE_1) + " " + DataSourceList.getDataSourcesStringList() + getString(DataView.SEARCH_ACTIVE_2)); searchNotificationTxt.setWidth(MixView.dWindow.getWidth()); searchNotificationTxt.setPadding(10, 2, 0, 0); searchNotificationTxt.setBackgroundColor(Color.DKGRAY); searchNotificationTxt.setTextColor(Color.WHITE); getListView().addHeaderView(searchNotificationTxt); } setListAdapter( new ArrayAdapter<SpannableString>(this, android.R.layout.simple_list_item_1, listViewMenu)); getListView().setTextFilterEnabled(true); break; case 3: String addr = this.getIntent().getExtras().getString("address"); Map<String, Location> locs = DataInterface.getRouteSuggestions(addr); suggestionItems = new Vector<String>(); suggestionLocations = new Vector<Location>(); for (Map.Entry<String, Location> l : locs.entrySet()) { suggestionItems.add(l.getKey()); suggestionLocations.add(l.getValue()); } setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, suggestionItems)); getListView().setTextFilterEnabled(true); break; } }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Creates the choose panel identity text. * //ww w. j ava 2s . co m * @return the text view */ private TextView createChoosePanelLabel() { TextView choosePanelInfo = new TextView(this); choosePanelInfo.setPadding(10, 5, 0, 5); choosePanelInfo.setText("Choose Panel Identity:"); choosePanelInfo.setBackgroundColor(Color.DKGRAY); return choosePanelInfo; }
From source file:com.cw.litenote.note.Note_adapter.java
@SuppressLint("SetJavaScriptEnabled") @Override// ww w .j av a2s .c o m public Object instantiateItem(ViewGroup container, final int position) { System.out.println("Note_adapter / instantiateItem / position = " + position); // Inflate the layout containing // 1. picture group: image,video, thumb nail, control buttons // 2. text group: title, body, time View pagerView = inflater.inflate(R.layout.note_view_adapter, container, false); int style = Note.getStyle(); pagerView.setBackgroundColor(ColorSet.mBG_ColorArray[style]); // Picture group ViewGroup pictureGroup = (ViewGroup) pagerView.findViewById(R.id.pictureContent); String tagPictureStr = "current" + position + "pictureView"; pictureGroup.setTag(tagPictureStr); // image view TouchImageView imageView = ((TouchImageView) pagerView.findViewById(R.id.image_view)); String tagImageStr = "current" + position + "imageView"; imageView.setTag(tagImageStr); // video view VideoViewCustom videoView = ((VideoViewCustom) pagerView.findViewById(R.id.video_view)); String tagVideoStr = "current" + position + "videoView"; videoView.setTag(tagVideoStr); ProgressBar spinner = (ProgressBar) pagerView.findViewById(R.id.loading); // link web view CustomWebView linkWebView = ((CustomWebView) pagerView.findViewById(R.id.link_web_view)); String tagStr = "current" + position + "linkWebView"; linkWebView.setTag(tagStr); // line view View line_view = pagerView.findViewById(R.id.line_view); // text group ViewGroup textGroup = (ViewGroup) pagerView.findViewById(R.id.textGroup); // Set tag for text web view CustomWebView textWebView = ((CustomWebView) textGroup.findViewById(R.id.textBody)); // set accessibility textGroup.setContentDescription(act.getResources().getString(R.string.note_text)); textWebView.getRootView().setContentDescription(act.getResources().getString(R.string.note_text)); tagStr = "current" + position + "textWebView"; textWebView.setTag(tagStr); // set text web view setWebView(textWebView, spinner, CustomWebView.TEXT_VIEW); String linkUri = db_page.getNoteLinkUri(position, true); String strTitle = db_page.getNoteTitle(position, true); String strBody = db_page.getNoteBody(position, true); // View mode // picture only if (Note.isPictureMode()) { System.out.println("Note_adapter / _instantiateItem / isPictureMode "); pictureGroup.setVisibility(View.VISIBLE); showPictureView(position, imageView, videoView, linkWebView, spinner); line_view.setVisibility(View.GONE); textGroup.setVisibility(View.GONE); } // text only else if (Note.isTextMode()) { System.out.println("Note_adapter / _instantiateItem / isTextMode "); pictureGroup.setVisibility(View.GONE); line_view.setVisibility(View.VISIBLE); textGroup.setVisibility(View.VISIBLE); if (Util.isYouTubeLink(linkUri) || !Util.isEmptyString(strTitle) || !Util.isEmptyString(strBody) || linkUri.startsWith("http")) { showTextWebView(position, textWebView); } } // picture and text else if (Note.isViewAllMode()) { System.out.println("Note_adapter / _instantiateItem / isViewAllMode "); // picture pictureGroup.setVisibility(View.VISIBLE); showPictureView(position, imageView, videoView, linkWebView, spinner); line_view.setVisibility(View.VISIBLE); textGroup.setVisibility(View.VISIBLE); // text if (!Util.isEmptyString(strTitle) || !Util.isEmptyString(strBody) || Util.isYouTubeLink(linkUri) || linkUri.startsWith("http")) { showTextWebView(position, textWebView); } else { textGroup.setVisibility(View.GONE); } } // footer of note view TextView footerText = (TextView) pagerView.findViewById(R.id.note_view_footer); if (!Note.isPictureMode()) { footerText.setVisibility(View.VISIBLE); footerText.setText(String.valueOf(position + 1) + "/" + pager.getAdapter().getCount()); footerText.setTextColor(ColorSet.mText_ColorArray[Note.mStyle]); footerText.setBackgroundColor(ColorSet.mBG_ColorArray[Note.mStyle]); } else footerText.setVisibility(View.GONE); container.addView(pagerView, 0); return pagerView; }