List of usage examples for android.widget LinearLayout setBackgroundResource
@RemotableViewMethod public void setBackgroundResource(@DrawableRes int resid)
From source file:org.noise_planet.noisecapture.CommentActivity.java
private void addTag(String tagName, int id, ViewGroup column, int color) { ToggleButton tagButton = new ToggleButton(this); if (color != -1) { LinearLayout colorBox = new LinearLayout(this); // Convert the dps to pixels, based on density scale final int tagPaddingPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()); final int tagPaddingPxBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 3, getResources().getDisplayMetrics()); //use a GradientDrawable with only one color set, to make it a solid color colorBox.setBackgroundResource(R.drawable.tag_round_corner); GradientDrawable gradientDrawable = (GradientDrawable) colorBox.getBackground(); gradientDrawable.setColor(color); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.setMargins(tagPaddingPx, tagPaddingPx, tagPaddingPx, tagPaddingPxBottom); colorBox.setLayoutParams(params); colorBox.addView(tagButton);/* w ww.ja v a 2s . c o m*/ column.addView(colorBox); } else { column.addView(tagButton); } tagButton.setTextOff(tagName); tagButton.setTextOn(tagName); boolean isChecked = checkedTags.contains(id); tagButton.setChecked(isChecked); if (isChecked) { tagButton.setTextColor(selectedColor); } tagButton.setOnCheckedChangeListener(new TagStateListener(id, checkedTags)); tagButton.setMinHeight(0); tagButton.setMinimumHeight(0); tagButton.setTextSize(Dimension.SP, 12); tagButton.setEnabled(record == null || record.getUploadId().isEmpty()); tagButton.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); tagButton.invalidate(); }
From source file:com.example.drugsformarinemammals.Dose_Information.java
public LinearLayout createBorderLayout() { LinearLayout border_layout = new LinearLayout(this); border_layout.setOrientation(LinearLayout.VERTICAL); border_layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); border_layout.setBackgroundResource(R.drawable.layout_border); return border_layout; }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageAdapter.java
@SuppressLint("SdCardPath") @Override/*from w w w .ja v a 2s.c o m*/ public void bindView(View view, Context context, Cursor cursor) { System.out.println("MessageAdapter.java in bindView() "); final MessageListItemViews tagView = (MessageListItemViews) view.getTag(); v = view; this.context = context; SipMessage msg = new SipMessage(cursor); // System.out.println("msg:"+msg); System.out.println("Cursor row count:" + cursor.getCount()); String number = msg.getRemoteNumber(); long date = msg.getDate(); String message = msg.getBodyContent(); subject = message; System.out.println("subject--" + subject); if (message.contains("[Offline message -") && !number.equals("sip:registrar@kamailio.org")) { System.out.println("offline message"); String[] finalMessage = message.split("]"); subject = finalMessage[finalMessage.length - 1]; } else { subject = message; } String errorTxt = msg.getErrorContent(); String mimeType = msg.getMimeType(); int type = msg.getType(); Log.setLogLevel(6); Log.d("Col count", cursor.getColumnCount() + " @"); String[] columnname = cursor.getColumnNames(); for (int i = 0; i < columnname.length; i++) { Log.d("columnname " + i, columnname[i] + " @"); Log.d(columnname[i], cursor.getString(cursor.getColumnIndex(columnname[i])) + " @"); } tv_msg_info = (TextView) view.findViewById(R.id.tv_msg_info); pb_uploading = (ProgressBar) view.findViewById(R.id.pb_uploading); String timestamp = ""; if (System.currentTimeMillis() - date > 1000 * 60 * 60 * 24) { // If it was recieved one day ago or more display relative // timestamp - SMS like behavior int flags = DateUtils.FORMAT_ABBREV_RELATIVE; timestamp = (String) DateUtils.getRelativeTimeSpanString(date, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags); } else { // If it has been recieved recently show time of reception - IM // like behavior timestamp = dateFormatter.format(new Date(date)); } tagView.dateView.setText(timestamp); // Delivery state if (type == SipMessage.MESSAGE_TYPE_QUEUED) { tagView.deliveredIndicator.setVisibility(View.VISIBLE); tagView.deliveredIndicator.setImageResource(R.drawable.error_watch_not_send); tagView.deliveredIndicator.setContentDescription(""); } else if (type == SipMessage.MESSAGE_TYPE_FAILED) { tagView.deliveredIndicator.setVisibility(View.VISIBLE); tagView.deliveredIndicator.setImageResource(R.drawable.error_watch_not_send); tagView.deliveredIndicator.setContentDescription(""); } else { tagView.deliveredIndicator.setVisibility(View.VISIBLE); tagView.deliveredIndicator.setImageResource(R.drawable.todo_send); tagView.deliveredIndicator.setContentDescription(""); } if (TextUtils.isEmpty(errorTxt)) { tagView.errorView.setVisibility(View.GONE); } else { tagView.errorView.setVisibility(View.GONE); tagView.errorView.setText(errorTxt); } // Subject tagView.contentView.setText(formatMessage(number, subject, mimeType)); if (msg.isOutgoing()) { setPhotoSide(tagView, ArrowPosition.LEFT); LinearLayout linerLayout = (LinearLayout) view.findViewById(R.id.message_block); linerLayout.setBackgroundResource(R.drawable.chatedittextdesign); text_view = (TextView) view.findViewById(R.id.text_view); text_view.setTextColor(Color.BLACK); // Photo tagView.quickContactView.assignContactUri(personalInfo.contactContentUri); /* ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), personalInfo, R.drawable.ic_contact_picture_holo_dark); */ System.out.println("msg adp out - 0"); String path = "/sdcard/R4W/ProfilePic/ProfilePic.png"; File user_imageFile = new File(path); if (user_imageFile.exists()) { try { if (bm != null) { // bm = null; } bm = BitmapFactory.decodeFile(path); bm = ImageHelperCircular.getRoundedCornerBitmap(bm, bm.getWidth()); tagView.quickContactView.getImageView().setImageBitmap(bm); } catch (Exception e) { // TODO: handle exception try { tagView.quickContactView.getImageView().setImageURI(Uri.parse(path)); } catch (Exception e2) { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), personalInfo, R.drawable.ic_contact_picture_holo_dark); // TODO: handle exception } } } else { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), personalInfo, R.drawable.ic_contact_picture_holo_dark); } outgoingImage(number); } else { setPhotoSide(tagView, ArrowPosition.RIGHT); LinearLayout linerLayout = (LinearLayout) view.findViewById(R.id.message_block); linerLayout.setBackgroundResource(R.drawable.messagebodyleft); // Contact CallerInfo info = CallerInfo.getCallerInfoFromSipUri(mContext, msg.getFullFrom()); text_view = (TextView) view.findViewById(R.id.text_view); text_view.setTextColor(Color.BLACK); pb_uploading.setVisibility(ProgressBar.GONE); // Photo tagView.quickContactView.assignContactUri(info.contactContentUri); /* ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), info, R.drawable.ic_contact_picture_holo_dark); */ System.out.println("msg adp in - 1"); String nu = stripNumber(number); String path = "/sdcard/R4W/ProfilePic/" + nu + ".png"; System.out.println("msg adp out - path=" + path); File user_imageFile = new File(path); if (user_imageFile.exists()) { try { if (bm != null) { // bm = null; } bm = BitmapFactory.decodeFile(path); bm = ImageHelperCircular.getRoundedCornerBitmap(bm, bm.getWidth()); tagView.quickContactView.getImageView().setImageBitmap(bm); } catch (Exception e) { // TODO: handle exception try { tagView.quickContactView.getImageView().setImageURI(Uri.parse(path)); } catch (Exception e2) { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), info, R.drawable.ic_contact_picture_holo_dark); // TODO: handle exception } } } else { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), info, R.drawable.ic_contact_picture_holo_dark); } incomingImage(); } }
From source file:com.lkunic.lib.activityaddonlib.twopane.fragments.showcase.ItemShowcaseFragment.java
/** * Sets up the fragment and it's views.//from ww w . ja v a 2 s.c o m * @param view The layout view. */ @Override protected void setupContent(View view) { // Make sure item data is available before setting up content. getItemData(); // Populate the view holder if needed if (viewHolder == null) { viewHolder = new ViewHolder(); viewHolder.showcaseItemImage = (ImageView) view.findViewById(R.id.showcase_image); viewHolder.showcaseItemTitle = (TextView) view.findViewById(R.id.showcase_title); viewHolder.viewPager = (ViewPager) view.findViewById(R.id.pager); viewHolder.pagerButtonBar = (LinearLayout) view.findViewById(R.id.pager_button_bar); } // Set the item image viewHolder.showcaseItemImage.setImageBitmap(getShowcaseImage()); // Set the item title viewHolder.showcaseItemTitle.setText(getShowcaseItemTitle()); // Set up the view pager ItemShowcaseInfoFragment[] infoFragments = getInfoFragments(); if (viewHolder.viewPager.getAdapter() == null) { // The ViewPager doesn't have an adapter yet, create it and populate with info fragments viewHolder.viewPager.setAdapter(new ShowcasePagerAdapter(getChildFragmentManager(), infoFragments)); viewHolder.viewPager.setOnPageChangeListener(showcasePageChangeListener); } else { // The ViewPager already has an adapter, populate it with new info fragments ShowcasePagerAdapter adapter = (ShowcasePagerAdapter) viewHolder.viewPager.getAdapter(); adapter.setPagerItems(infoFragments); adapter.notifyDataSetChanged(); } // Build the button bar for controlling the view pager ShowcaseButton showcaseButton; LinearLayout showcaseButtonContainer; LayoutParams showcaseButtonParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1); // Remove all buttons that could have been populated by previous item viewHolder.pagerButtonBar.removeAllViews(); for (int i = 0, n = infoFragments.length; i < n; i++) { // Create a new showcase button and populate it with data from corresponding fragment showcaseButton = new ShowcaseButton(getActivity(), infoFragments[i].getQuantity(), infoFragments[i].getQuantityName()); // Setup the showcase view so that it can be used as a tab button showcaseButtonContainer = (LinearLayout) showcaseButton.findViewById(R.id.container); showcaseButtonContainer.setTag(i); showcaseButtonContainer.setOnClickListener(showcaseButtonClickListener); showcaseButtonContainer.setBackgroundResource(i % 2 == 0 ? R.drawable.showcase_button_background_light : R.drawable.showcase_button_background_dark); // Add the button to the button bar showcaseButton.setLayoutParams(showcaseButtonParams); viewHolder.pagerButtonBar.addView(showcaseButton); } viewHolder.viewPager.setCurrentItem(0, true); selectPageButton(0); }
From source file:com.lkunic.libs.apptoolbox.twopane.fragments.ShowcaseFragment.java
/** * Sets up the fragment and it's views.//from ww w . ja v a2 s . co m * @param view The layout view. */ @Override protected void setupContent(View view) { // Make sure item data is available before setting up content. getItemData(); // Populate the view holder if needed if (viewHolder == null) { viewHolder = new ViewHolder(); viewHolder.showcaseItemImage = (ImageView) view.findViewById(R.id.item_image); viewHolder.showcaseItemTitle = (TextView) view.findViewById(R.id.item_title); viewHolder.viewPager = (ViewPager) view.findViewById(R.id.pager); viewHolder.pagerButtonBar = (LinearLayout) view.findViewById(R.id.pager_button_bar); } // Set the item image viewHolder.showcaseItemImage.setImageBitmap(getShowcaseImage()); // Set the item title viewHolder.showcaseItemTitle.setText(getShowcaseItemTitle()); // Set up the view pager ShowcaseInfoFragment[] infoFragments = getInfoFragments(); if (viewHolder.viewPager.getAdapter() == null) { // The ViewPager doesn't have an adapter yet, create it and populate with info fragments viewHolder.viewPager.setAdapter(new ShowcasePagerAdapter(getChildFragmentManager(), infoFragments)); viewHolder.viewPager.addOnPageChangeListener(showcasePageChangeListener); } else { // The ViewPager already has an adapter, populate it with new info fragments ShowcasePagerAdapter adapter = (ShowcasePagerAdapter) viewHolder.viewPager.getAdapter(); adapter.setPagerItems(infoFragments); adapter.notifyDataSetChanged(); } // Build the button bar for controlling the view pager TextButton textButton; LinearLayout showcaseButtonContainer; LinearLayout.LayoutParams showcaseButtonParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1); // Remove all buttons that could have been populated by previous item viewHolder.pagerButtonBar.removeAllViews(); for (int i = 0, n = infoFragments.length; i < n; i++) { // Create a new showcase button and populate it with data from corresponding fragment textButton = new TextButton(getContext(), infoFragments[i].getPrimaryText(), infoFragments[i].getSecondaryText()); // Setup the showcase view so that it can be used as a tab button showcaseButtonContainer = (LinearLayout) textButton.findViewById(R.id.container); showcaseButtonContainer.setTag(i); showcaseButtonContainer.setOnClickListener(showcaseButtonClickListener); showcaseButtonContainer.setBackgroundResource(i % 2 == 0 ? R.drawable.pager_tab_control_background_1 : R.drawable.pager_tab_control_background_2); // Add the button to the button bar textButton.setLayoutParams(showcaseButtonParams); viewHolder.pagerButtonBar.addView(textButton); } viewHolder.viewPager.setCurrentItem(0, true); selectPageButton(0); }
From source file:ru.adios.budgeter.widgets.DataTableLayout.java
private LinearLayout getCenteredRowText(Context context, String text, float layoutWeightSum, boolean largeText, float textViewWeight) { final LinearLayout inner = new LinearLayout(context); final TableRow.LayoutParams innerParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f); innerParams.span = itemsPerInnerRow; inner.setLayoutParams(innerParams);/*from w w w . java 2 s .c om*/ inner.setWeightSum(layoutWeightSum); inner.setBackgroundResource(R.drawable.cell_shape); final TextView nameTextView = new TextView(context); nameTextView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, textViewWeight)); nameTextView.setTextAppearance(context, largeText ? android.R.style.TextAppearance_Large : android.R.style.TextAppearance_Medium); nameTextView.setText(text); nameTextView.setGravity(Gravity.CENTER); inner.addView(nameTextView); return inner; }
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 .j a v a2s.co 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.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;//w w w.j a v a 2s.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:edu.pitt.gis.uniapp.UniApp.java
/** * Shows the splash screen over the full Activity *//*ww w. j av a 2 s.co m*/ @SuppressWarnings("deprecation") protected void showSplashScreen(final int time) { final UniApp that = this; Runnable runnable = new Runnable() { public void run() { // Get reference to display Display display = getWindowManager().getDefaultDisplay(); // Create the layout for the dialog LinearLayout root = new LinearLayout(that.getActivity()); root.setMinimumHeight(display.getHeight()); root.setMinimumWidth(display.getWidth()); root.setOrientation(LinearLayout.VERTICAL); root.setBackgroundColor(that.getIntegerProperty("backgroundColor", Color.BLACK)); root.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT, 0.0F)); root.setBackgroundResource(that.splashscreen); // Create and show the dialog splashDialog = new Dialog(that, android.R.style.Theme_Translucent_NoTitleBar); // check to see if the splash screen should be full screen if ((getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == WindowManager.LayoutParams.FLAG_FULLSCREEN) { splashDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } splashDialog.setContentView(root); splashDialog.setCancelable(false); splashDialog.show(); // Set Runnable to remove splash screen just in case final Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { removeSplashScreen(); } }, time); } }; this.runOnUiThread(runnable); }
From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java
public DrawerForm(Context context, Context unstyledContext, Callback callback, WatcherService.Client watcherServiceClient) { this.context = context; this.unstyledContext = unstyledContext; this.callback = callback; this.watcherServiceClient = watcherServiceClient; float density = ResourceUtils.obtainDensity(context); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setLayoutParams(new SortableListView.LayoutParams(SortableListView.LayoutParams.MATCH_PARENT, SortableListView.LayoutParams.WRAP_CONTENT)); LinearLayout editTextContainer = new LinearLayout(context); editTextContainer.setGravity(Gravity.CENTER_VERTICAL); linearLayout.addView(editTextContainer); searchEdit = new SafePasteEditText(context); searchEdit.setOnKeyListener((v, keyCode, event) -> { if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) { v.clearFocus();/*from ww w .j a va2 s . c o m*/ } return false; }); searchEdit.setHint(context.getString(R.string.text_code_number_address)); searchEdit.setOnEditorActionListener(this); searchEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); searchEdit.setImeOptions(EditorInfo.IME_ACTION_GO | EditorInfo.IME_FLAG_NO_EXTRACT_UI); ImageView searchIcon = new ImageView(context, null, android.R.attr.buttonBarButtonStyle); searchIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonForward, 0)); searchIcon.setScaleType(ImageView.ScaleType.CENTER); searchIcon.setOnClickListener(this); editTextContainer.addView(searchEdit, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); editTextContainer.addView(searchIcon, (int) (40f * density), (int) (40f * density)); if (C.API_LOLLIPOP) { editTextContainer.setPadding((int) (12f * density), (int) (8f * density), (int) (8f * density), 0); } else { editTextContainer.setPadding(0, (int) (2f * density), (int) (4f * density), (int) (2f * density)); } LinearLayout selectorContainer = new LinearLayout(context); selectorContainer.setBackgroundResource( ResourceUtils.getResourceId(context, android.R.attr.selectableItemBackground, 0)); selectorContainer.setOrientation(LinearLayout.HORIZONTAL); selectorContainer.setGravity(Gravity.CENTER_VERTICAL); selectorContainer.setOnClickListener(v -> { hideKeyboard(); setChanSelectMode(!chanSelectMode); }); linearLayout.addView(selectorContainer); selectorContainer.setMinimumHeight((int) (40f * density)); if (C.API_LOLLIPOP) { selectorContainer.setPadding((int) (16f * density), 0, (int) (16f * density), 0); ((LinearLayout.LayoutParams) selectorContainer.getLayoutParams()).topMargin = (int) (4f * density); } else { selectorContainer.setPadding((int) (8f * density), 0, (int) (12f * density), 0); } chanNameView = new TextView(context, null, android.R.attr.textAppearanceListItem); chanNameView.setTextSize(TypedValue.COMPLEX_UNIT_SP, C.API_LOLLIPOP ? 14f : 16f); if (C.API_LOLLIPOP) { chanNameView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM); } else { chanNameView.setFilters(new InputFilter[] { new InputFilter.AllCaps() }); } selectorContainer.addView(chanNameView, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1)); chanSelectorIcon = new ImageView(context); chanSelectorIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonDropDownDrawer, 0)); selectorContainer.addView(chanSelectorIcon, (int) (24f * density), (int) (24f * density)); ((LinearLayout.LayoutParams) chanSelectorIcon.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL | Gravity.END; headerView = linearLayout; inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); chans.add(new ListItem(ListItem.ITEM_DIVIDER, 0, 0, null)); int color = ResourceUtils.getColor(context, R.attr.drawerIconColor); ChanManager manager = ChanManager.getInstance(); Collection<String> availableChans = manager.getAvailableChanNames(); for (String chanName : availableChans) { ChanConfiguration configuration = ChanConfiguration.get(chanName); if (configuration.getOption(ChanConfiguration.OPTION_READ_POSTS_COUNT)) { watcherSupportSet.add(chanName); } Drawable drawable = manager.getIcon(chanName, color); chanIcons.put(chanName, drawable); chans.add( new ListItem(ListItem.ITEM_CHAN, chanName, null, null, configuration.getTitle(), 0, drawable)); } if (availableChans.size() == 1) { selectorContainer.setVisibility(View.GONE); } }