List of usage examples for android.widget TextView setTextSize
@android.view.RemotableViewMethod public void setTextSize(float size)
From source file:com.equinox.prodriver.Activities.RegisterDriverActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register_driver); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w w w . j a va 2 s. c o m getSupportActionBar().setDisplayHomeAsUpEnabled(true); context = this; appBarLayout = (AppBarLayout) findViewById(R.id.app_bar); appBarLayout.setExpanded(false, true); mainScrollView = (NestedScrollView) findViewById(R.id.content_register_driver); mainScrollView.setSmoothScrollingEnabled(true); selectorsLayouts = new ArrayList<>(); editDriver = new Driver(); preferredPlace = new PrologixPlace(); if (currentDriver == null) { getSupportActionBar().setTitle(getString(R.string.title_activity_register_driver)); if (savedInstanceState != null && savedInstanceState.getBoolean("EDITING")) { editDriver = tempDriver; if (editDriver == null) editDriver = new Driver(); } vehiclesList = new ArrayList<>(); } else { getSupportActionBar().setTitle(getString(R.string.title_activity_update_driver)); editDriver = currentDriver.clone(); if (editDriver.getPreferredAddress() != null) { preferredPlace.setAddress( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredAddress()), GeoAddress.class)); preferredPlace.setLocation( driverGson.fromJson(driverGson.toJson(editDriver.getPreferredLocation()), LatLng.class)); } } storagePermission = new PermissionManager(this); if (!storagePermission.checkReadStoragePermission()) storagePermission.getReadStoragePermission(); registerEmailHeaderFragment = RegisterEmailHeaderFragment.newInstance(editDriver); vehicleIndicator = (ImageView) findViewById(R.id.driver_vehicle_indicator); if (editDriver.getVehicles() == null) editDriver.setVehicles(new ArrayList<Vehicle>()); vehicleRecyclerAdapter = new VehicleRecyclerAdapter(context, editDriver.getVehicles(), false); if (!editDriver.getVehicles().isEmpty()) setIndicator(context, vehicleIndicator, true); if (!editDriver.getVehicles().contains(createVehicle)) { editDriver.getVehicles().add(new Vehicle()); //TODO remove this.. just for testing only /*String vehicleId = "SA-3184VLB"; DriverTask driverTask = new DriverTask(vehicleFetcher, "en"); driverTask.getVehicle.execute(vehicleId);*/ } vehicleListView = (RecyclerView) findViewById(R.id.vehicle_list_view); vehicleListView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)); vehicleListView.setHasFixedSize(true); vehicleListView.setAdapter(vehicleRecyclerAdapter); vehicleListView.setNestedScrollingEnabled(false); licenseIndicator = (ImageView) findViewById(R.id.license_info_indicator); licenseValueNumber = (TextView) findViewById(R.id.license_info_number); licenseValueExpiry = (TextView) findViewById(R.id.license_info_expiry); licenseImage = (ImageView) findViewById(R.id.license_image); licenseImageLoaded = (NetworkImageView) findViewById(R.id.license_image_loaded); licenseInfoLayout = (RelativeLayout) findViewById(R.id.license_info_layout); if (editDriver.getLicenseNumber() != null) { setIndicator(context, licenseIndicator, true); licenseValueNumber.setText(editDriver.getLicenseNumber()); licenseValueExpiry.setText(StringManipulation.getFormattedDate(editDriver.getLicenseExpiry())); if (editDriver.getLicenseImage() != null) licenseImageLoaded.setImageUrl(editDriver.getLicenseImage(), DataHolder.getInstance().getImageLoader()); } if (photo1 != null) licenseImage.setImageBitmap(photo1); licenseInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra("source", REQUEST_DRIVER_LICENSE); startActivity(scanIdIntent); } }); residenceIndicator = (ImageView) findViewById(R.id.residence_info_indicator); residenceValueNumber = (TextView) findViewById(R.id.residence_info_number); residenceValueExpiry = (TextView) findViewById(R.id.residence_info_expiry); residenceValueLegalName = (TextView) findViewById(R.id.residence_info_legal_name); residenceImage = (ImageView) findViewById(R.id.residence_image); residenceImageLoaded = (NetworkImageView) findViewById(R.id.residence_image_loaded); residenceInfoLayout = (RelativeLayout) findViewById(R.id.residence_info_layout); if (editDriver.getResidenceNumber() != null) { setIndicator(context, residenceIndicator, true); residenceValueNumber.setText(editDriver.getResidenceNumber()); residenceValueLegalName.setText(editDriver.getLegalName()); if (editDriver.getResidenceImage() != null) residenceImageLoaded.setImageUrl(editDriver.getResidenceImage(), DataHolder.getInstance().getImageLoader()); } if (photo2 != null) residenceImage.setImageBitmap(photo2); residenceInfoLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent scanIdIntent = new Intent(context, CameraVisionActivity.class); scanIdIntent.putExtra(SOURCE, REQUEST_RESIDENCE_ID); startActivity(scanIdIntent); } }); nationalityIndicator = (ImageView) findViewById(R.id.nationality_indicator); nationalityValue = (TextView) findViewById(R.id.nationality_value); nationalityLayout = (RelativeLayout) findViewById(R.id.nationality_layout); nationalityProgressLayout = (LinearLayout) findViewById(R.id.nationality_progress_layout); final RelativeLayout nationalitySelector = (RelativeLayout) findViewById(R.id.nationality_selector); selectorsLayouts.add(nationalitySelector); nationalitySelectorContent = (LinearLayout) findViewById(R.id.nationality_selector_content); countryTask = new CountryTask(countryListHandler, "en"); countryTask.getCountryList.execute("en"); if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); } nationalityAuto = (InstantAutoComplete) findViewById(R.id.nationality_auto); nationalityLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (nationalitySelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, nationalitySelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, nationalityLayout.getTop()); nationalityAuto.showDropDown(); } }, 1000); } if (countryTask.getCountryList.getStatus().equals(AsyncTask.Status.RUNNING)) { nationalityProgressLayout.setVisibility(View.VISIBLE); nationalitySelectorContent.setVisibility(View.GONE); } LinearLayout okayButton = (LinearLayout) findViewById(R.id.nationality_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (editDriver.getNationality() != null) { setIndicator(context, nationalityIndicator, true); nationalityValue.setText(editDriver.getNationality().getCountryName()); addressLayout.postDelayed(new Runnable() { @Override public void run() { addressLayout.performClick(); } }, 1000); } else { setIndicator(context, nationalityIndicator, false); nationalitySelector.setVisibility(View.GONE); } } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.nationality_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { nationalitySelector.setVisibility(View.GONE); } }); } }); addressIndicator = (ImageView) findViewById(R.id.preferred_address_indicator); addressValue = (TextView) findViewById(R.id.preferred_address_value); addressLayout = (RelativeLayout) findViewById(R.id.preferred_address_layout); if (editDriver.getPreferredAddress() != null) { setIndicator(context, addressIndicator, true); preferredPlace.setAddress(transform(editDriver.getPreferredAddress())); preferredPlace.setLocation(transform(editDriver.getPreferredLocation())); addressValue.setText(preferredPlace.getAddress().getFullAddress()); } addressChooser = (FrameLayout) findViewById(R.id.preferred_address_chooser); selectorsLayouts.add(addressChooser); addressLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); try { if (addressChooser.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, addressChooser); getSupportFragmentManager().beginTransaction() .replace(R.id.preferred_address_chooser, PlaceChooserFragment.newInstance(preferredPlace, placeChooseHandler)) .commit(); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, addressLayout.getTop()); } }, 1500); } else { addressChooser.setVisibility(View.GONE); getSupportFragmentManager().popBackStack(); } } catch (Resources.NotFoundException | OutOfMemoryError ignored) { } } }); final ImageView phoneIndicator = (ImageView) findViewById(R.id.driver_phone_indicator); final TextView phoneValue = (TextView) findViewById(R.id.driver_phone_value); if (editDriver.getPhoneNumber() != null) { setIndicator(context, phoneIndicator, true); phoneValue.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); } final LinearLayout phoneSelector = (LinearLayout) findViewById(R.id.driver_phone_selector); selectorsLayouts.add(phoneSelector); phoneLayout = (RelativeLayout) findViewById(R.id.driver_phone_layout); phoneLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (phoneSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, phoneSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, phoneLayout.getTop()); } }, 1000); } final EditText input = (EditText) findViewById(R.id.phone_number); if (editDriver.getPhoneNumber() != null) input.setText(editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "")); TextView phoneCode = (TextView) findViewById(R.id.country_code); phoneCode.setText(currentCountry.getPhoneCode()); NetworkImageView countryFlag = (NetworkImageView) findViewById(R.id.country_flag); countryFlag.setImageUrl(currentCountry.getFlag(), DataHolder.getInstance().getImageLoader()); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_phone_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (!input.getText().toString().isEmpty()) { String phoneNumberEdit = currentCountry.getPhoneCode() + input.getText().toString().replaceAll(" ", ""); editDriver.setPhoneNumber(phoneNumberEdit); phoneValue.setText(phoneNumberEdit); setIndicator(context, phoneIndicator, true); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, dobLayout.getTop()); } }, 1000); } else { phoneValue.setText(getString(R.string.driver_phone_hint)); setIndicator(context, phoneIndicator, false); } phoneSelector.setVisibility(View.GONE); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_phone_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { phoneSelector.setVisibility(View.GONE); } }); } }); dobValue = (TextView) findViewById(R.id.driver_dob_value); if (editDriver.getDob() != null) dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); dobLayout = (RelativeLayout) findViewById(R.id.driver_dob_layout); dobLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final Calendar calendar = Calendar.getInstance(); if (editDriver.getDob() != null) { dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); calendar.setTimeInMillis(editDriver.getDob()); } DatePickerDialog datePickerDialog = DatePickerDialog .newInstance(new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, monthOfYear); calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth); editDriver.setDob(calendar.getTimeInMillis()); dobValue.setText(StringManipulation.getFormattedDate(editDriver.getDob())); } }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH)); datePickerDialog.show(getFragmentManager(), "Datepickerdialog"); } }); final TextView genderValue = (TextView) findViewById(R.id.driver_gender_value); if (editDriver.getGender() != null) genderValue.setText( editDriver.getGender() ? getString(R.string.male_option) : getString(R.string.female_option)); final LinearLayout genderSelector = (LinearLayout) findViewById(R.id.driver_gender_selector); selectorsLayouts.add(genderSelector); final RelativeLayout genderLayout = (RelativeLayout) findViewById(R.id.driver_gender_layout); genderLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(context); if (genderSelector.getVisibility() == View.GONE) { closeInactiveLayouts(appBarLayout, selectorsLayouts, genderSelector); mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, genderLayout.getTop()); } }, 1000); } else genderSelector.setVisibility(View.GONE); final int checkedPos = editDriver.getGender() == null ? -1 : (editDriver.getGender() ? R.id.driver_gender_male : R.id.driver_gender_female); final RadioGroup insuranceRadioGroup = (RadioGroup) findViewById(R.id.driver_gender_radio_group); if (checkedPos != -1) insuranceRadioGroup.check(checkedPos); LinearLayout okayButton = (LinearLayout) findViewById(R.id.driver_gender_okay_button); okayButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { switch (insuranceRadioGroup.getCheckedRadioButtonId()) { case R.id.driver_gender_male: editDriver.setGender(true); genderValue.setText(getString(R.string.male_option)); break; case R.id.driver_gender_female: editDriver.setGender(false); genderValue.setText(getString(R.string.female_option)); break; default: break; } mainScrollView.postDelayed(new Runnable() { @Override public void run() { mainScrollView.smoothScrollTo(0, 0); } }, 500); appBarLayout.postDelayed(new Runnable() { @Override public void run() { appBarLayout.setExpanded(true, true); } }, 1500); } }); LinearLayout cancelButton = (LinearLayout) findViewById(R.id.driver_gender_cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { genderSelector.setVisibility(View.GONE); } }); } }); //TODO image analyis on IDs (license) and cross check with profile photo1, or maybe selfie uploadCount = new AtomicInteger(0); saveDriverAction = (FloatingActionButton) findViewById(R.id.fab_save_id); saveDriverAction.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { boolean error = false; hideKeyboard(context); if (editDriver.getVehicles().size() == 1) { setIndicator(context, vehicleIndicator, false); error = true; } if (licenseImage.getDrawable() == null || editDriver.getLicenseExpiry() == null || editDriver.getLicenseNumber() == null) { setIndicator(context, licenseIndicator, false); error = true; } if (residenceImage.getDrawable() == null || editDriver.getResidenceNumber() == null) { setIndicator(context, residenceIndicator, false); error = true; } if (editDriver.getNationality() == null) { setIndicator(context, nationalityIndicator, false); error = true; } if (editDriver.getPreferredAddress() == null) { setIndicator(context, addressIndicator, false); error = true; } if (editDriver.getPhoneNumber() == null || editDriver.getPhoneNumber().isEmpty()) { setIndicator(context, phoneIndicator, false); error = true; } if (user == null && !registerEmailHeaderFragment.setCustomerValues()) error = true; if (error) Snackbar.make(view, getString(R.string.incorrect_driver_data_message), Snackbar.LENGTH_LONG) .show(); else if (user != null) { signUpAnalytics(user.getProviderId()); editDriver.getVehicles().remove(editDriver.getVehicles().size() - 1); uploadImage("driver_license_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getLicenseNumber() + ".jpg", ((BitmapDrawable) licenseImage.getDrawable()).getBitmap(), REQUEST_DRIVER_LICENSE); uploadImage("driver_residence_snapshot", "image_" + editDriver.getPhoneNumber().replace(currentCountry.getPhoneCode(), "") + "_" + editDriver.getResidenceNumber() + ".jpg", ((BitmapDrawable) residenceImage.getDrawable()).getBitmap(), REQUEST_RESIDENCE_ID); crossFade(context, findViewById(R.id.driver_progress_layout), findViewById(R.id.driver_main_layout), null); //TODO verify registration details for duplicate, correctness, etc } } }); imageUploadStatus = (TextSwitcher) findViewById(R.id.image_upload_status); imageUploadStatus.setFactory(new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView switcherTextView = new TextView(getApplicationContext()); switcherTextView.setTextSize(16); switcherTextView.setTypeface(null, Typeface.BOLD); switcherTextView.setText(getString(R.string.uploading_images)); switcherTextView.setTextColor(getResources().getColor(R.color.colorAccent)); return switcherTextView; } }); Animation animationOut = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); Animation animationIn = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); imageUploadStatus.setOutAnimation(animationOut); imageUploadStatus.setInAnimation(animationIn); }
From source file:com.example.tony.gymnasieschema.sTab.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;/*from www . j av a 2s. com*/ TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector)); tabTitleView.setTextSize(14); } }
From source file:edu.mum.ml.group7.guessasketch.android.EasyPaint.java
private void resetPredictionsView(LinearLayout predictions, boolean showInitLabel) { predictions.removeAllViews();/*from www .jav a 2 s .co m*/ if (showInitLabel) { TextView tv1 = new TextView(this); tv1.setText("Predictions will appear Here"); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.weight = 1.f; params.gravity = Gravity.CENTER_VERTICAL; tv1.setLayoutParams(params); tv1.setTextSize(pixels5); predictions.addView(tv1); } if (saveButton != null) saveButton.setVisibility(View.INVISIBLE); if (loader != null) loader.setVisibility(View.INVISIBLE); }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Creates the auto layout.//from www . j ava2 s. c om * It contains toggle button to switch auto state, two text view to indicate auto messages. * * @return the relative layout */ private RelativeLayout createAutoLayout() { RelativeLayout autoLayout = new RelativeLayout(this); autoLayout.setPadding(10, 5, 10, 10); autoLayout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, 80)); TextView autoText = new TextView(this); RelativeLayout.LayoutParams autoTextLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); autoTextLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); autoTextLayout.addRule(RelativeLayout.CENTER_VERTICAL); autoText.setLayoutParams(autoTextLayout); autoText.setText("Auto Discovery"); ToggleButton autoButton = new ToggleButton(this); autoButton.setWidth(150); RelativeLayout.LayoutParams autoButtonLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); autoButtonLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); autoButtonLayout.addRule(RelativeLayout.CENTER_VERTICAL); autoButton.setLayoutParams(autoButtonLayout); autoButton.setChecked(autoMode); autoButton.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { appSettingsView.removeViewAt(2); currentServer = ""; if (isChecked) { IPAutoDiscoveryServer.isInterrupted = false; appSettingsView.addView(constructAutoServersView(), 2); } else { IPAutoDiscoveryServer.isInterrupted = true; appSettingsView.addView(constructCustomServersView(), 2); } AppSettingsModel.setAutoMode(AppSettingsActivity.this, isChecked); } }); TextView infoText = new TextView(this); RelativeLayout.LayoutParams infoTextLayout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); infoTextLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); infoTextLayout.addRule(RelativeLayout.ALIGN_PARENT_LEFT); infoText.setLayoutParams(infoTextLayout); infoText.setTextSize(10); infoText.setText("Turn off auto-discovery to input controller url manually."); autoLayout.addView(autoText); autoLayout.addView(autoButton); autoLayout.addView(infoText); return autoLayout; }
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;/* ww w.ja va2 s .co m*/ 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:com.gelakinetic.mtgfam.activities.MainActivity.java
public void showDialogFragment(final int id) { // DialogFragment.show() will take care of adding the fragment // in a transaction. We also want to remove any currently showing // dialog, so make our own transaction and take care of that here. this.showContent(); FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction(); Fragment prev = getSupportFragmentManager().findFragmentByTag(FamiliarFragment.DIALOG_TAG); if (prev != null) { ft.remove(prev);/*from www . j a v a2 s.co m*/ } // Create and show the dialog. FamiliarDialogFragment newFragment = new FamiliarDialogFragment() { @Override public void onDismiss(DialogInterface mDialog) { super.onDismiss(mDialog); if (bounceMenu) { getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); bounceMenu = false; Runnable r = new Runnable() { @Override public void run() { long timeStarted = System.currentTimeMillis(); Message msg = Message.obtain(); msg.arg1 = OPEN; bounceHandler.sendMessage(msg); while (System.currentTimeMillis() < (timeStarted + 1500)) { ; } msg = Message.obtain(); msg.arg1 = CLOSE; bounceHandler.sendMessage(msg); runOnUiThread(new Runnable() { @Override public void run() { getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED); } }); } }; Thread t = new Thread(r); t.start(); } } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { switch (id) { case DONATEDIALOG: { AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity()); builder.setTitle(R.string.main_donate_dialog_title); builder.setNeutralButton(R.string.dialog_thanks_anyway, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); LayoutInflater inflater = this.getActivity().getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.about_dialog, (ViewGroup) findViewById(R.id.dialog_layout_root)); TextView text = (TextView) dialoglayout.findViewById(R.id.aboutfield); text.setText(ImageGetterHelper.jellyBeanHack(getString(R.string.main_donate_text))); text.setMovementMethod(LinkMovementMethod.getInstance()); text.setTextSize(15); ImageView paypal = (ImageView) dialoglayout.findViewById(R.id.imageview1); paypal.setImageResource(R.drawable.paypal); paypal.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse( "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=SZK4TAH2XBZNC&lc=US&item_name=MTG%20Familiar¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted")); startActivity(myIntent); } }); ((ImageView) dialoglayout.findViewById(R.id.imageview2)).setVisibility(View.GONE); builder.setView(dialoglayout); return builder.create(); } case ABOUTDIALOG: { AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity()); // You have to catch the exception because the package stuff is all // run-time if (pInfo != null) { builder.setTitle(getString(R.string.main_about) + " " + getString(R.string.app_name) + " " + pInfo.versionName); } else { builder.setTitle(getString(R.string.main_about) + " " + getString(R.string.app_name)); } builder.setNeutralButton(R.string.dialog_thanks, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); LayoutInflater inflater = this.getActivity().getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.about_dialog, (ViewGroup) findViewById(R.id.dialog_layout_root)); TextView text = (TextView) dialoglayout.findViewById(R.id.aboutfield); text.setText(ImageGetterHelper.jellyBeanHack(getString(R.string.main_about_text))); text.setMovementMethod(LinkMovementMethod.getInstance()); builder.setView(dialoglayout); return builder.create(); } case CHANGELOGDIALOG: { AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity()); if (pInfo != null) { builder.setTitle(getString(R.string.main_whats_new_in_title) + " " + pInfo.versionName); } else { builder.setTitle(R.string.main_whats_new_title); } builder.setNeutralButton(R.string.dialog_enjoy, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); builder.setMessage(ImageGetterHelper.jellyBeanHack(getString(R.string.main_whats_new_text))); return builder.create(); } default: { savedInstanceState.putInt("id", id); return super.onCreateDialog(savedInstanceState); } } } }; newFragment.show(ft, FamiliarFragment.DIALOG_TAG); }
From source file:com.asgj.android.appusage.ui.widgets.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 ww w . j av a 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, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); LinearLayout.LayoutParams tabViewParams = (LinearLayout.LayoutParams) tabView.getLayoutParams(); if (tabViewParams == null) tabViewParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); tabViewParams.weight = 1; tabView.setLayoutParams(tabViewParams); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setTextSize(15); tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); mTabStrip.addView(tabView); } }
From source file:com.example.drugsformarinemammals.General_Info_Drug.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.general_info_drug); isStoredInLocal = false;// w w w. ja v a2 s. c o m fiveLastScreen = false; helper = new Handler_Sqlite(this); helper.open(); Bundle extras1 = this.getIntent().getExtras(); if (extras1 != null) { infoBundle = extras1.getStringArrayList("generalInfoDrug"); fiveLastScreen = extras1.getBoolean("fiveLastScreen"); if (infoBundle == null) isStoredInLocal = true; if (!isStoredInLocal) { initializeGeneralInfoDrug(); initializeCodesInformation(); initializeCodes(); } else { drug_name = extras1.getString("drugName"); codes = helper.getCodes(drug_name); codesInformation = helper.getCodesInformation(drug_name); } //Title TextView drugTitle = (TextView) findViewById(R.id.drugTitle); drugTitle.setText(drug_name); drugTitle.setTypeface(Typeface.SANS_SERIF); //Description LinearLayout borderDescription = new LinearLayout(this); borderDescription.setOrientation(LinearLayout.VERTICAL); borderDescription .setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); borderDescription.setBackgroundResource(R.drawable.layout_border); TextView description = new TextView(this); if (isStoredInLocal) description.setText(helper.getDescription(drug_name)); else description.setText(this.description); description.setTextSize(18); description.setTypeface(Typeface.SANS_SERIF); LinearLayout.LayoutParams paramsDescription = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsDescription.leftMargin = 60; paramsDescription.rightMargin = 60; paramsDescription.topMargin = 20; borderDescription.addView(description, borderDescription.getChildCount(), paramsDescription); LinearLayout layoutDescription = (LinearLayout) findViewById(R.id.layoutDescription); layoutDescription.addView(borderDescription, layoutDescription.getChildCount()); //Animals TextView headerAnimals = (TextView) findViewById(R.id.headerAnimals); headerAnimals.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); Button cetaceansButton = (Button) findViewById(R.id.cetaceansButton); cetaceansButton.setText("CETACEANS"); cetaceansButton.setTypeface(Typeface.SANS_SERIF); cetaceansButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDoseInformation(drug_name, "Cetaceans"); } }); Button pinnipedsButton = (Button) findViewById(R.id.pinnipedsButton); pinnipedsButton.setText("PINNIPEDS"); pinnipedsButton.setTypeface(Typeface.SANS_SERIF); pinnipedsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SQLiteDatabase db = helper.open(); ArrayList<String> families = new ArrayList<String>(); if (db != null) families = helper.read_animals_family(drug_name, "Pinnipeds"); if ((families != null && families.size() == 1 && families.get(0).equals("")) || (families != null && families.size() == 0)) showDoseInformation(drug_name, "Pinnipeds"); else showDoseInformationPinnipeds(drug_name, families); } }); Button otherButton = (Button) findViewById(R.id.otherButton); otherButton.setText("OTHER MM"); otherButton.setTypeface(Typeface.SANS_SERIF); otherButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDoseInformation(drug_name, "Other MM"); } }); //Codes & therapeutic target & anatomical target TextView headerATCvetCodes = (TextView) findViewById(R.id.headerATCvetCodes); headerATCvetCodes.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); //Action TextView headerActionAnatomical = (TextView) findViewById(R.id.headerActionAnatomical); headerActionAnatomical.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); createTextViewAnatomical(); createBorderAnatomicalGroup(); TextView headerActionTherapeutic = (TextView) findViewById(R.id.headerActionTherapeutic); headerActionTherapeutic.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); createTextViewTherapeutic(); createBorderTherapeuticGroup(); params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); params.leftMargin = 60; params.rightMargin = 60; params.topMargin = 20; Spinner codesSpinner = (Spinner) findViewById(R.id.codesSpinner); SpinnerAdapter adapterCodes = new SpinnerAdapter(this, R.layout.item_spinner, codes); adapterCodes.setDropDownViewResource(R.layout.spinner_dropdown_item); codesSpinner.setAdapter(adapterCodes); codesSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View arg1, int arg2, long arg3) { userEntryCode = parent.getSelectedItem().toString(); int numCodes = codesInformation.size(); layoutAnatomicalGroup.removeView(borderAnatomicalGroup); createBorderAnatomicalGroup(); boolean founded = false; int i = 0; while (!founded && i < numCodes) { if (userEntryCode.equals(codesInformation.get(i).getCode())) { createTextViewAnatomical(); anatomicalGroup.setText(codesInformation.get(i).getAnatomic_group() + "\n"); borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params); founded = true; } i++; } layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical); layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount()); layoutTherapeuticGroup.removeView(borderTherapeuticGroup); createBorderTherapeuticGroup(); founded = false; i = 0; while (!founded && i < numCodes) { if (userEntryCode.equals(codesInformation.get(i).getCode())) { createTextViewTherapeutic(); therapeuticGroup.setText(codesInformation.get(i).getTherapeutic_group() + "\n"); borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params); founded = true; } i++; } layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic); layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount()); } public void onNothingSelected(AdapterView<?> arg0) { } }); layoutAnatomicalGroup = (LinearLayout) findViewById(R.id.layoutActionAnatomical); layoutTherapeuticGroup = (LinearLayout) findViewById(R.id.layoutActionTherapeutic); borderTherapeuticGroup.addView(therapeuticGroup, borderTherapeuticGroup.getChildCount(), params); borderAnatomicalGroup.addView(anatomicalGroup, borderAnatomicalGroup.getChildCount(), params); layoutAnatomicalGroup.addView(borderAnatomicalGroup, layoutAnatomicalGroup.getChildCount()); layoutTherapeuticGroup.addView(borderTherapeuticGroup, layoutTherapeuticGroup.getChildCount()); //Generic Drug TextView headerGenericDrug = (TextView) findViewById(R.id.headerGenericDrug); headerGenericDrug.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); boolean isAvalaible = false; if (isStoredInLocal) isAvalaible = helper.isAvalaible(drug_name); else isAvalaible = available.equals("Yes"); if (isAvalaible) { ImageView genericDrug = new ImageView(this); genericDrug.setImageResource(R.drawable.tick_verde); LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug); layoutGenericDrug.addView(genericDrug); } else { Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf"); TextView genericDrug = new TextView(this); genericDrug.setTypeface(font); genericDrug.setText("Nd"); genericDrug.setTextColor(getResources().getColor(R.color.maroon)); genericDrug.setTextSize(20); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int size = metrics.widthPixels; int middle = size / 2; int quarter = size / 4; genericDrug.setTranslationX(middle - quarter); genericDrug.setTranslationY(-3); LinearLayout layoutGenericDrug = (LinearLayout) findViewById(R.id.layoutGenericDrug); layoutGenericDrug.addView(genericDrug); } //Licenses TextView headerLicense = (TextView) findViewById(R.id.headerLicense); headerLicense.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD); TextView fdaLicense = (TextView) findViewById(R.id.license1); Typeface font = Typeface.createFromAsset(getAssets(), "Typoster_demo.otf"); fdaLicense.setTypeface(font); String fda; if (isStoredInLocal) fda = helper.getLicense_FDA(drug_name); else fda = license_FDA; if (fda.equals("Yes")) { fdaLicense.setText("Yes"); fdaLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { fdaLicense.setText("Nd"); fdaLicense.setTextColor(getResources().getColor(R.color.maroon)); } TextView emaLicense = (TextView) findViewById(R.id.license3); emaLicense.setTypeface(font); String ema; if (isStoredInLocal) ema = helper.getLicense_EMA(drug_name); else ema = license_EMA; if (ema.equals("Yes")) { emaLicense.setText("Yes"); emaLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { emaLicense.setText("Nd"); emaLicense.setTextColor(getResources().getColor(R.color.maroon)); } TextView aempsLicense = (TextView) findViewById(R.id.license2); aempsLicense.setTypeface(font); String aemps; if (isStoredInLocal) aemps = helper.getLicense_AEMPS(drug_name); else aemps = license_AEMPS; if (aemps.equals("Yes")) { aempsLicense.setText("Yes"); aempsLicense.setTextColor(getResources().getColor(R.color.lightGreen)); } else { aempsLicense.setText("Nd"); aempsLicense.setTextColor(getResources().getColor(R.color.maroon)); } ImageButton food_and_drug = (ImageButton) findViewById(R.id.food_and_drug); food_and_drug.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.fda.gov/animalveterinary/products/approvedanimaldrugproducts/default.htm")); startActivity(intent); } }); ImageButton european_medicines_agency = (ImageButton) findViewById(R.id.european_medicines_agency); european_medicines_agency.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.ema.europa.eu/ema/index.jsp?curl=pages/medicines/landing/vet_epar_search.jsp&mid=WC0b01ac058001fa1c")); startActivity(intent); } }); ImageButton logo_aemps = (ImageButton) findViewById(R.id.logo_aemps); logo_aemps.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse( "http://www.aemps.gob.es/medicamentosVeterinarios/Med-Vet-autorizados/home.htm")); startActivity(intent); } }); if (helper.existDrug(drug_name)) { int drug_priority = helper.getDrugPriority(drug_name); ArrayList<String> sorted_drugs = new ArrayList<String>(); sorted_drugs.add(0, drug_name); for (int i = 1; i < drug_priority; i++) { String name = helper.getDrugName(i); sorted_drugs.add(i, name); } for (int i = 0; i < sorted_drugs.size(); i++) helper.setDrugPriority(sorted_drugs.get(i), i + 1); } if (!isStoredInLocal) { //Server code String[] urls = { "http://formmulary.tk/Android/getDoseInformation.php?drug_name=", "http://formmulary.tk/Android/getGeneralNotesInformation.php?drug_name=" }; new GetDoseInformation(this).execute(urls); } helper.close(); } }
From source file:com.cssweb.android.quote.QHSCGridActivity.java
protected void initQuote(int pageNum, String stocks, String stocksname) throws JSONException { this.temp1 = stocks.split(","); this.temp2 = stocksname.split(","); try {//from ww w.j a v a 2s . c om if (null != temp1 && null != temp2 && !"".equals(temp1) && !"".equals(temp2)) { for (int i = 1; i <= temp1.length; i++) { TextView localView6 = (TextView) this.mLinerLock.findViewWithTag(i); TextView localView7 = (TextView) this.mLinerLock2.findViewWithTag(i); if (localView7 == null || localView6 == null) { Log.i("tag", "localView7 is " + localView7); Log.i("tag", "localView6 is " + localView6); } if (nameOrCodeFlag) {// ?(????) if (nameOrcode) localView6.setText(temp2[i - 1]); else { if (temp1[i - 1].length() > 2) { localView6.setText(temp1[i - 1].substring(2)); } } } else { if (temp2[i - 1].length() > 5) { localView7.setTextSize(16); } if (temp1[i - 1].length() > 2) { if (temp1[i - 1].substring(2).length() > 5) { localView6.setTextSize(16); } localView6.setText(temp1[i - 1].substring(2)); localView7.setText(temp2[i - 1]); } } } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.df.app.procedures.CarRecogniseLayout.java
/** * //from ww w .ja va 2 s .c om */ private void selectCarManually() { if (!mCarSettings.getBrandString().equals("")) { View view1 = ((Activity) rootView.getContext()).getLayoutInflater().inflate(R.layout.popup_layout, null); TableLayout contentArea = (TableLayout) view1.findViewById(R.id.contentArea); TextView content = new TextView(view1.getContext()); content.setText(R.string.reMatch); content.setTextSize(20f); contentArea.addView(content); setTextView(view1, R.id.title, getResources().getString(R.string.alert)); AlertDialog dialog = new AlertDialog.Builder(rootView.getContext()).setView(view1) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { mHideContentCallback.hideContent(); showSelectCarDialog(); } }).setNegativeButton(R.string.cancel, null).create(); dialog.show(); } else { showSelectCarDialog(); } }