List of usage examples for android.widget TextView setTextColor
@android.view.RemotableViewMethod public void setTextColor(ColorStateList colors)
From source file:com.box.myview.MyTopSnackBar.TSnackbar.java
/** * Sets the text color of the action specified in * {@link #setAction(CharSequence, View.OnClickListener)}. *//* w ww . ja v a 2 s . c om*/ @NonNull public TSnackbar setMessageTextColor(ColorStateList colors) { final TextView tv = mView.getMessageView(); tv.setTextColor(colors); return this; }
From source file:com.amaze.filemanager.fragments.ProcessViewer.java
public void processResults(final DataPackage b) { if (!running) return;/*from w ww. j a v a 2 s . c om*/ if (getResources() == null) return; if (b != null) { int id = b.getId(); final Integer id1 = new Integer(id); if (!CancelledCopyIds.contains(id1)) { if (CopyIds.contains(id1)) { boolean completed = b.isCompleted(); View process = rootView.findViewWithTag("copy" + id); if (completed) { try { rootView.removeViewInLayout(process); CopyIds.remove(CopyIds.indexOf(id1)); } catch (Exception e) { e.printStackTrace(); } } else { String name = b.getName(); int p1 = b.getP1(); int p2 = b.getP2(); long total = b.getTotal(); long done = b.getDone(); boolean move = b.isMove(); String text = utils.getString(getActivity(), R.string.copying) + "\n" + name + "\n" + utils.readableFileSize(done) + "/" + utils.readableFileSize(total) + "\n" + p1 + "%"; if (move) { text = utils.getString(getActivity(), R.string.moving) + "\n" + name + "\n" + utils.readableFileSize(done) + "/" + utils.readableFileSize(total) + "\n" + p1 + "%"; } ((TextView) process.findViewById(R.id.progressText)).setText(text); ProgressBar p = (ProgressBar) process.findViewById(R.id.progressBar1); p.setProgress(p1); p.setSecondaryProgress(p2); } } else { CardView root = (android.support.v7.widget.CardView) getActivity().getLayoutInflater() .inflate(R.layout.processrow, null); root.setTag("copy" + id); ImageButton cancel = (ImageButton) root.findViewById(R.id.delete_button); TextView progressText = (TextView) root.findViewById(R.id.progressText); Drawable icon = icons.getCopyDrawable(); boolean move = b.isMove(); if (move) { icon = icons.getCutDrawable(); } if (mainActivity.theme1 == 1) { cancel.setImageResource(R.drawable.ic_action_cancel); root.setCardBackgroundColor(R.color.cardView_foreground); root.setCardElevation(0f); progressText.setTextColor(Color.WHITE); } else { icon.setColorFilter(Color.parseColor("#666666"), PorterDuff.Mode.SRC_ATOP); progressText.setTextColor(Color.BLACK); } ((ImageView) root.findViewById(R.id.progressImage)).setImageDrawable(icon); cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.stopping), Toast.LENGTH_LONG).show(); Intent i = new Intent("copycancel"); i.putExtra("id", id1); getActivity().sendBroadcast(i); rootView.removeView(rootView.findViewWithTag("copy" + id1)); CopyIds.remove(CopyIds.indexOf(id1)); CancelledCopyIds.add(id1); // TODO: Implement this method } }); String name = b.getName(); int p1 = b.getP1(); int p2 = b.getP2(); String text = utils.getString(getActivity(), R.string.copying) + "\n" + name; if (move) { text = utils.getString(getActivity(), R.string.moving) + "\n" + name; } progressText.setText(text); ProgressBar p = (ProgressBar) root.findViewById(R.id.progressBar1); p.setProgress(p1); p.setSecondaryProgress(p2); CopyIds.add(id1); rootView.addView(root); } } } }
From source file:com.app.viaje.viaje.MapsActivity.java
/** * @description :: Get posts.//w ww . jav a 2s . co m */ private void getPosts() { final Query queryRef = dbRef.child(ViajeConstants.POSTS_KEY); queryRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if (dataSnapshot.getValue() != null) { final Map<String, Post> td = new HashMap<String, Post>(); final ArrayList<Post> postValues = new ArrayList<>(td.values()); List<String> keys = new ArrayList<String>(td.keySet()); for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) { Post post = postSnapshot.getValue(Post.class); td.put(postSnapshot.getKey(), post); double lat = post.getLat(); double lng = post.getLng(); String postContent = post.getText(); final String username = post.getUser().getUsername(); LatLng location = new LatLng(lat, lng); //User current location mMap.addMarker( new MarkerOptions().position(location).title("post").snippet(postSnapshot.getKey()) .icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher))) .setTag(post); mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(final Marker marker) { if (marker.getTitle().contains("post")) { /** * Layout Inflater for the * alert dialog when a marker * has been click */ LayoutInflater inflater = getLayoutInflater(); View dialogLayout = inflater.inflate(R.layout.dialog_layout_comment, null, false); AlertDialog.Builder builder = new AlertDialog.Builder(MapsActivity.this); //Create StringBuilder to have a new line in every TextView StringBuilder sb = new StringBuilder(""); post_content = (TextView) dialogLayout.findViewById(R.id.postContent); date_time = (TextView) dialogLayout.findViewById(R.id.timestampID); postCommentContent = (TextView) dialogLayout .findViewById(R.id.commentContentID); postCommentedBy = (TextView) dialogLayout.findViewById(R.id.commentedByID); commentContentBody = (EditText) dialogLayout.findViewById(R.id.post); Post p = (Post) marker.getTag(); System.out.println(p); post_content.append(p.getText()); post_content.setPaintFlags( post_content.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); /** * Loop every entry of p.comments * inside the marker.getTag(). */ if (p.comments != null) { Iterator entries = p.comments.entrySet().iterator(); while (entries.hasNext()) { Map.Entry myEntry = (Map.Entry) entries.next(); Object key = myEntry.getKey(); Post.Comment value = (Post.Comment) myEntry.getValue(); String commenter = value.getUser().getUsername(); String dateTime = getDate(value.getTimestamp()); //String dateTime = new Date(value.getTimestamp()); sb.append(commenter + " on " + dateTime + "\n \t \t" + value.getText()); sb.append("\n \n"); postCommentedBy.setText(sb.toString()); } } //Button that submits a comment to a post. builder.setPositiveButton("Post Comment", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String comment = commentContentBody.getText().toString().trim(); /** * Function declaration that * submits a comment to the 'post' * at firebase database. */ if (comment.isEmpty()) { Snackbar snackbar = Snackbar.make(relativeLayout, "Comment must not be empty..", Snackbar.LENGTH_LONG); View sbView = snackbar.getView(); TextView textView = (TextView) sbView.findViewById( android.support.design.R.id.snackbar_text); textView.setTextColor(Color.RED); snackbar.show(); } else { postComment(comment, marker.getSnippet()); } } }); builder.setView(dialogLayout); builder.create().show(); } else if (marker.getTitle().contains("safezone")) { /** * If the marker type is safezone * then get the advertisement instead * of posts. */ final Safezone sz = (Safezone) marker.getTag(); /** * Layout Inflater for the * alert dialog when a marker * has been click */ LayoutInflater inflater = getLayoutInflater(); View adsDialog = inflater.inflate(R.layout.show_ads_info_window, null, false); AlertDialog.Builder builder = new AlertDialog.Builder(MapsActivity.this); ads_image = (ImageView) adsDialog.findViewById(R.id.ads); adText = (TextView) adsDialog.findViewById(R.id.adText); adTime = (TextView) adsDialog.findViewById(R.id.timestampID); adTitle = (TextView) adsDialog.findViewById(R.id.adTitle); shop_name = (TextView) adsDialog.findViewById(R.id.shop_name); String service_type = sz.getService_information_type(); String username = sz.getUsername(); System.out.print(username); if (service_type.contains("repair")) { /** * @description Get ads of every * safezone */ getAds(sz); } else if (service_type.contains("hospital")) { /** * @description Get ads of every * safezone */ getAds(sz); } else if (service_type.contains("towing")) { /** * @description Get ads of every * safezone */ getAds(sz); } else if (service_type.contains("vulcanizing")) { /** * @description Get ads of every * safezone */ getAds(sz); } else if (service_type.contains("gasoline")) { /** * @description Get ads of every * safezone */ getAds(sz); } builder.setView(adsDialog); builder.create().show(); } else { Snackbar snackbar = Snackbar.make(relativeLayout, "Current Location..", Snackbar.LENGTH_LONG); View sbView = snackbar.getView(); TextView textView = (TextView) sbView .findViewById(android.support.design.R.id.snackbar_text); textView.setTextColor( ContextCompat.getColor(getApplicationContext(), R.color.app_color)); snackbar.show(); } return true; } }); } } //end if } @Override public void onCancelled(DatabaseError databaseError) { } }); }
From source file:com.amaze.filemanager.adapters.TabSpinnerAdapter.java
@Override public View getDropDownView(final int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View row = inflater.inflate(R.layout.spinner_dropdown_layout, parent, false); ma = ((Main) fragmentTransaction.findFragmentById(R.id.content_frame)); final TextView textView = (TextView) row.findViewById(R.id.spinnerText); LinearLayout linearLayout = (LinearLayout) row.findViewById(R.id.textParent); final SharedPreferences sharedPreferences1 = PreferenceManager.getDefaultSharedPreferences(context); String skin = sharedPreferences1.getString("skin_color", "#5677fc"); final int spinner_current = sharedPreferences1.getInt("spinner_selected", 0); ImageButton imageButton = (ImageButton) row.findViewById(R.id.spinnerButton); if (items.get(position).equals("/")) textView.setText(R.string.rootdirectory); else// ww w .j ava 2s . co m textView.setText(new File(items.get(position)).getName()); imageButton.setBackgroundColor(Color.parseColor(skin)); if (position == spinner_current) { textView.setTextColor(Color.parseColor(skin)); textView.setTypeface(null, Typeface.BOLD); } linearLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { hideSpinnerDropDown(spinner); if (position == spinner_current) { } else { TabHandler tabHandler1 = new TabHandler(context, null, null, 1); Tab tab = tabHandler1.findTab(position); String name = tab.getPath(); //Toast.makeText(getActivity(), name, Toast.LENGTH_SHORT).show(); sharedPreferences1.edit().putString("current", name).apply(); sharedPreferences1.edit().putInt("spinner_selected", position).apply(); Main ma = ((Main) fragmentTransaction.findFragmentById(R.id.content_frame)); ma.loadlist(new File(tab.getPath()), false); Animation animationLeft = AnimationUtils.loadAnimation(getContext(), R.anim.tab_selection_left); Animation animationRight = AnimationUtils.loadAnimation(getContext(), R.anim.tab_selection_right); if (position < spinner_current) { ma.listView.setAnimation(animationLeft); ma.gridView.setAnimation(animationLeft); } else { ma.listView.setAnimation(animationRight); ma.gridView.setAnimation(animationRight); } } } }); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { TabHandler tabHandler = new TabHandler(context, null, null, 1); Tab tab = tabHandler.findTab(position); if (position > spinner_current) { //Toast.makeText(getContext(), "Closed", Toast.LENGTH_SHORT).show(); items.remove(position); int old_tab = tab.getTab(); int a; for (a = old_tab; a < tabHandler.getTabsCount() - 1; a++) { int new_tab = a + 1; Tab tab1 = tabHandler.findTab(new_tab); String next_label = tab1.getLabel(); String next_path = tab1.getPath(); tabHandler.updateTab(new Tab(a, next_label, next_path)); } tabHandler.deleteTab(tabHandler.getTabsCount() - 1); hideSpinnerDropDown(spinner); } else if (position < spinner_current) { // Toast.makeText(getContext(), "Closed", Toast.LENGTH_SHORT).show(); items.remove(position); int old_tab = tab.getTab(); int a; for (a = old_tab; a < tabHandler.getTabsCount() - 1; a++) { int new_tab = a + 1; Tab tab1 = tabHandler.findTab(new_tab); String next_label = tab1.getLabel(); String next_path = tab1.getPath(); tabHandler.updateTab(new Tab(a, next_label, next_path)); } tabHandler.deleteTab(tabHandler.getTabsCount() - 1); int older_spinner_selected = sharedPreferences1.getInt("spinner_selected", 0); older_spinner_selected--; sharedPreferences1.edit().putInt("spinner_selected", older_spinner_selected).apply(); hideSpinnerDropDown(spinner); } else if (position == spinner_current) { if (tabHandler.getTabsCount() == 1) { // Toast.makeText(getContext(), "exits the app", Toast.LENGTH_SHORT).show(); ma.home(); } else if (tabHandler.getTabsCount() - 1 > position) { items.remove(position); int old_tab = tab.getTab(); int a; for (a = old_tab; a < tabHandler.getTabsCount() - 1; a++) { int new_tab = a + 1; Tab tab1 = tabHandler.findTab(new_tab); String next_label = tab1.getLabel(); String next_path = tab1.getPath(); tabHandler.updateTab(new Tab(a, next_label, next_path)); } tabHandler.deleteTab(tabHandler.getTabsCount() - 1); Tab tab1 = tabHandler.findTab(spinner_current); ma.loadlist(new File(tab1.getPath()), false); } else if (tabHandler.getTabsCount() - 1 == position) { items.remove(position); tabHandler.deleteTab(tabHandler.getTabsCount() - 1); int older_spinner_selected = sharedPreferences1.getInt("spinner_selected", 0); older_spinner_selected--; sharedPreferences1.edit().putInt("spinner_selected", older_spinner_selected).apply(); Tab tab1 = tabHandler.findTab(older_spinner_selected); Main ma = ((Main) fragmentTransaction.findFragmentById(R.id.content_frame)); ma.loadlist(new File(tab1.getPath()), false); } } } }); return row; }
From source file:com.bhatworks.android.slidingtab.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}./*from w w w .jav a 2 s . c o m*/ */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); textView.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); textView.setAllCaps(true); int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); if (mTabColor != null) { textView.setTextColor(mTabColor); } return textView; }
From source file:com.codeterps.streetfighterframedojo.ui.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 w ww .ja v a2 s . co m 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; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setTextColor(mTextColor); tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.b44t.ui.ActionBar.BottomSheet.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Window window = getWindow();//w w w .jav a 2 s . c om window.setWindowAnimations(R.style.DialogNoAnimation); setContentView(container, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); if (containerView == null) { containerView = new FrameLayout(getContext()) { @Override public boolean hasOverlappingRendering() { return false; } }; containerView.setBackgroundDrawable(shadowDrawable); containerView.setPadding(backgroundPaddingLeft, (applyTopPadding ? AndroidUtilities.dp(8) : 0) + backgroundPaddingTop, backgroundPaddingLeft, (applyBottomPadding ? AndroidUtilities.dp(8) : 0)); } if (Build.VERSION.SDK_INT >= 21) { containerView.setFitsSystemWindows(true); } containerView.setVisibility(View.INVISIBLE); container.addView(containerView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM)); if (customView != null) { if (customView.getParent() != null) { ViewGroup viewGroup = (ViewGroup) customView.getParent(); viewGroup.removeView(customView); } containerView.addView(customView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); } else { int topOffset = 0; if (title != null) { TextView titleView = new TextView(getContext()); titleView.setLines(1); titleView.setSingleLine(true); titleView.setText(title); titleView.setTextColor(0xff757575); titleView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleView.setEllipsize(TextUtils.TruncateAt.MIDDLE); titleView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), AndroidUtilities.dp(8)); titleView.setGravity(Gravity.CENTER_VERTICAL); containerView.addView(titleView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48)); titleView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); topOffset += 48; } if (items != null) { FrameLayout rowLayout = null; int lastRowLayoutNum = 0; for (int a = 0; a < items.length; a++) { BottomSheetCell cell = new BottomSheetCell(getContext(), 0); cell.setTextAndIcon(items[a], itemIcons != null ? itemIcons[a] : 0); containerView.addView(cell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP, 0, topOffset, 0, 0)); topOffset += 48; cell.setTag(a); cell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismissWithButtonClick((Integer) v.getTag()); } }); itemViews.add(cell); } } } WindowManager.LayoutParams params = window.getAttributes(); params.width = ViewGroup.LayoutParams.MATCH_PARENT; params.gravity = Gravity.TOP | Gravity.LEFT; params.dimAmount = 0; params.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; if (!focusable) { params.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } params.height = ViewGroup.LayoutParams.MATCH_PARENT; window.setAttributes(params); }
From source file:com.adarshahd.indianrailinfo.donate.TrainDetails.java
private void createTableLayoutTrainFare() { if (mPage.contains("SORRY")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Not a valid class, Please select a different class and try again."); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews();/*from w w w .j a v a 2s . c o m*/ mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ISL Of")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ERROR")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("Network Connectivity")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("unavailable")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText( "Response from server:\n\nYour request could not be processed now. \nPlease try again later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) { Iterator iterator = null; try { iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("TrainDetails", mPage); } mListFr = new ArrayList<List<String>>(); List<String> list; Element tmp; while (iterator.hasNext()) { tmp = (Element) iterator.next(); list = new ArrayList<String>(); list.add(tmp.select("td").get(0).text()); list.add(tmp.select("td").get(1).text()); mListFr.add(list); } mDetails = new Details(mListFr, TrainEnquiry.FARE, mTrainNumber); } else { mListFr = mDetails.getList(); } mTblLayoutFr = new TableLayout(mActivity); TableRow row; TextView tv1, tv2; mTblLayoutFr.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < mListFr.size(); i++) { row = new TableRow(mActivity); tv1 = new TextView(mActivity); tv2 = new TextView(mActivity); tv1.setText(" " + mListFr.get(i).get(0)); tv2.setText(" " + mListFr.get(i).get(1)); tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv1.setPadding(5, 5, 5, 5); tv2.setPadding(5, 5, 5, 5); /*tv2.setBackgroundResource(R.drawable.card_divider); tv3.setBackgroundResource(R.drawable.card_divider); tv4.setBackgroundResource(R.drawable.card_divider);*/ row.addView(tv1); row.addView(tv2); row.setBackgroundResource(R.drawable.button_selector); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); mTblLayoutFr.addView(row); } LinearLayout ll = new LinearLayout(mActivity); ScrollView scrollView = new ScrollView(mActivity); TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Fare details:"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(textViewTrnDtls); ll.addView(mTblLayoutFr); scrollView.addView(ll); mFrameLayout.removeAllViews(); mFrameLayout.addView(scrollView); if (mDialog.isShowing()) { mDialog.cancel(); } }
From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java
private void displayArtistInfo_bk(JSONObject j) throws JSONException { if (imageLoader == null) imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) imageLoader.init(config);/* w ww .j ava 2 s. com*/ Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString()); JSONObject j_artist_info = j.getJSONObject("artist"); tArtistName.setText(j_artist_info.getString("name")); final JSONObject urls = j_artist_info.optJSONObject("urls"); final JSONArray videos = j_artist_info.optJSONArray("video"); final JSONArray images = j_artist_info.optJSONArray("images"); final String fm_image = j.optString("fm_image"); final JSONArray available_images = new JSONArray(); ArrayList<String> image_urls = new ArrayList<String>(); if (fm_image != null) { image_urls.add(fm_image); } Log.i("musicInfo", images.toString()); if (images != null) { for (int i = 0; i < images.length(); i++) { JSONObject image = images.getJSONObject(i); int width = image.optInt("width", 0); int height = image.optInt("height", 0); String url = image.optString("url", ""); Log.i("musicInfo", i + ": " + url); if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) { //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) { image_urls.add(url); Log.i("musicInfo", "Selected: " + url); //available_images.put(image); } } int random = (int) (Math.random() * image_urls.size()); final String f_url = image_urls.get(random); //int random = (int) (Math.random() * available_images.length()); //final JSONObject fImage = available_images.length()>0?available_images.getJSONObject(random > images.length() ? 0 : random):images.getJSONObject(0); Log.i("musicInfo", "Total image#=" + available_images.length() + " Selected image#=" + random + " " + f_url); imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { lLinkList.removeAllViews(); //String attr = fImage.optJSONObject("license").optString("attribution"); //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr)); if (urls != null) { String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url", "twitter_url" }; for (int i = 0; i < jsonName.length; i++) { if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) { Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i])); TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); switch (jsonName[i]) { case "official_url": tv.setText("HOME."); break; case "wikipedia_url": tv.setText("WIKI."); break; case "mb_url": tv.setText("Music Brainz."); break; case "lastfm_url": tv.setText("Last FM."); break; case "twitter_url": tv.setText("Twitter."); break; } try { tv.setTag(urls.getString(jsonName[i])); } catch (JSONException e) { e.printStackTrace(); } tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse((String) v.getTag())); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Toast.makeText(getApplicationContext(), "Open the Link...", Toast.LENGTH_SHORT).show(); //finish(); } }); lLinkList.addView(tv); } } } else { TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setText("Sorry, No Link Here..."); lLinkList.addView(tv); } if (videos != null) { jVideoArray = videos; mAdapter = new StaggeredViewAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, generateImageData(videos)); //if (mData == null) { mData = generateImageData(videos); //} //mAdapter.clear(); for (JSONObject data : mData) { mAdapter.add(data); } mGridView.setAdapter(mAdapter); } else { } adjBottomColor(((ImageView) view).getDrawable()); } @Override public void onLoadingCancelled(String imageUri, View view) { } }); } }
From source file:com.android.ngynstvn.slidingtablayouttest.ui.tabs.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;/* w ww . java2s. c o m*/ 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; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextColor(getResources().getColor(R.color.white_100)); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }