List of usage examples for android.widget TextView setTextSize
@android.view.RemotableViewMethod public void setTextSize(float size)
From source file:com.egloos.hyunyi.musicinfo.LinkPopUp.java
private void displayArtistInfo(JSONObject j) throws JSONException { if (imageLoader == null) imageLoader = ImageLoader.getInstance(); if (!imageLoader.isInited()) imageLoader.init(config);/*from w w w .j a v a2 s. c o m*/ Log.i("musicInfo", "LinkPopUp. displayArtistInfo " + j.toString()); //JSONObject j_artist_info = j.getJSONObject("artist"); final String artist_name = j.getString("name"); tArtistName.setText(artist_name); final JSONObject urls = j.optJSONObject("urls"); final JSONArray videos = j.optJSONArray("video"); final JSONArray images = j.optJSONArray("images"); final String msg = artist_name.replaceAll("\\p{Punct}", " ").replaceAll("\\p{Space}", "+"); AsyncHttpClient client = new AsyncHttpClient(); String fmURL = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=" + msg + "&autocorrect[1]&format=json&api_key=ca4c10f9ae187ebb889b33ba12da7ee9"; Log.i("musicInfo", fmURL); client.get(fmURL, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { String r = new String(responseBody); ArrayList<String> image_urls = new ArrayList<String>(); try { Log.i("musicInfo", "Communicating with LastFM..."); JSONObject json = new JSONObject(r); Log.i("musicInfo", json.toString()); json = json.getJSONObject("artist"); Log.i("musicInfo", json.toString()); JSONArray artist_images = json.optJSONArray("image"); Log.i("musicInfo", artist_images.toString()); for (int i = 0; i < artist_images.length(); i++) { JSONObject j = artist_images.getJSONObject(i); Log.i("musicInfo", j.optString("size")); if (j.optString("size").contains("extralarge")) { image_urls.add(j.optString("#text")); //b.putString("fm_image", j.getString("#text")); //Log.i("musicInfo", j.getString("#text")); break; } } } catch (JSONException e) { e.printStackTrace(); } if (images != null) { for (int i = 0; i < images.length(); i++) { JSONObject image = null; try { image = images.getJSONObject(i); } catch (JSONException e) { e.printStackTrace(); } int width = image.optInt("width", 0); int height = image.optInt("height", 0); String url = image.optString("url", ""); Log.i("musicInfo", i + ": " + url); if ((width * height > 10000) && (width * height < 100000) && (!url.contains("userserve-ak"))) { //if ((width>300&&width<100)&&(height>300&&height<1000)&&(!url.contains("userserve-ak"))) { image_urls.add(url); Log.i("musicInfo", "Selected: " + url); //available_images.put(image); } } } int random = (int) (Math.random() * image_urls.size()); final String f_url = image_urls.get(random); Log.i("musicInfo", "Total image#=" + image_urls.size() + " Selected image#=" + random + " " + f_url); if (image_urls.size() > 0) { imageLoader.displayImage(f_url, ArtistImage, new ImageLoadingListener() { @Override public void onLoadingStarted(String imageUri, View view) { } @Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { } @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { lLinkList.removeAllViews(); //String attr = fImage.optJSONObject("license").optString("attribution"); //tAttribution.setText("Credit. " + ((attr == null) || (attr.contains("n/a")) ? "Unknown" : attr)); if (urls != null) { String[] jsonName = { "wikipedia_url", "mb_url", "lastfm_url", "official_url", "twitter_url" }; for (int i = 0; i < jsonName.length; i++) { if ((urls.optString(jsonName[i]) != null) && (urls.optString(jsonName[i]) != "")) { Log.d("musicinfo", "Link URL: " + urls.optString(jsonName[i])); TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); switch (jsonName[i]) { case "official_url": tv.setText("HOME."); break; case "wikipedia_url": tv.setText("WIKI."); break; case "mb_url": tv.setText("Music Brainz."); break; case "lastfm_url": tv.setText("Last FM."); break; case "twitter_url": tv.setText("Twitter."); break; } try { tv.setTag(urls.getString(jsonName[i])); } catch (JSONException e) { e.printStackTrace(); } tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setData(Uri.parse((String) v.getTag())); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); Toast.makeText(getApplicationContext(), "Open the Link...", Toast.LENGTH_SHORT).show(); //finish(); } }); lLinkList.addView(tv); } } } else { TextView tv = new TextView(getApplicationContext()); tv.setTextSize(11); tv.setPadding(16, 16, 16, 16); tv.setTextColor(Color.LTGRAY); tv.setTypeface(Typeface.SANS_SERIF); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setText("Sorry, No Link Here..."); lLinkList.addView(tv); } if (videos != null) { jVideoArray = videos; mAdapter = new StaggeredViewAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, generateImageData(videos)); //if (mData == null) { mData = generateImageData(videos); //} //mAdapter.clear(); for (JSONObject data : mData) { mAdapter.add(data); } mGridView.setAdapter(mAdapter); } else { } adjBottomColor(((ImageView) view).getDrawable()); } @Override public void onLoadingCancelled(String imageUri, View view) { } }); } else { ArtistImage.setImageResource(R.drawable.lamb_no_image_available); } } @Override public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { } }); }
From source file:com.farmerbb.notepad.adapter.NoteListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position NoteListItem item = getItem(position); String note = item.getNote(); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout, parent, false); // Lookup view for data population TextView noteTitle = convertView.findViewById(R.id.noteTitle); // Populate the data into the template view using the data object noteTitle.setText(note);//from w ww. j av a 2 s . c om // Apply theme SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences", Context.MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary)); if (theme.contains("dark")) noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark)); if (theme.contains("sans")) noteTitle.setTypeface(Typeface.SANS_SERIF); if (theme.contains("serif")) noteTitle.setTypeface(Typeface.SERIF); if (theme.contains("monospace")) noteTitle.setTypeface(Typeface.MONOSPACE); switch (pref.getString("font_size", "normal")) { case "smallest": noteTitle.setTextSize(12); break; case "small": noteTitle.setTextSize(14); break; case "normal": noteTitle.setTextSize(16); break; case "large": noteTitle.setTextSize(18); break; case "largest": noteTitle.setTextSize(20); break; } // Return the completed view to render on screen return convertView; }
From source file:com.anjalimacwan.adapter.NoteListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { // Get the data item for this position NoteListItem item = getItem(position); String note = item.getNote(); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_layout, parent, false); // Lookup view for data population TextView noteTitle = (TextView) convertView.findViewById(R.id.noteTitle); // Populate the data into the template view using the data object noteTitle.setText(note);/*ww w .j ava 2 s. co m*/ // Apply theme SharedPreferences pref = getContext().getSharedPreferences(getContext().getPackageName() + "_preferences", Context.MODE_PRIVATE); String theme = pref.getString("theme", "light-sans"); if (theme.contains("light")) noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary)); if (theme.contains("dark")) noteTitle.setTextColor(ContextCompat.getColor(getContext(), R.color.text_color_primary_dark)); if (theme.contains("sans")) noteTitle.setTypeface(Typeface.SANS_SERIF); if (theme.contains("serif")) noteTitle.setTypeface(Typeface.SERIF); if (theme.contains("monospace")) noteTitle.setTypeface(Typeface.MONOSPACE); switch (pref.getString("font_size", "normal")) { case "smallest": noteTitle.setTextSize(12); break; case "small": noteTitle.setTextSize(14); break; case "normal": noteTitle.setTextSize(16); break; case "large": noteTitle.setTextSize(18); break; case "largest": noteTitle.setTextSize(20); break; } // Return the completed view to render on screen return convertView; }
From source file:com.example.iyad.materialdesign01_g2.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 . ja va2 s. co m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextSize(48); tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:eu.operando.operandoapp.OperandoProxyStatus.java
@Override protected void onCreate(Bundle savedInstanceState) { MainUtil.initializeMainContext(getApplicationContext()); Settings settings = mainContext.getSettings(); settings.initializeDefaultValues();//ww w. ja va 2s . c o m setCurrentThemeStyle(settings.getThemeStyle()); setTheme(getCurrentThemeStyle().themeAppCompatStyle()); super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); settings.registerOnSharedPreferenceChangeListener(this); webView = (WebView) findViewById(R.id.webView); webView.getSettings().setJavaScriptEnabled(true); //region Floating Action Button fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (MainUtil.isServiceRunning(mainContext.getContext(), ProxyService.class) && !MainUtil.isProxyPaused(mainContext)) { //Update Preferences to BypassProxy MainUtil.setProxyPaused(mainContext, true); fab.setImageResource(android.R.drawable.ic_media_play); //Toast.makeText(mainContext.getContext(), "-- bypass (disable) proxy --", Toast.LENGTH_SHORT).show(); } else if (MainUtil.isServiceRunning(mainContext.getContext(), ProxyService.class) && MainUtil.isProxyPaused(mainContext)) { MainUtil.setProxyPaused(mainContext, false); fab.setImageResource(android.R.drawable.ic_media_pause); //Toast.makeText(mainContext.getContext(), "-- re-enable proxy --", Toast.LENGTH_SHORT).show(); } else if (!mainContext.getAuthority() .aliasFile(BouncyCastleSslEngineSource.KEY_STORE_FILE_EXTENSION).exists()) { try { installCert(); } catch (RootCertificateException | GeneralSecurityException | OperatorCreationException | IOException ex) { Logger.error(this, ex.getMessage(), ex.getCause()); } } } }); //endregion //region TabHost final TabHost tabHost = (TabHost) findViewById(R.id.tabHost2); tabHost.setup(); TabHost.TabSpec tabSpec = tabHost.newTabSpec("wifi_ap"); tabSpec.setContent(R.id.WifiAndAccessPointsScrollView); tabSpec.setIndicator("", getResources().getDrawable(R.drawable.ic_home)); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("response_domain_filters"); tabSpec.setContent(R.id.ResponseAndDomainFiltersScrollView); tabSpec.setIndicator("", getResources().getDrawable(R.drawable.ic_filter)); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("pending_notifications"); tabSpec.setContent(R.id.PendingNotificationsScrollView); tabSpec.setIndicator("", getResources().getDrawable(R.drawable.ic_pending_notification)); tabHost.addTab(tabSpec); tabSpec = tabHost.newTabSpec("logs"); tabSpec.setContent(R.id.LogsScrollView); tabSpec.setIndicator("", getResources().getDrawable(R.drawable.ic_report)); tabHost.addTab(tabSpec); tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String tabId) { switch (tabId) { case "pending_notifications": //region Load Tab3 ((TableLayout) ((LinearLayout) ((ScrollView) findViewById(R.id.PendingNotificationsScrollView)) .getChildAt(0)).getChildAt(1)).removeAllViews(); LoadPendingNotificationsTab(); //endregion break; case "logs": //region Load Tab 4 //because it is a heavy task it is being loaded asynchronously ((TableLayout) ((LinearLayout) ((ScrollView) findViewById(R.id.LogsScrollView)).getChildAt(0)) .getChildAt(1)).removeAllViews(); new AsyncTask() { private ProgressDialog mProgress; private List<String[]> apps; @Override protected void onPreExecute() { super.onPreExecute(); mProgress = new ProgressDialog(MainActivity.this); mProgress.setCancelable(false); mProgress.setCanceledOnTouchOutside(false); mProgress.setTitle("Fetching Application Data Logs"); mProgress.show(); } @Override protected Object doInBackground(Object[] params) { apps = new ArrayList(); for (String[] app : getInstalledApps(false)) { apps.add(new String[] { app[0], GetDataForApp(Integer.parseInt(app[1])) }); } return null; } @Override protected void onPostExecute(Object o) { super.onPostExecute(o); mProgress.dismiss(); for (String[] app : apps) { if (app[0].contains(".")) { continue; } TextView tv = new TextView(MainActivity.this); tv.setTextSize(18); tv.setText(app[0] + " || " + app[1]); ((TableLayout) ((LinearLayout) ((ScrollView) findViewById(R.id.LogsScrollView)) .getChildAt(0)).getChildAt(1)).addView(tv); View separator = new View(MainActivity.this); separator.setBackgroundColor(Color.BLACK); separator.setLayoutParams( new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 5)); ((TableLayout) ((LinearLayout) ((ScrollView) findViewById(R.id.LogsScrollView)) .getChildAt(0)).getChildAt(1)).addView(separator); } } }.execute(); //endregion break; } } }); //endregion //region Buttons WiFiAPButton = (Button) findViewById(R.id.WiFiAPButton); WiFiAPButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent i = new Intent(mainContext.getContext(), AccessPointsActivity.class); startActivity(i); } }); responseFiltersButton = (Button) findViewById(R.id.responseFiltersButton); responseFiltersButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(mainContext.getContext(), ResponseFiltersActivity.class); startActivity(i); } }); domainFiltersButton = (Button) findViewById(R.id.domainFiltersButton); domainFiltersButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(mainContext.getContext(), DomainFiltersActivity.class); startActivity(i); } }); domainManagerButton = (Button) findViewById(R.id.domainManagerButton); domainManagerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(mainContext.getContext(), DomainManagerActivity.class); startActivity(i); } }); permissionsPerDomainButton = (Button) findViewById(R.id.permissionsPerDomainButton); permissionsPerDomainButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(mainContext.getContext(), PermissionsPerDomainActivity.class); startActivity(i); } }); trustedAccessPointsButton = (Button) findViewById(R.id.trustedAccessPointsButton); trustedAccessPointsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(mainContext.getContext(), TrustedAccessPointsActivity.class); startActivity(i); } }); updateButton = (Button) findViewById(R.id.updateButton); updateButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // mark first time has not runned and update like it's initial . final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(MainActivity.this); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("firstTime", true); editor.commit(); DownloadInitialSettings(); } }); statisticsButton = (Button) findViewById(R.id.statisticsButton); statisticsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(mainContext.getContext(), StatisticsActivity.class); startActivity(i); } }); //endregion //region Action Bar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { setTitle(R.string.app_name); } //endregion //region Send Cached Settings //send cached settings if exist... BufferedReader br = null; try { File file = new File(MainContext.INSTANCE.getContext().getFilesDir(), "resend.inf"); StringBuilder content = new StringBuilder(); br = new BufferedReader(new FileReader(file)); String line; while ((line = br.readLine()) != null) { content.append(line); } if (content.toString().equals("1")) { File f = new File(file.getCanonicalPath()); f.delete(); new DatabaseHelper(MainActivity.this) .sendSettingsToServer(new RequestFilterUtil(MainActivity.this).getIMEI()); } } catch (Exception ex) { ex.getMessage(); } finally { try { br.close(); } catch (Exception ex) { ex.getMessage(); } } //endregion initializeProxyService(); }
From source file:com.demo.panguso.demo160714.view.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); frgCount = adapter.getCount();/*from www.j a va 2s. c o m*/ for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextSize(tabTitleTextSize); tabTitleView.setMaxLines(1); tabView.setOnClickListener(new TabClickListener()); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } textViewList.add(tabTitleView); } textViewList.get(0).setTextColor(selectedTitleTextColor); for (int i = 1; i < frgCount; i++) { textViewList.get(i).setTextColor(unselectedTitleTextColor); } }
From source file:com.example.testing.myapplication.module.pageSliding.PagerSlidingTabStrip.java
private void addTextTab(final int position, final String title) { TextView tab = new TextView(getContext()); tab.setText(title);// w w w .j a va2 s . c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setFocusable(true); //tab.setOnClickListener(new OnClickListener() { // @Override public void onClick(View v) { // pager.setCurrentItem(position); // v.setSelected(true); // } //}); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); v.setSelected(true); } }); tab.setPadding(tabPadding, 0, tabPadding, 0); tab.setBackgroundResource(tabBackgroundResId); tab.setTextColor(mTabTextColor); tab.setTextSize(tabTextSize); //tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setSelected(position == 0); // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a // pre-ICS-build if (textAllCaps) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tab.setAllCaps(true); } else { tab.setText(tab.getText().toString().toUpperCase(locale)); } } tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:com.android.loushi.loushi.util.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); frgCount = adapter.getCount();/*from ww w.j av a 2 s .c o m*/ for (int i = 0; i < adapter.getCount(); i++) { View tabView = null; TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setTextSize(tabTitleTextSize); tabTitleView.setMaxLines(1); tabView.setOnClickListener(new TabClickListener()); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } TextView tv_collect_cate = (TextView) tabView.findViewById(R.id.tv_tab_view_cate); if (i == 0) tv_collect_cate.setText(""); if (i == 1) tv_collect_cate.setText("?"); mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } textViewList.add(tabTitleView); } textViewList.get(0).setTextColor(selectedTitleTextColor); for (int i = 1; i < frgCount; i++) { textViewList.get(i).setTextColor(unselectedTitleTextColor); } }
From source file:com.example.kjpark.smartclass.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;// w w w .j a va 2 s .c o m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } if (mDistributeEvenly) { LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams(); lp.width = 0; lp.weight = 1; } tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector)); tabTitleView.setTextSize(14); if (adapter.getPageTitle(i) == "") { tabTitleView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_setting, 0, 0, 0); } else if (adapter.getPageTitle(i) == "") { tabTitleView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_message, 0, 0, 0); } else if (adapter.getPageTitle(i) == " ") { tabTitleView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_memory, 0, 0, 0); } else if (adapter.getPageTitle(i) == "") { tabTitleView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_assignment, 0, 0, 0); } else if (adapter.getPageTitle(i) == "") { tabTitleView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_notice, 0, 0, 0); } else { tabTitleView.setText(adapter.getPageTitle(i)); } tabView.setOnClickListener(tabClickListener); String desc = mContentDescriptions.get(i, null); if (desc != null) { tabView.setContentDescription(desc); } mTabStrip.addView(tabView); if (i == mViewPager.getCurrentItem()) { tabView.setSelected(true); } } }
From source file:com.example.drugsformarinemammals.Dose_Information.java
public void show_dose(ArrayList<Dose_Data> dose, TableLayout dose_table, TableRow dose_data, String drug_name, String group_name, String animal_family, String animal_name, String animal_category, ArrayList<String> notes, ArrayList<String> references, ArrayList<Article_Reference> references_index) { String doseAmount;//from www . ja va 2s .c o m String dosePosology; String doseRoute; String doseBookReference; String doseArticleReference; for (int k = 0; k < dose.size(); k++) { if (k > 0) { dose_data = new TableRow(this); } doseAmount = dose.get(k).getAmount(); dosePosology = dose.get(k).getPosology(); doseRoute = dose.get(k).getRoute(); doseBookReference = dose.get(k).getBookReference(); doseArticleReference = dose.get(k).getArticleReference(); //Dose amount data TextView textView_animal_dose_amount = new TextView(this); textView_animal_dose_amount.setText(doseAmount); textView_animal_dose_amount.setSingleLine(false); textView_animal_dose_amount.setTextColor(Color.BLACK); textView_animal_dose_amount.setTextSize(15); textView_animal_dose_amount.setTypeface(Typeface.SANS_SERIF); TableRow.LayoutParams paramsDoseAmount = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseAmount.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_amount, paramsDoseAmount); //Dose posology data TextView textView_animal_dose_posology = new TextView(this); textView_animal_dose_posology.setText(dosePosology); textView_animal_dose_posology.setSingleLine(false); textView_animal_dose_posology.setTextColor(Color.BLACK); textView_animal_dose_posology.setTextSize(15); textView_animal_dose_posology.setTypeface(Typeface.SANS_SERIF); TableRow.LayoutParams paramsDosePosology = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDosePosology.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Posology")) || screenWidth >= 600) dose_data.addView(textView_animal_dose_posology, paramsDosePosology); //Dose route data TextView textView_animal_dose_route = new TextView(this); textView_animal_dose_route.setText(doseRoute); textView_animal_dose_route.setSingleLine(false); textView_animal_dose_route.setTextColor(Color.BLACK); textView_animal_dose_route.setTextSize(15); textView_animal_dose_route.setTypeface(Typeface.SANS_SERIF); if (screenWidth >= 600) { TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseRoute.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_route, paramsDoseRoute); } else { TableRow.LayoutParams paramsDoseRoute = new TableRow.LayoutParams(30, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseRoute.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_route, paramsDoseRoute); } //Dose reference data TextView textView_animal_dose_reference = new TextView(this); if (!doseBookReference.equals("")) textView_animal_dose_reference.setText(doseBookReference); else if (!doseArticleReference.equals("")) { if (!references.contains(doseArticleReference)) { references.add(references.size(), doseArticleReference); Article_Reference article_reference = new Article_Reference(reference_index, doseArticleReference); references_index.add(references_index.size(), article_reference); reference_index++; } int article_index = references.indexOf(doseArticleReference); textView_animal_dose_reference.setText("(" + references_index.get(article_index).getIndex() + ")"); } textView_animal_dose_reference.setSingleLine(false); textView_animal_dose_reference.setTextColor(Color.BLACK); textView_animal_dose_reference.setTextSize(15); textView_animal_dose_reference.setTypeface(Typeface.SANS_SERIF); if (screenWidth >= 600) { TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseReference.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_reference, paramsDoseReference); } else { TableRow.LayoutParams paramsDoseReference = new TableRow.LayoutParams(150, TableRow.LayoutParams.WRAP_CONTENT); paramsDoseReference.gravity = Gravity.CENTER; dose_data.addView(textView_animal_dose_reference, paramsDoseReference); } //Specific note index ArrayList<String> specific_notes = new ArrayList<String>(); specific_notes = helper.read_specific_notes(drug_name, group_name, animal_name, animal_family, animal_category, doseAmount, dosePosology, doseRoute, doseBookReference, doseArticleReference); String index = ""; for (int m = 0; m < specific_notes.size(); m++) { String note = specific_notes.get(m); if (!notes.contains(note)) { notes.add(notes.size(), note); } index += "(" + (notes.indexOf(note) + 1) + ") "; } TextView textView_specific_note_index = new TextView(this); textView_specific_note_index.setText(index); textView_specific_note_index.setSingleLine(false); textView_specific_note_index.setTextColor(Color.BLACK); textView_specific_note_index.setTextSize(15); textView_specific_note_index.setTypeface(Typeface.SANS_SERIF); if (screenWidth >= 600 && screenWidth < 720) { TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(150, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNoteIndex.gravity = Gravity.CENTER; dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex); } else if (screenWidth >= 720) { TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams( TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNoteIndex.gravity = Gravity.CENTER; dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex); } else { TableRow.LayoutParams paramsSpecificNoteIndex = new TableRow.LayoutParams(100, TableRow.LayoutParams.WRAP_CONTENT); paramsSpecificNoteIndex.gravity = Gravity.CENTER; if ((screenWidth < 600 && !isCollapsed(drug_name, group_name, animal_family, "Note")) || screenWidth >= 600) dose_data.addView(textView_specific_note_index, paramsSpecificNoteIndex); } dose_table.addView(dose_data); } }