List of usage examples for android.widget TextView setTextAppearance
@Deprecated public void setTextAppearance(Context context, @StyleRes int resId)
From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** Presents additional information about a specific assistant. * @return a dynamically generated linear layout *//*ww w. j a va 2 s .co m*/ private LinearLayout getServiceDescLayout() { final LinearLayout output = new LinearLayout(this); final RelativeLayout topButtonsLayout = new RelativeLayout(this); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); final Button btnBack = new Button(this); btnBack.setText(R.string.btnAllServices); btnBack.setId(5); btnBack.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { output.setVisibility(View.GONE); getListView().setVisibility(View.VISIBLE); lblAvAssist.setVisibility(View.VISIBLE); } }); topButtonsLayout.addView(btnBack); final Button btnInvoke = new Button(this); btnInvoke.setText(R.string.btnInvokeLabel); btnInvoke.setId(6); btnInvoke.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new InvocationTask().execute(); } }); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId()); btnInvoke.setLayoutParams(layoutParams); topButtonsLayout.addView(btnInvoke); output.addView(topButtonsLayout); TableLayout serviceInfoTbl = new TableLayout(this); output.addView(serviceInfoTbl); serviceInfoTbl.setColumnShrinkable(1, true); /* FIRST ROW */ TableRow rowServiceName = new TableRow(this); TextView lblServiceName = new TextView(this); lblServiceName.setText(R.string.lblServiceName); lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceName = new TextView(this); txtServiceName.setText(selectedService); txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceName.setPadding(10, 0, 0, 0); rowServiceName.addView(lblServiceName); rowServiceName.addView(txtServiceName); /* SECOND ROW */ TableRow rowServiceDesc = new TableRow(this); TextView lblServiceDesc = new TextView(this); lblServiceDesc.setText(R.string.lblServiceDesc); lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceDesc = new TextView(this); txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceDesc.setPadding(10, 0, 0, 0); List<GateRuntimeParameter> params = null; ServiceInfoForClientArray list = getServices(); for (int i = 0; i < list.getItem().size(); i++) { if (list.getItem().get(i).getServiceName().equals(selectedService)) { txtServiceDesc.setText(list.getItem().get(i).getServiceDescription()); params = list.getItem().get(i).getParams(); break; } } TextView lblParams = new TextView(this); lblParams.setText(R.string.lblServiceParams); lblParams.setTextAppearance(getApplicationContext(), R.style.titleText); output.addView(lblParams); LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout paramsLayout = new LinearLayout(this); paramsLayout.setId(0); if (params.size() > 0) { ScrollView scroll = new ScrollView(this); scroll.setLayoutParams(txtParamsAttrbs); paramsLayout.setOrientation(LinearLayout.VERTICAL); scroll.addView(paramsLayout); for (int j = 0; j < params.size(); j++) { TextView lblParamName = new TextView(this); lblParamName.setText(params.get(j).getParamName()); EditText tview = new EditText(this); tview.setId(1); tview.setText(params.get(j).getDefaultValueString()); LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); tview.setLayoutParams(txtViewLayoutParams); paramsLayout.addView(lblParamName); paramsLayout.addView(tview); } output.addView(scroll); } else { TextView lblParamName = new TextView(this); lblParamName.setText(R.string.lblRTParams); output.addView(lblParamName); } rowServiceDesc.addView(lblServiceDesc); rowServiceDesc.addView(txtServiceDesc); serviceInfoTbl.addView(rowServiceName); serviceInfoTbl.addView(rowServiceDesc); output.setOrientation(LinearLayout.VERTICAL); output.setGravity(Gravity.TOP); return output; }
From source file:com.cloud.widget.viewpager.PagerSlidingTabStrip.java
private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { RelativeLayout rl = (RelativeLayout) tabsContainer.getChildAt(i); View v = rl.getChildAt(0); v.setBackgroundResource(tabBackgroundResId); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextAppearance(getContext(), tabDefaultTextAppearance); if (pager != null && i == pager.getCurrentItem()) { tab.setTextAppearance(getContext(), tabSelectedTextAppearance); }//w w w . j a va2 s .c om // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(titleText.getText().toString().toUpperCase(locale)); } } } } }
From source file:com.adarshahd.indianrailinfo.donate.PNRStat.java
private void createTableLayoutTrnDtls() { if (mPageResult.contains("FLUSHED PNR / ") || mPageResult.contains("Invalid PNR")) { mTextViewPNRSts.setText("The PNR entered is either invalid or expired! Please check."); mFrameLayout.removeAllViews();//from w w w . ja v a 2 s . com mFrameLayout.addView(mTextViewPNRSts); return; } if (mPageResult.contains("Connectivity Failure") || mPageResult.contains("try again")) { mTextViewPNRSts.setText("Looks like server is busy or currently unavailable. Please try again later!"); mFrameLayout.removeAllViews(); mFrameLayout.addView(mTextViewPNRSts); return; } List<String> trainList; if (mTrainDetails == null || mTrainDetails.getPNR() != mPNRNumber) { Elements eleTrain = Jsoup.parse(mPageResult).select("table tr tr td:containsOwn(Train Number)"); Iterator iteTrain = null; try { iteTrain = eleTrain.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("PNRStat", mPageResult); return; } trainList = new ArrayList<String>(); Element tmp; //Get the third row for train details iteTrain.next(); iteTrain.next(); if (iteTrain.hasNext()) { tmp = (Element) iteTrain.next(); trainList.add(tmp.select("td").get(0).text()); trainList.add(tmp.select("td").get(1).text()); trainList.add(tmp.select("td").get(2).text()); trainList.add(tmp.select("td").get(5).text()); trainList.add(tmp.select("td").get(6).text()); trainList.add(tmp.select("td").get(7).text()); } mTrainDetails = new TrainDetails(trainList, mPNRNumber); } else { trainList = mTrainDetails.getTrainDetails(); } mTableLayoutTrn = new TableLayout(mActivity); mTableLayoutTrn.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TableRow row = new TableRow(mActivity); mStrTrainDetails = new String(); row.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (String list : trainList) { TextView tv = new TextView(mActivity); tv.setText(list); tv.setPadding(10, 10, 10, 10); tv.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Small); row.addView(tv); mStrTrainDetails += list + " "; } row.setBackgroundResource(R.drawable.card_background); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); mTableLayoutTrn.addView(row); }
From source file:com.gmobi.poponews.widget.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); int px = DipHelper.dip2px(50); tab.setHeight(px);//from w w w .j a v a2 s. c o m px = DipHelper.dip2px(90); tab.setPadding(20, 0, 20, 0); tab.setText(title); tab.setTextAppearance(this.getContext(), R.style.TabTextStyle); tab.setGravity(Gravity.CENTER); tab.setShadowLayer((float) 0.01, 0, (float) 1.0, 0xffffff); addTab(position, tab); }
From source file:at.alladin.rmbt.android.map.overlay.RMBTBalloonOverlayView.java
public void setBalloonData(final RMBTBalloonOverlayItem item, final ViewGroup parent) { // map our custom item data to fields // title.setText(item.getTitle()); resultItems = item.getResultItems(); resultListView.removeAllViews();/*from w w w . j ava 2 s . c om*/ final float scale = getResources().getDisplayMetrics().density; final int leftRightItem = Helperfunctions.dpToPx(5, scale); final int topBottomItem = Helperfunctions.dpToPx(3, scale); final int leftRightDiv = Helperfunctions.dpToPx(0, scale); final int topBottomDiv = Helperfunctions.dpToPx(0, scale); final int heightDiv = Helperfunctions.dpToPx(1, scale); final int topBottomImg = Helperfunctions.dpToPx(1, scale); if (resultItems != null && resultItems.length() > 0) { for (int i = 0; i < 1; i++) // JSONObject resultListItem; try { final JSONObject result = resultItems.getJSONObject(i); final LayoutInflater resultInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View resultView = resultInflater.inflate(R.layout.balloon_overlay_listitem, parent); final LinearLayout measurementLayout = (LinearLayout) resultView .findViewById(R.id.resultMeasurementList); measurementLayout.setVisibility(View.GONE); final LinearLayout netLayout = (LinearLayout) resultView.findViewById(R.id.resultNetList); netLayout.setVisibility(View.GONE); final TextView measurementHeader = (TextView) resultView.findViewById(R.id.resultMeasurement); measurementHeader.setVisibility(View.GONE); final TextView netHeader = (TextView) resultView.findViewById(R.id.resultNet); netHeader.setVisibility(View.GONE); final TextView dateHeader = (TextView) resultView.findViewById(R.id.resultDate); dateHeader.setVisibility(View.GONE); dateHeader.setText(result.optString("time_string")); final JSONArray measurementArray = result.getJSONArray("measurement"); final JSONArray netArray = result.getJSONArray("net"); for (int j = 0; j < measurementArray.length(); j++) { final JSONObject singleItem = measurementArray.getJSONObject(j); final LinearLayout measurememtItemLayout = new LinearLayout(context); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item); measurememtItemLayout.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); measurememtItemLayout.setGravity(Gravity.CENTER_VERTICAL); measurememtItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem, topBottomItem); final TextView itemTitle = new TextView(context, null, R.style.balloonResultItemTitle); itemTitle.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.4f)); itemTitle.setTextAppearance(context, R.style.balloonResultItemTitle); itemTitle.setWidth(0); itemTitle.setGravity(Gravity.LEFT); itemTitle.setText(singleItem.getString("title")); measurememtItemLayout.addView(itemTitle); final ImageView itemClassification = new ImageView(context); itemClassification.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0.1f)); itemClassification.setPadding(0, topBottomImg, 0, topBottomImg); // itemClassification.set setGravity(Gravity.LEFT); itemClassification.setImageDrawable(getResources().getDrawable( Helperfunctions.getClassificationImage(singleItem.getInt("classification")))); measurememtItemLayout.addView(itemClassification); final TextView itemValue = new TextView(context, null, R.style.balloonResultItemValue); itemValue.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f)); itemValue.setTextAppearance(context, R.style.balloonResultItemValue); itemValue.setWidth(0); itemValue.setGravity(Gravity.LEFT); itemValue.setText(singleItem.getString("value")); measurememtItemLayout.addView(itemValue); measurementLayout.addView(measurememtItemLayout); final View divider = new View(context); divider.setLayoutParams(new LinearLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, heightDiv, 1)); divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); measurementLayout.addView(divider); measurementLayout.invalidate(); } for (int j = 0; j < netArray.length(); j++) { final JSONObject singleItem = netArray.getJSONObject(j); final LinearLayout netItemLayout = new LinearLayout(context); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item); netItemLayout.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT)); netItemLayout.setPadding(leftRightItem, topBottomItem, leftRightItem, topBottomItem); netItemLayout.setGravity(Gravity.CENTER_VERTICAL); final TextView itemTitle = new TextView(context, null, R.style.balloonResultItemTitle); itemTitle.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.4f)); itemTitle.setTextAppearance(context, R.style.balloonResultItemTitle); itemTitle.setWidth(0); itemTitle.setGravity(Gravity.LEFT); itemTitle.setText(singleItem.getString("title")); netItemLayout.addView(itemTitle); final ImageView itemClassification = new ImageView(context); itemClassification.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT, 0.1f)); itemClassification.setPadding(0, topBottomImg, 0, topBottomImg); itemClassification.setImageDrawable( context.getResources().getDrawable(R.drawable.traffic_lights_none)); netItemLayout.addView(itemClassification); final TextView itemValue = new TextView(context, null, R.style.balloonResultItemValue); itemValue.setLayoutParams( new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 0.5f)); itemValue.setTextAppearance(context, R.style.balloonResultItemValue); itemValue.setWidth(0); itemValue.setGravity(Gravity.LEFT); itemValue.setText(singleItem.optString("value", null)); netItemLayout.addView(itemValue); netLayout.addView(netItemLayout); final View divider = new View(context); divider.setLayoutParams(new LinearLayout.LayoutParams( android.view.ViewGroup.LayoutParams.MATCH_PARENT, heightDiv, 1)); divider.setPadding(leftRightDiv, topBottomDiv, leftRightDiv, topBottomDiv); divider.setBackgroundResource(R.drawable.bg_trans_light_10); netLayout.addView(divider); netLayout.invalidate(); } measurementHeader.setVisibility(View.VISIBLE); netHeader.setVisibility(View.VISIBLE); measurementLayout.setVisibility(View.VISIBLE); netLayout.setVisibility(View.VISIBLE); dateHeader.setVisibility(View.VISIBLE); resultListView.addView(resultView); Log.d(DEBUG_TAG, "View Added"); // codeText.setText(resultListItem.getString("sync_code")); } catch (final JSONException e) { e.printStackTrace(); } progessBar.setVisibility(View.GONE); emptyView.setVisibility(View.GONE); resultListView.setVisibility(View.VISIBLE); resultListView.invalidate(); } else { Log.i(DEBUG_TAG, "LEERE LISTE"); progessBar.setVisibility(View.GONE); emptyView.setVisibility(View.VISIBLE); emptyView.setText(context.getString(R.string.error_no_data)); emptyView.invalidate(); } }
From source file:org.bdigi.andy.MainActivity.java
private Fragment[] getModeFragments() { final Context ctx = MainActivity.this; Mode modes[] = getModes();//from w w w . j a v a 2 s . com Fragment frags[] = new Fragment[modes.length]; for (int i = 0; i < modes.length; i++) { final Mode mode = modes[i]; Fragment frag = new Fragment() { @Override public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) { LinearLayout layout = new LinearLayout(ctx); layout.setOrientation(LinearLayout.VERTICAL); TextView title = new TextView(ctx); title.setClickable(true); title.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { setMode(mode); } }); title.setText("Mode: " + mode.name()); title.setTextAppearance(ctx, R.style.Title); layout.addView(title); Seq<Property<?>> props = mode.properties().properties(); for (int i = 0; i < props.size(); i++) { Property p = props.apply(i); if (p instanceof BooleanProperty) { layout.addView(new PropWidget.BooleanPropertyWidget(ctx, (BooleanProperty) p)); } else if (p instanceof RadioProperty) { layout.addView(new PropWidget.RadioPropertyWidget(ctx, (RadioProperty) p)); } } return layout; } }; frags[i] = frag; } return frags; }
From source file:com.facebook.android.friendsmash.ScoreboardFragment.java
private void populateScoreboard() { // Ensure all components are firstly removed from scoreboardContainer scoreboardContainer.removeAllViews(); // Ensure the progress spinner is hidden progressContainer.setVisibility(View.INVISIBLE); // Ensure scoreboardEntriesList is not null and not empty first if (application.getScoreboardEntriesList() == null || application.getScoreboardEntriesList().size() <= 0) { closeAndShowError(getResources().getString(R.string.error_no_scores)); } else {// www . j a v a2s . c om // Iterate through scoreboardEntriesList, creating new UI elements for each entry int index = 0; Iterator<ScoreboardEntry> scoreboardEntriesIterator = application.getScoreboardEntriesList().iterator(); while (scoreboardEntriesIterator.hasNext()) { // Get the current scoreboard entry final ScoreboardEntry currentScoreboardEntry = scoreboardEntriesIterator.next(); // FrameLayout Container for the currentScoreboardEntry ... // Create and add a new FrameLayout to display the details of this entry FrameLayout frameLayout = new FrameLayout(getActivity()); scoreboardContainer.addView(frameLayout); // Set the attributes for this frameLayout int topPadding = getResources().getDimensionPixelSize(R.dimen.scoreboard_entry_top_margin); frameLayout.setPadding(0, topPadding, 0, 0); // ImageView background image ... { // Create and add an ImageView for the background image to this entry ImageView backgroundImageView = new ImageView(getActivity()); frameLayout.addView(backgroundImageView); // Set the image of the backgroundImageView String uri = "drawable/scores_stub_even"; if (index % 2 != 0) { // Odd entry uri = "drawable/scores_stub_odd"; } int imageResource = getResources().getIdentifier(uri, null, getActivity().getPackageName()); Drawable image = getResources().getDrawable(imageResource); backgroundImageView.setImageDrawable(image); // Other attributes of backgroundImageView to modify FrameLayout.LayoutParams backgroundImageViewLayoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); int backgroundImageViewMarginTop = getResources() .getDimensionPixelSize(R.dimen.scoreboard_background_imageview_margin_top); backgroundImageViewLayoutParams.setMargins(0, backgroundImageViewMarginTop, 0, 0); backgroundImageViewLayoutParams.gravity = Gravity.LEFT; if (index % 2 != 0) { // Odd entry backgroundImageViewLayoutParams.gravity = Gravity.RIGHT; } backgroundImageView.setLayoutParams(backgroundImageViewLayoutParams); } // ProfilePictureView of the current user ... { // Create and add a ProfilePictureView for the current user entry's profile picture ProfilePictureView profilePictureView = new ProfilePictureView(getActivity()); frameLayout.addView(profilePictureView); // Set the attributes of the profilePictureView int profilePictureViewWidth = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_width); FrameLayout.LayoutParams profilePictureViewLayoutParams = new FrameLayout.LayoutParams( profilePictureViewWidth, profilePictureViewWidth); int profilePictureViewMarginLeft = 0; int profilePictureViewMarginTop = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_top); int profilePictureViewMarginRight = 0; int profilePictureViewMarginBottom = 0; if (index % 2 == 0) { profilePictureViewMarginLeft = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_left); } else { profilePictureViewMarginRight = getResources() .getDimensionPixelSize(R.dimen.scoreboard_profile_picture_view_margin_right); } profilePictureViewLayoutParams.setMargins(profilePictureViewMarginLeft, profilePictureViewMarginTop, profilePictureViewMarginRight, profilePictureViewMarginBottom); profilePictureViewLayoutParams.gravity = Gravity.LEFT; if (index % 2 != 0) { // Odd entry profilePictureViewLayoutParams.gravity = Gravity.RIGHT; } profilePictureView.setLayoutParams(profilePictureViewLayoutParams); // Finally set the id of the user to show their profile pic profilePictureView.setProfileId(currentScoreboardEntry.getId()); } // LinearLayout to hold the text in this entry // Create and add a LinearLayout to hold the TextViews LinearLayout textViewsLinearLayout = new LinearLayout(getActivity()); frameLayout.addView(textViewsLinearLayout); // Set the attributes for this textViewsLinearLayout FrameLayout.LayoutParams textViewsLinearLayoutLayoutParams = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT); int textViewsLinearLayoutMarginLeft = 0; int textViewsLinearLayoutMarginTop = getResources() .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_top); int textViewsLinearLayoutMarginRight = 0; int textViewsLinearLayoutMarginBottom = 0; if (index % 2 == 0) { textViewsLinearLayoutMarginLeft = getResources() .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_left); } else { textViewsLinearLayoutMarginRight = getResources() .getDimensionPixelSize(R.dimen.scoreboard_textviews_linearlayout_margin_right); } textViewsLinearLayoutLayoutParams.setMargins(textViewsLinearLayoutMarginLeft, textViewsLinearLayoutMarginTop, textViewsLinearLayoutMarginRight, textViewsLinearLayoutMarginBottom); textViewsLinearLayoutLayoutParams.gravity = Gravity.LEFT; if (index % 2 != 0) { // Odd entry textViewsLinearLayoutLayoutParams.gravity = Gravity.RIGHT; } textViewsLinearLayout.setLayoutParams(textViewsLinearLayoutLayoutParams); textViewsLinearLayout.setOrientation(LinearLayout.VERTICAL); // TextView with the position and name of the current user { // Set the text that should go in this TextView first int position = index + 1; String currentScoreboardEntryTitle = position + ". " + currentScoreboardEntry.getName(); // Create and add a TextView for the current user position and first name TextView titleTextView = new TextView(getActivity()); textViewsLinearLayout.addView(titleTextView); // Set the text and other attributes for this TextView titleTextView.setText(currentScoreboardEntryTitle); titleTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerNameFont); } // TextView with the score of the current user { // Create and add a TextView for the current user score TextView scoreTextView = new TextView(getActivity()); textViewsLinearLayout.addView(scoreTextView); // Set the text and other attributes for this TextView scoreTextView.setText("Score: " + currentScoreboardEntry.getScore()); scoreTextView.setTextAppearance(getActivity(), R.style.ScoreboardPlayerScoreFont); } // Finally make this frameLayout clickable so that a game starts with the user smashing // the user represented by this frameLayout in the scoreContainer frameLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_UP) { Bundle bundle = new Bundle(); bundle.putString("user_id", currentScoreboardEntry.getId()); Intent i = new Intent(); i.putExtras(bundle); getActivity().setResult(Activity.RESULT_FIRST_USER, i); getActivity().finish(); return false; } else { return true; } } }); // Increment the index before looping back index++; } } }
From source file:me.futuretechnology.blops.ui.FeedFragment.java
private void initUI() { if (getView() == null) { return;//from w ww.ja v a 2 s . c o m } // start out with a progress indicator setListShownNoAnimation(false); TypedValue typedValue = new TypedValue(); Resources.Theme theme = getActivity().getTheme(); // noinspection ResourceType SwipeRefreshLayout swipeLayout = (SwipeRefreshLayout) getView().findViewById(INTERNAL_LIST_CONTAINER_ID); theme.resolveAttribute(R.attr.colorPrimary, typedValue, true); swipeLayout.setColorSchemeResources(typedValue.resourceId); swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { LoaderManager lm = getLoaderManager(); lm.restartLoader(LoaderIds.ASYNC_GET_FEED + getArguments().getInt("position"), null, loaderCallbacks); } }); ListView listView = getListView(); listView.setVelocityScale(2.0f); setEmptyText(getText(R.string.empty_news)); TextView tvEmpty = (TextView) listView.getEmptyView(); tvEmpty.setTextAppearance(getActivity(), R.style.TextAppearance_AppCompat_Title); theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true); tvEmpty.setTextColor(getResources().getColor(typedValue.resourceId)); listView.setOnScrollListener(this); // listView().setOnCreateContextMenuListener(this); }
From source file:uk.co.ashtonbrsc.intentexplode.Explode.java
/** textViewToIgnore is not updated so current selected char in that textview will not change */ private void showAllIntentData(TextView textViewToIgnore) { showTextViewIntentData(textViewToIgnore); categoriesLayout.removeAllViews();/* w ww .ja v a 2s . c o m*/ Set<String> categories = editableIntent.getCategories(); StringBuilder stringBuilder = new StringBuilder(); if (categories != null) { categoriesHeader.setVisibility(View.VISIBLE); stringBuilder.append(getResources().getString(R.string.categories)); for (String category : categories) { stringBuilder.append(category).append(NEWLINE); TextView categoryTextView = new TextView(this); categoryTextView.setText(category); categoryTextView.setTextAppearance(this, R.style.TextFlags); categoriesLayout.addView(categoryTextView); } } else { categoriesHeader.setVisibility(View.GONE); // addTextToLayout("NONE", Typeface.NORMAL, categoriesLayout); } flagsLayout.removeAllViews(); ArrayList<String> flagsStrings = getFlags(); if (!flagsStrings.isEmpty()) { for (String thisFlagString : flagsStrings) { addTextToLayout(thisFlagString, Typeface.NORMAL, flagsLayout); } } else { addTextToLayout(getResources().getString(R.string.none), Typeface.NORMAL, flagsLayout); } extrasLayout.removeAllViews(); try { Bundle intentBundle = editableIntent.getExtras(); if (intentBundle != null) { Set<String> keySet = intentBundle.keySet(); stringBuilder.append(getResources().getString(R.string.bundle_title_bold)); int count = 0; for (String key : keySet) { count++; Object thisObject = intentBundle.get(key); addTextToLayout(getResources().getString(R.string.extra) + count, Typeface.BOLD, extrasLayout); String thisClass = thisObject.getClass().getName(); if (thisClass != null) { addTextToLayout(getResources().getString(R.string.class_text) + thisClass, Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, extrasLayout); } addTextToLayout(getResources().getString(R.string.key) + key, Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, extrasLayout); if (thisObject instanceof String || thisObject instanceof Long || thisObject instanceof Integer || thisObject instanceof Boolean || thisObject instanceof Uri) { addTextToLayout(getResources().getString(R.string.value) + thisObject.toString(), Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, extrasLayout); } else if (thisObject instanceof ArrayList) { addTextToLayout(getResources().getString(R.string.values), Typeface.ITALIC, extrasLayout); ArrayList thisArrayList = (ArrayList) thisObject; for (Object thisArrayListObject : thisArrayList) { addTextToLayout(thisArrayListObject.toString(), Typeface.ITALIC, STANDARD_INDENT_SIZE_IN_DIP, extrasLayout); } } } } else { addTextToLayout(getResources().getString(R.string.none), Typeface.NORMAL, extrasLayout); } } catch (Exception e) { // TODO Should make this red to highlight error addTextToLayout(getResources().getString(R.string.error_extracting_extras), Typeface.NORMAL, extrasLayout); e.printStackTrace(); } // resolveInfo = pm.queryIntentServices(intent, 0); // stringBuilder.append("<br><b><u>" + resolveInfo.size() // + " services match this intent:</u></b><br>"); // for (int i = 0; i < resolveInfo.size(); i++) { // ResolveInfo info = resolveInfo.get(i); // ActivityInfo activityinfo = info.activityInfo; // stringBuilder.append(activityinfo.packageName + "<br>"); // } // intentDetailsHtml = stringBuilder.toString(); // (((TextView) findViewById(R.id.text))).setText(intentDetailsHtml); refreshUI(); }