List of usage examples for android.widget TextView setSingleLine
@android.view.RemotableViewMethod public void setSingleLine(boolean singleLine)
From source file:liqui.droid.activity.Base.java
/** * Creates the breadcrumb.// w w w . j a v a2s .c om * * @param subTitle the sub title * @param breadCrumbHolders the bread crumb holders */ public void createBreadcrumb(String subTitle, BreadCrumbHolder... breadCrumbHolders) { if (breadCrumbHolders != null) { LinearLayout llPart = (LinearLayout) this.findViewById(R.id.ll_part); for (int i = 0; i < breadCrumbHolders.length; i++) { TextView tvBreadCrumb = new TextView(getApplication()); SpannableString part = new SpannableString(breadCrumbHolders[i].getLabel()); part.setSpan(new UnderlineSpan(), 0, part.length(), 0); tvBreadCrumb.append(part); tvBreadCrumb.setTag(breadCrumbHolders[i]); tvBreadCrumb.setBackgroundResource(R.drawable.default_link); tvBreadCrumb.setTextAppearance(getApplication(), R.style.default_text_small); tvBreadCrumb.setSingleLine(true); tvBreadCrumb.setOnClickListener(new OnClickBreadCrumb(this)); llPart.addView(tvBreadCrumb); if (i < breadCrumbHolders.length - 1) { TextView slash = new TextView(getApplication()); slash.setText(" / "); slash.setTextAppearance(getApplication(), R.style.default_text_small); llPart.addView(slash); } } } ScrollingTextView tvSubtitle = (ScrollingTextView) this.findViewById(R.id.tv_subtitle); tvSubtitle.setText(subTitle); }
From source file:com.example.drugsformarinemammals.Dose_Information.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dose_information); Bundle parameters = this.getIntent().getExtras(); if (parameters != null) { TextView textViewDrug = (TextView) findViewById(R.id.textView_drug_name); textViewDrug.setTypeface(Typeface.SANS_SERIF); textViewDrug.setText(parameters.getString("drugName")); TextView textViewGroupName = (TextView) findViewById(R.id.textView_group_name); textViewGroupName.setTypeface(Typeface.SANS_SERIF); textViewGroupName.setText("(" + parameters.getString("groupName") + ")"); layoutDose = (LinearLayout) findViewById(R.id.layout_dose); helper = new Handler_Sqlite(this); SQLiteDatabase db = helper.open(); ArrayList<String> notes_index = new ArrayList<String>(); ArrayList<String> references = new ArrayList<String>(); ArrayList<Article_Reference> references_index = new ArrayList<Article_Reference>(); reference_index = 'a'; ArrayList<String> families = new ArrayList<String>(); if (db != null) families = helper.read_animals_family(parameters.getString("drugName"), parameters.getString("groupName")); for (int l = 0; l < families.size(); l++) { //if exists animals family TextView textView_family = new TextView(this); textView_family.setText(families.get(l)); textView_family.setTextSize(20); textView_family.setTextColor(getResources().getColor(R.color.darkGray)); textView_family.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.leftMargin = 30;//from w w w. ja v a 2 s . c om params.topMargin = 20; layoutDose.addView(textView_family, layoutDose.getChildCount(), params); //dose information LinearLayout layout_dose_information = new LinearLayout(this); layout_dose_information.setOrientation(LinearLayout.VERTICAL); layout_dose_information .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); layout_dose_information.setBackgroundResource(R.drawable.layout_border); ArrayList<Dose_Data> dose = new ArrayList<Dose_Data>(); if (db != null) { dose = helper.read_dose_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "", ""); } TableLayout doseTable = new TableLayout(this); doseTable.setStretchAllColumns(true); screenWidth = Integer.parseInt(getString(R.string.display)); TableRow header = new TableRow(this); //Amount TextView textView_dose_amount = new TextView(this); textView_dose_amount.setText("Dose"); textView_dose_amount.setSingleLine(true); textView_dose_amount.setTextColor(getResources().getColor(R.color.darkGray)); textView_dose_amount.setTextSize(17); textView_dose_amount.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsAmount.gravity = Gravity.CENTER; header.addView(textView_dose_amount, paramsAmount); //Posology TextView textView_posology = new TextView(this); if (screenWidth >= 720) textView_posology.setText("Posology"); else textView_posology.setText("Pos"); textView_posology.setSingleLine(true); textView_posology.setTextColor(getResources().getColor(R.color.darkGray)); textView_posology.setTextSize(17); textView_posology.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsPosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsPosology.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology")) || screenWidth >= 600) header.addView(textView_posology, paramsPosology); //Route TextView textView_route = new TextView(this); textView_route.setText("Route"); textView_route.setSingleLine(true); textView_route.setTextColor(getResources().getColor(R.color.darkGray)); textView_route.setTextSize(17); textView_route.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsRoute = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsRoute.gravity = Gravity.CENTER; header.addView(textView_route, paramsRoute); //Reference TextView textView_reference = new TextView(this); textView_reference.setText("Ref"); textView_reference.setSingleLine(true); textView_reference.setTextColor(getResources().getColor(R.color.darkGray)); textView_reference.setTextSize(17); textView_reference.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsReference = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsReference.gravity = Gravity.CENTER; header.addView(textView_reference, paramsReference); //Specific Note TextView textView_specific_note = new TextView(this); textView_specific_note.setText("Note"); textView_specific_note.setSingleLine(true); textView_specific_note.setTextColor(getResources().getColor(R.color.darkGray)); textView_specific_note.setTextSize(17); textView_specific_note.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); TableRow.LayoutParams paramsSpecificNote = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNote.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) || screenWidth >= 600) header.addView(textView_specific_note, paramsSpecificNote); TableRow doseData = new TableRow(this); doseTable.addView(header); //General Dose if (dose.size() > 0) { show_dose(dose, doseTable, doseData, parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "", "", notes_index, references, references_index); } HashMap<String, ArrayList<String>> animal_information = new HashMap<String, ArrayList<String>>(); if (db != null) animal_information = helper.read_animal_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l)); String animalName; Object[] animalsName = animal_information.keySet().toArray(); for (int i = 0; i < animalsName.length; i++) { doseData = new TableRow(this); //if exists animal name animalName = (String) animalsName[i]; TextView textView_animal_name = new TextView(this); if (!animalName.equals("")) { //Animal name textView_animal_name.setText(animalName); textView_animal_name.setSingleLine(false); textView_animal_name.setTextColor(getResources().getColor(R.color.darkGray)); textView_animal_name.setTextSize(15); textView_animal_name.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); } //if exists category ArrayList<String> categories = animal_information.get(animalName); String animalCategory; for (int j = 0; j < categories.size(); j++) { animalCategory = categories.get(j); if (!animalCategory.equals("")) { //Animal category TextView textView_animal_category = new TextView(this); textView_animal_category.setText(animalCategory); textView_animal_category.setSingleLine(false); textView_animal_category.setTextColor(Color.BLACK); textView_animal_category.setTextSize(15); textView_animal_category.setTypeface(Typeface.SANS_SERIF); if (!animalName.equals("")) { if (j == 0) { TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); if (screenWidth < 600 && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) paramsAnimalName.span = 3; else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") || isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note"))) paramsAnimalName.span = 4; else paramsAnimalName.span = 5; doseData.addView(textView_animal_name, paramsAnimalName); doseTable.addView(doseData); } if (db != null) dose = helper.read_dose_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory); doseData = new TableRow(this); textView_animal_category.setTypeface(Typeface.SANS_SERIF, Typeface.ITALIC); TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); if (screenWidth < 600 && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) paramsCategoryName.span = 3; else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") || isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note"))) paramsCategoryName.span = 4; else paramsCategoryName.span = 5; if (screenWidth < 600) paramsCategoryName.leftMargin = 15; else if (screenWidth >= 600 && screenWidth < 720) paramsCategoryName.leftMargin = 20; else paramsCategoryName.leftMargin = 30; doseData.addView(textView_animal_category, paramsCategoryName); doseTable.addView(doseData); doseData = new TableRow(this); show_dose(dose, doseTable, doseData, parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory, notes_index, references, references_index); doseData = new TableRow(this); } else { if (db != null) dose = helper.read_dose_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory); textView_animal_category.setTypeface(Typeface.SANS_SERIF, Typeface.DEFAULT_BOLD.getStyle()); textView_animal_category.setTextColor(getResources().getColor(R.color.darkGray)); TableRow.LayoutParams paramsCategoryName = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); if (screenWidth < 600 && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) paramsCategoryName.span = 3; else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") || isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note"))) paramsCategoryName.span = 4; else paramsCategoryName.span = 5; doseData.addView(textView_animal_category, paramsCategoryName); doseTable.addView(doseData); doseData = new TableRow(this); show_dose(dose, doseTable, doseData, parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory, notes_index, references, references_index); doseData = new TableRow(this); } } if (!animalName.equals("") && animalCategory.equals("")) { if (db != null) dose = helper.read_dose_information(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory); TableRow.LayoutParams paramsAnimalName = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); if (screenWidth < 600 && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") && isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note")) paramsAnimalName.span = 3; else if (screenWidth < 600 && (isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Posology") || isCollapsed(parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), "Note"))) paramsAnimalName.span = 4; else paramsAnimalName.span = 5; doseData.addView(textView_animal_name, paramsAnimalName); doseTable.addView(doseData); doseData = new TableRow(this); show_dose(dose, doseTable, doseData, parameters.getString("drugName"), parameters.getString("groupName"), families.get(l), animalName, animalCategory, notes_index, references, references_index); doseData = new TableRow(this); } } } LinearLayout.LayoutParams paramsDoseTable = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); if (screenWidth >= 600) { paramsDoseTable.topMargin = 5; paramsDoseTable.leftMargin = 50; paramsDoseTable.rightMargin = 50; } else { paramsDoseTable.topMargin = 5; paramsDoseTable.leftMargin = 60; paramsDoseTable.rightMargin = 30; } layout_dose_information.addView(doseTable, paramsDoseTable); layoutDose.addView(layout_dose_information, layoutDose.getChildCount()); } helper.close(); //Notes additionalInformationInterface("GENERAL NOTES", parameters.getString("drugName"), parameters.getString("groupName"), notes_index, references_index); additionalInformationInterface("SPECIFIC NOTES", parameters.getString("drugName"), parameters.getString("groupName"), notes_index, references_index); //References additionalInformationInterface("REFERENCES", parameters.getString("drugName"), parameters.getString("groupName"), notes_index, references_index); } }
From source file:org.michaelbel.bottomsheet.BottomSheet.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (backgroundColor == 0) { backgroundColor = darkTheme ? 0xFF424242 : 0xFFFFFFFF; }/*w w w. j a v a 2 s.c o m*/ if (titleTextColor == 0) { titleTextColor = darkTheme ? 0xB3FFFFFF : 0x8A000000; } if (itemTextColor == 0) { itemTextColor = darkTheme ? 0xFFFFFFFF : 0xDE000000; } if (iconColor == 0) { iconColor = darkTheme ? 0xFFFFFFFF : 0x8A000000; } if (itemSelector == 0) { itemSelector = darkTheme ? R.drawable.selectable_dark : R.drawable.selectable_light; } Window window = getWindow(); 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; } }; if (Build.VERSION.SDK_INT >= 16) { containerView.setBackground(shadowDrawable); } else { containerView.setBackgroundDrawable(shadowDrawable); } containerView.setPadding(0, backgroundPaddingTop, 0, Utils.dp(getContext(), 8)); } if (Build.VERSION.SDK_INT >= 21) { containerView.setFitsSystemWindows(true); } containerView.setVisibility(View.INVISIBLE); containerView.setBackgroundColor(backgroundColor); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; containerView.setLayoutParams(params); container.addView(containerView, 0); if (customView != null) { if (customView.getParent() != null) { ViewGroup viewGroup = (ViewGroup) customView.getParent(); viewGroup.removeView(customView); } FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams) containerView.getLayoutParams(); params1.width = ViewGroup.LayoutParams.MATCH_PARENT; params1.height = ViewGroup.LayoutParams.WRAP_CONTENT; params1.gravity = Gravity.START | Gravity.TOP; containerView.addView(customView, params1); } else { int topOffset = 0; if (titleText != null) { TextView titleTextView = new TextView(getContext()); titleTextView.setLines(1); titleTextView.setMaxLines(1); titleTextView.setSingleLine(true); titleTextView.setText(titleText); titleTextView.setTextColor(titleTextColor); titleTextView.setEllipsize(TextUtils.TruncateAt.MIDDLE); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleTextView.setGravity(Gravity.CENTER_VERTICAL); FrameLayout.LayoutParams params0 = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, Utils.dp(getContext(), 56)); params0.gravity = Gravity.START | Gravity.TOP; params0.leftMargin = Utils.dp(getContext(), 16); params0.rightMargin = Utils.dp(getContext(), 16); titleTextView.setLayoutParams(params0); containerView.addView(titleTextView); titleTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); topOffset += 56; } BottomSheetAdapter adapter = new BottomSheetAdapter(); if (mItems != null || mItemsRes != null) { if (contentType == LIST) { FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params2.topMargin = Utils.dp(getContext(), topOffset); ListView listView = new ListView(getContext()); listView.setSelector(itemSelector); listView.setDividerHeight(0); listView.setAdapter(adapter); listView.setDrawSelectorOnTop(true); listView.setVerticalScrollBarEnabled(false); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { dismissWithButtonClick(i); } }); listView.setLayoutParams(params2); containerView.addView(listView); } else if (contentType == GRID) { FrameLayout.LayoutParams params3 = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); GridView gridView = new GridView(getContext()); gridView.setSelector(itemSelector); gridView.setAdapter(adapter); gridView.setNumColumns(3); gridView.setVerticalScrollBarEnabled(false); gridView.setVerticalSpacing(Utils.dp(getContext(), 16)); gridView.setPadding(Utils.dp(getContext(), 0), Utils.dp(getContext(), topOffset + 8), Utils.dp(getContext(), 0), Utils.dp(getContext(), 16)); gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { dismissWithButtonClick(i); } }); gridView.setLayoutParams(params3); containerView.addView(gridView); } if (mItems != null) { for (int a = 0; a < mItems.length; a++) { items.add(new Item(mItems[a], mIcons != null ? mIcons[a] : 0)); } } else { for (int a = 0; a < mItemsRes.length; a++) { items.add(new Item(getContext().getText(mItemsRes[a]), mIcons != null ? mIcons[a] : 0)); } } adapter.notifyDataSetChanged(); } } WindowManager.LayoutParams params4 = window.getAttributes(); params4.width = ViewGroup.LayoutParams.MATCH_PARENT; params4.gravity = Gravity.TOP | Gravity.START; params4.dimAmount = 0; params4.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; if (!focusable) { params4.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; } params4.height = ViewGroup.LayoutParams.MATCH_PARENT; window.setAttributes(params4); }
From source file:net.gnu.common.view.SlidingHorizontalScroll.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); final int count = adapter.getCount(); for (int i = 0; i < count; i++) { View tabView = null;//w ww. ja va 2 s . 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, mTabStripLinearLayout, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if ((fra == null || fra.circular()) && (i == 0 || i == count - 1) && count > 1) { final int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); tabView.setPadding(0, padding >> 2, 0, padding >> 2); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setEllipsize(TextUtils.TruncateAt.MIDDLE); tabTitleView.setMaxEms(9); tabTitleView.setSingleLine(true); tabView.setOnClickListener(tabClickListener); tabTitleView.setTextColor(ExplorerActivity.TEXT_COLOR); mTabStripLinearLayout.addView(tabView); } mTabStripLinearLayout.setBackgroundColor(ExplorerActivity.BASE_BACKGROUND); }
From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private void showThemeDialog() { final int checkedItem = Arrays.asList(Preferences.VALUES_THEME).indexOf(Preferences.getTheme()); Resources resources = getResources(); float density = ResourceUtils.obtainDensity(resources); ScrollView scrollView = new ScrollView(this); LinearLayout outer = new LinearLayout(this); outer.setOrientation(LinearLayout.VERTICAL); int outerPadding = (int) (16f * density); outer.setPadding(outerPadding, outerPadding, outerPadding, outerPadding); scrollView.addView(outer, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); final AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.action_change_theme) .setView(scrollView).setNegativeButton(android.R.string.cancel, null).create(); View.OnClickListener listener = v -> { int index = (int) v.getTag(); if (index != checkedItem) { Preferences.setTheme(Preferences.VALUES_THEME[index]); recreate();/* w w w .j a v a2 s. co m*/ } dialog.dismiss(); }; int circleSize = (int) (56f * density); int itemPadding = (int) (12f * density); LinearLayout inner = null; for (int i = 0; i < Preferences.ENTRIES_THEME.length; i++) { if (i % 3 == 0) { inner = new LinearLayout(this); inner.setOrientation(LinearLayout.HORIZONTAL); outer.addView(inner, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); } LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setGravity(Gravity.CENTER); layout.setBackgroundResource( ResourceUtils.getResourceId(this, android.R.attr.selectableItemBackground, 0)); layout.setPadding(0, itemPadding, 0, itemPadding); layout.setOnClickListener(listener); layout.setTag(i); inner.addView(layout, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); View view = new View(this); int colorBackgroundAttr = Preferences.VALUES_THEME_COLORS[i][0]; int colorPrimaryAttr = Preferences.VALUES_THEME_COLORS[i][1]; int colorAccentAttr = Preferences.VALUES_THEME_COLORS[i][2]; Resources.Theme theme = getResources().newTheme(); theme.applyStyle(Preferences.VALUES_THEME_IDS[i], true); TypedArray typedArray = theme .obtainStyledAttributes(new int[] { colorBackgroundAttr, colorPrimaryAttr, colorAccentAttr }); view.setBackground(new ThemeChoiceDrawable(typedArray.getColor(0, 0), typedArray.getColor(1, 0), typedArray.getColor(2, 0))); typedArray.recycle(); if (C.API_LOLLIPOP) { view.setElevation(6f * density); } layout.addView(view, circleSize, circleSize); TextView textView = new TextView(this, null, android.R.attr.textAppearanceListItem); textView.setSingleLine(true); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setText(Preferences.ENTRIES_THEME[i]); if (C.API_LOLLIPOP) { textView.setAllCaps(true); textView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12f); } else { textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14f); } textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setPadding(0, (int) (8f * density), 0, 0); layout.addView(textView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); if (i + 1 == Preferences.ENTRIES_THEME.length && Preferences.ENTRIES_THEME.length % 3 != 0) { if (Preferences.ENTRIES_THEME.length % 3 == 1) { inner.addView(new View(this), 0, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); } inner.addView(new View(this), new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); } } dialog.show(); }
From source file:pro.dbro.bart.TheActivity.java
public void displayEtdResponse(etdResponse etdResponse) { if (timer != null) timer.cancel(); // cancel previous timer long now = new Date().getTime(); timerViews = new ArrayList(); // release old ETA text views maxTimer = 0; // reset maxTimer fareTv.setText(""); fareTv.setVisibility(View.GONE); tableLayout.removeAllViews();//w w w. j a va2 s . com String lastDestination = ""; // Display the alert ImageView and create a click listener to display alert html if (etdResponse.message != null) { // If the response message matches the response for a closed station, // Display "Closed for tonight" and time of next train, if available. if (etdResponse.message.contains("No data matched your criteria.")) { String message = "This station is closed for tonight"; TextView specialScheduleTextView = (TextView) View.inflate(c, R.layout.tabletext, null); specialScheduleTextView.setPadding(0, 0, 0, 0); if (etdResponse.etds != null && etdResponse.etds.size() > 0) { Date nextTrain = new Date(etdResponse.date.getTime() + ((etd) etdResponse.etds.get(0)).minutesToArrival * 60 * 1000); SimpleDateFormat sdf = new SimpleDateFormat("KK:MM a"); message += ". Next train at " + sdf.format(nextTrain); } specialScheduleTextView.setText(message); tableLayout.addView(specialScheduleTextView); } else { // Create an imageview that spawns an alertDialog with BART message ImageView specialScheduleImageView = (ImageView) View.inflate(c, R.layout.specialschedulelayout, null); // Tag the specialScheduleImageView with the message html specialScheduleImageView.setTag(Html.fromHtml(etdResponse.message)); // Set the OnClickListener for the specialScheduleImageView to display the tagged message html specialScheduleImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { TextView specialScheduleTv = (TextView) View.inflate(c, R.layout.tabletext, null); specialScheduleTv.setPadding(0, 0, 0, 0); specialScheduleTv.setText(Html.fromHtml(arg0.getTag().toString())); specialScheduleTv.setTextSize(16); specialScheduleTv.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(c).setTitle("Station Alerts").setIcon(R.drawable.warning) .setView(specialScheduleTv).setPositiveButton("Bummer", null).show(); } }); tableLayout.addView(specialScheduleImageView); } } TableRow tr = (TableRow) View.inflate(c, R.layout.tablerow_right, null); LinearLayout destinationRow = (LinearLayout) View.inflate(c, R.layout.destination_row, null); //TextView timeTv =(TextView) View.inflate(c, R.layout.tabletext, null); int numAlt = 0; for (int x = 0; x < etdResponse.etds.size(); x++) { if (etdResponse.etds.get(x) == null) break; etd thisEtd = (etd) etdResponse.etds.get(x); if (thisEtd.destination != lastDestination) { // new train destination numAlt = 0; tr = (TableRow) View.inflate(c, R.layout.tablerow_right, null); tr.setPadding(0, 0, 10, 0); destinationRow = (LinearLayout) View.inflate(c, R.layout.destination_row, null); TextView destinationTv = (TextView) View.inflate(c, R.layout.destinationlayout, null); if (x == 0) destinationTv.setPadding(0, 0, 0, 0); //bullet.setWidth(200); //destinationTv.setPadding(0, 0, 0, 0); destinationTv.setTextSize(28); destinationTv.setText(thisEtd.destination); TextView timeTv = (TextView) View.inflate(c, R.layout.tabletext, null); // Display eta less than 1m as "<1" if (thisEtd.minutesToArrival == 0) timeTv.setText("<1"); else timeTv.setText(String.valueOf(thisEtd.minutesToArrival)); timeTv.setSingleLine(false); timeTv.setTextSize(36); //timeTv.setPadding(30, 0, 0, 0); long counterTime = thisEtd.minutesToArrival * 60 * 1000; if (counterTime > maxTimer) { maxTimer = counterTime; } timeTv.setTag(counterTime + now); timerViews.add(timeTv); //new ViewCountDownTimer(timeTv, counterTime, 60*1000).start(); //text.setWidth(120); destinationRow.addView(destinationTv); //tr.addView(destinationTv); tr.addView(timeTv); tr.setTag(thisEtd); tableLayout.addView(destinationRow); tableLayout.addView(tr); tr.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { int index = tableLayout.indexOfChild(arg0); // index of clicked view. Expanded view will always be +1 etd thisEtd = (etd) arg0.getTag(); if (!thisEtd.isExpanded) { // if route not expanded thisEtd.isExpanded = true; LinearLayout routeDetail = (LinearLayout) View.inflate(c, R.layout.routedetail, null); TextView platformTv = (TextView) View.inflate(c, R.layout.tabletext, null); platformTv.setPadding(0, 0, 0, 0); platformTv.setText("platform " + thisEtd.platform); platformTv.setTextSize(20); routeDetail.addView(platformTv); ImageView bikeIv = (ImageView) View.inflate(c, R.layout.bikeimage, null); if (!thisEtd.bikes) bikeIv.setImageResource(R.drawable.no_bicycle); routeDetail.addView(bikeIv); tableLayout.addView(routeDetail, index + 1); } else { thisEtd.isExpanded = false; tableLayout.removeViewAt(index + 1); } } }); } else { // append next trains arrival time to existing destination display //timeTv.append(String.valueOf(", "+thisEtd.minutesToArrival)); numAlt++; TextView nextTimeTv = (TextView) View.inflate(c, R.layout.tabletext, null); //nextTimeTv.setTextSize(36-(5*numAlt)); nextTimeTv.setTextSize(36); nextTimeTv.setText(String.valueOf(thisEtd.minutesToArrival)); //nextTimeTv.setPadding(30, 0, 0, 0); if (numAlt == 1) //0xFFF06D2F C9C7C8 nextTimeTv.setTextColor(0xFFC9C7C8); else if (numAlt == 2) nextTimeTv.setTextColor(0xFFA8A7A7); long counterTime = thisEtd.minutesToArrival * 60 * 1000; nextTimeTv.setTag(counterTime + now); if (counterTime > maxTimer) { maxTimer = counterTime; } timerViews.add(nextTimeTv); //new ViewCountDownTimer(nextTimeTv, counterTime, 60*1000).start(); tr.addView(nextTimeTv); } lastDestination = thisEtd.destination; } // end for //scrolly.scrollTo(0, 0); // Avoid spamming bart.gov. Only re-ping if etd response is valid for at least 3m if (maxTimer > 1000 * 60 * 3) { timer = new ViewCountDownTimer(timerViews, "etd", maxTimer, 30 * 1000); timer.start(); } }
From source file:com.cssweb.android.base.QuoteGridActivity.java
private void AddViewItem(String paramString, int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean) { TextView localTextView = new TextView(this); float f = this.mFontSize; localTextView.setTextSize(f);/*from www . jav a 2 s . co m*/ //??4? if (paramInt2 == paramInt4 && paramInt3 == 0 && nameOrcode) { if (this.mPaint.measureText(paramString) > textWeight) localTextView.setTextSize(13); } if (n2 == paramInt2) { String str = (n1 == 0) ? paramString + low : (n1 == 1) ? paramString + top : paramString; localTextView.setText(str); } else { localTextView.setText(paramString); } localTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); localTextView.setFocusable(paramBoolean); localTextView.setOnClickListener(mClickListener); localTextView.setOnLongClickListener(mLongClickListener); localTextView.setOnTouchListener(this); //touch localTextView.setTag(paramInt2); localTextView.setEnabled(paramBoolean); localTextView.setSingleLine(false); if (paramInt4 == 0 && paramInt3 >= 0) {// localTextView.setGravity(Gravity.CENTER); int i1 = this.residTitleCol; int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(i1); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[2]); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[1]); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this)); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } if (paramInt4 != 0 && paramInt3 >= 0) { int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(this.residCol); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residScrollCol[2]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; //localTextView.setWidth(i8+20); } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; //localTextView.setWidth(i8+20); } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residScrollCol[1]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + rowHeight); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } // if ((paramInt3 == j) && (paramInt4 == l)) { // int i13 = this.residTitleScrollCol[l]; // localDrawable = localResources.getDrawable(i13); // localTextView.setTextColor(paramInt1); // localTextView.setBackgroundDrawable(localDrawable); // paramLinearLayout.addView(localTextView); // return; // } }
From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java
private TextView makeCommonTextView(boolean header) { TextView textView = new TextView(context, null, C.API_LOLLIPOP ? android.R.attr.textAppearanceListItem : android.R.attr.textAppearance); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, C.API_LOLLIPOP ? 14f : 16f); textView.setGravity(Gravity.CENTER_VERTICAL); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setSingleLine(true); if (C.API_LOLLIPOP) { textView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM); int color = textView.getTextColors().getDefaultColor(); if (header) { color &= 0x5effffff;/*from w ww . ja va2 s. c om*/ } else { color &= 0xddffffff; } textView.setTextColor(color); } return textView; }
From source file:com.juick.android.MessageMenu.java
protected void runActions() { if (!isDialogMode()) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); final CharSequence[] items = new CharSequence[menuActions.size()]; for (int j = 0; j < items.length; j++) { items[j] = menuActions.get(j).title; }//from w ww. j a v a 2s . c om builder.setItems(items, this); final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { ColorsTheme.ColorTheme colorTheme = JuickMessagesAdapter.getColorTheme(activity); ColorDrawable divider = new ColorDrawable( colorTheme.getColor(ColorsTheme.ColorKey.COMMON_BACKGROUND, 0xFFFFFFFF)); alertDialog.getListView().setDivider(divider); alertDialog.getListView().setDividerHeight(1); } }); alertDialog.show(); final ListAdapter adapter = alertDialog.getListView().getAdapter(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(activity); float menuFontScale = 1; try { menuFontScale = Float.parseFloat(sp.getString("menuFontScale", "1.0")); } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } final boolean compressedMenu = sp.getBoolean("compressedMenu", false); final boolean singleLineMenu = sp.getBoolean("singleLineMenu", false); final float finalMenuFontScale = menuFontScale; final int screenHeight = activity.getWindow().getWindowManager().getDefaultDisplay().getHeight(); alertDialog.getListView().setAdapter(new ListAdapter() { @Override public boolean areAllItemsEnabled() { return adapter.areAllItemsEnabled(); } @Override public boolean isEnabled(int position) { return adapter.isEnabled(position); } @Override public void registerDataSetObserver(DataSetObserver observer) { adapter.registerDataSetObserver(observer); } @Override public void unregisterDataSetObserver(DataSetObserver observer) { adapter.unregisterDataSetObserver(observer); } @Override public int getCount() { return items.length; } @Override public Object getItem(int position) { return adapter.getItem(position); } @Override public long getItemId(int position) { return adapter.getItemId(position); } @Override public boolean hasStableIds() { return adapter.hasStableIds(); } @Override public View getView(int position, View convertView, ViewGroup parent) { View retval = adapter.getView(position, null, parent); if (retval instanceof TextView) { TextView tv = (TextView) retval; if (compressedMenu) { int minHeight = (int) ((screenHeight * 0.7) / getCount()); tv.setMinHeight(minHeight); tv.setMinimumHeight(minHeight); } if (singleLineMenu) { tv.setSingleLine(true); tv.setEllipsize(TextUtils.TruncateAt.MIDDLE); } tv.setTextSize(22 * finalMenuFontScale); } return retval; } @Override public int getItemViewType(int position) { return adapter.getItemViewType(position); } @Override public int getViewTypeCount() { return adapter.getViewTypeCount(); } @Override public boolean isEmpty() { return adapter.isEmpty(); } }); } else { AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(activity, R.style.Theme_Sherlock)); View dialogView = activity.getLayoutInflater().inflate(R.layout.message_menu2, null); builder.setView(dialogView); builder.setCancelable(true); int width = activity.getWindowManager().getDefaultDisplay().getWidth(); View scrollView = dialogView.findViewById(R.id.scrollView); scrollView.getLayoutParams().width = (int) (width * 0.90); final AlertDialog alertDialog = builder.create(); alertDialog.setOnShowListener(new DialogInterface.OnShowListener() { @Override public void onShow(DialogInterface dialog) { //MainActivity.restyleChildrenOrWidget(alertDialog.getWindow().getDecorView()); } }); TextView messageNo = (TextView) dialogView.findViewById(R.id.message_no); messageNo.setText(listSelectedItem.getDisplayMessageNo()); Spinner openUrl = (Spinner) dialogView.findViewById(R.id.open_url); Button singleURL = (Button) dialogView.findViewById(R.id.single_url); if (urls != null && urls.size() == 1) { singleURL.setVisibility(View.VISIBLE); openUrl.setVisibility(View.GONE); SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append(urls.get(0)); sb.setSpan(new UnderlineSpan(), 0, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); singleURL.setText(sb); singleURL.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); launchURL(listSelectedItem.getMID(), urls.get(0)); } }); } else if (urls != null && urls.size() > 0) { singleURL.setVisibility(View.GONE); openUrl.setVisibility(View.VISIBLE); openUrl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position != 0) { alertDialog.dismiss(); launchURL(listSelectedItem.getMID(), urls.get(position)); } } @Override public void onNothingSelected(AdapterView<?> parent) { //To change body of implemented methods use File | Settings | File Templates. } }); urls.add(0, activity.getString(R.string.ClickToSelectURL)); openUrl.setAdapter(new BaseAdapter() { @Override public int getCount() { return urls.size(); } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { View rowView = activity.getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null); TextView textView = (TextView) rowView.findViewById(android.R.id.text1); textView.setSingleLine(false); textView.setMaxLines(5); SpannableStringBuilder sb = new SpannableStringBuilder(); sb.append(urls.get(position)); if (position == 0) { textView.setTextColor(0xFF808080); } else { sb.setSpan(new UnderlineSpan(), 0, sb.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); } textView.setText(sb); return rowView; } }); } else { openUrl.setVisibility(View.GONE); singleURL.setVisibility(View.GONE); } final String UName = listSelectedItem.User.UName; View recommendMessage = dialogView.findViewById(R.id.recommend_message); View deleteMessage = dialogView.findViewById(R.id.delete_message); View saveMessage = dialogView.findViewById(R.id.save_message); View unsaveMessage = dialogView.findViewById(R.id.unsave_message); //View subscribeUser = dialogView.findViewById(R.id.subscribe_user); View subscribeMessage = dialogView.findViewById(R.id.subscribe_message); //View unsubscribeUser = dialogView.findViewById(R.id.unsubscribe_user); View unsubscribeMessage = dialogView.findViewById(R.id.unsubscribe_message); View translateMessage = dialogView.findViewById(R.id.translate_message); View shareMessage = dialogView.findViewById(R.id.share_message); //View blacklistUser = dialogView.findViewById(R.id.blacklist_user); //View filterUser = dialogView.findViewById(R.id.filter_user); //View userBlog = dialogView.findViewById(R.id.user_blog); //View userStats = dialogView.findViewById(R.id.user_stats); View openMessageInBrowser = dialogView.findViewById(R.id.open_message_in_browser); Button userCenter = (Button) dialogView.findViewById(R.id.user_center); if (null == dialogView.findViewById(R.id.column_3)) { // only for portrait userCenter.setText("@" + listSelectedItem.User.UName + " " + userCenter.getText()); } unsubscribeMessage.setEnabled(listSelectedItem.getRID() == 0); subscribeMessage.setEnabled(listSelectedItem.getRID() == 0); unsaveMessage.setEnabled(listSelectedItem.getRID() == 0); recommendMessage.setEnabled(listSelectedItem.getRID() == 0); if (UName.equalsIgnoreCase(JuickAPIAuthorizer.getJuickAccountName(activity.getApplicationContext()))) { recommendMessage.setVisibility(View.GONE); } else { deleteMessage.setVisibility(View.GONE); } if (messagesSource instanceof SavedMessagesSource) { saveMessage.setVisibility(View.GONE); } else { unsaveMessage.setVisibility(View.GONE); } recommendMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionRecommendMessage(); } }); deleteMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionDeleteMessage(); } }); saveMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionSaveMessage(); } }); unsaveMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionUnsaveMessage(); } }); // subscribeUser.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionSubscribeUser(); // } // }); subscribeMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionSubscribeMessage(); } }); // unsubscribeUser.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionUnsubscribeUser(); // } // }); unsubscribeMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionUnsubscribeMessage(); } }); translateMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionTranslateMessage(); } }); shareMessage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionShareMessage(); } }); // blacklistUser.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionBlacklistUser(); // } // }); // filterUser.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionFilterUser(UName); // } // }); // userBlog.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionUserBlog(); // } // }); // userStats.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // alertDialog.dismiss(); // actionUserStats(); // } // }); openMessageInBrowser.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionOpenMessageInBrowser(); } }); userCenter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.dismiss(); actionUserCenter(); } }); completeInitDialogMode(alertDialog, dialogView); alertDialog.show(); } }
From source file:plugin.google.maps.GoogleMaps.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @Override// w w w .j a v a 2 s.c o m public View getInfoContents(Marker marker) { String title = marker.getTitle(); String snippet = marker.getSnippet(); if ((title == null) && (snippet == null)) { return null; } JSONObject properties = null; JSONObject styles = null; String propertyId = "marker_property_" + marker.getId(); PluginEntry pluginEntry = this.plugins.get("Marker"); PluginMarker pluginMarker = (PluginMarker) pluginEntry.plugin; if (pluginMarker.objects.containsKey(propertyId)) { properties = (JSONObject) pluginMarker.objects.get(propertyId); if (properties.has("styles")) { try { styles = (JSONObject) properties.getJSONObject("styles"); } catch (JSONException e) { } } } // Linear layout LinearLayout windowLayer = new LinearLayout(activity); windowLayer.setPadding(3, 3, 3, 3); windowLayer.setOrientation(LinearLayout.VERTICAL); LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER; windowLayer.setLayoutParams(layoutParams); //---------------------------------------- // text-align = left | center | right //---------------------------------------- int gravity = Gravity.LEFT; int textAlignment = View.TEXT_ALIGNMENT_GRAVITY; if (styles != null) { try { String textAlignValue = styles.getString("text-align"); switch (TEXT_STYLE_ALIGNMENTS.valueOf(textAlignValue)) { case left: gravity = Gravity.LEFT; textAlignment = View.TEXT_ALIGNMENT_GRAVITY; break; case center: gravity = Gravity.CENTER; textAlignment = View.TEXT_ALIGNMENT_CENTER; break; case right: gravity = Gravity.RIGHT; textAlignment = View.TEXT_ALIGNMENT_VIEW_END; break; } } catch (Exception e) { } } if (title != null) { if (title.indexOf("data:image/") > -1 && title.indexOf(";base64,") > -1) { String[] tmp = title.split(","); Bitmap image = PluginUtil.getBitmapFromBase64encodedImage(tmp[1]); image = PluginUtil.scaleBitmapForDevice(image); ImageView imageView = new ImageView(this.cordova.getActivity()); imageView.setImageBitmap(image); windowLayer.addView(imageView); } else { TextView textView = new TextView(this.cordova.getActivity()); textView.setText(title); textView.setSingleLine(false); int titleColor = Color.BLACK; if (styles != null && styles.has("color")) { try { titleColor = PluginUtil.parsePluginColor(styles.getJSONArray("color")); } catch (JSONException e) { } } textView.setTextColor(titleColor); textView.setGravity(gravity); if (VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { textView.setTextAlignment(textAlignment); } //---------------------------------------- // font-style = normal | italic // font-weight = normal | bold //---------------------------------------- int fontStyle = Typeface.NORMAL; if (styles != null) { try { if ("italic".equals(styles.getString("font-style"))) { fontStyle = Typeface.ITALIC; } } catch (JSONException e) { } try { if ("bold".equals(styles.getString("font-weight"))) { fontStyle = fontStyle | Typeface.BOLD; } } catch (JSONException e) { } } textView.setTypeface(Typeface.DEFAULT, fontStyle); windowLayer.addView(textView); } } if (snippet != null) { //snippet = snippet.replaceAll("\n", ""); TextView textView2 = new TextView(this.cordova.getActivity()); textView2.setText(snippet); textView2.setTextColor(Color.GRAY); textView2.setTextSize((textView2.getTextSize() / 6 * 5) / density); textView2.setGravity(gravity); if (VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { textView2.setTextAlignment(textAlignment); } windowLayer.addView(textView2); } return windowLayer; }