List of usage examples for android.widget TextView setPadding
@Override public void setPadding(int left, int top, int right, int bottom)
From source file:com.android.deskclock.timer.TimerView.java
/** * Measure the text and add a start padding to the view * @param textView view to measure and onb to which add start padding *//*from w w w .j ava 2 s . co m*/ private void addStartPadding(TextView textView) { final float gapPadding = 0.45f; // allDigits will contain ten digits: "0123456789" in the default locale String allDigits = String.format(Locale.getDefault(), "%010d", 123456789); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setTextSize(textView.getTextSize()); paint.setTypeface(textView.getTypeface()); float widths[] = new float[allDigits.length()]; int ll = paint.getTextWidths(allDigits, widths); int largest = 0; for (int ii = 1; ii < ll; ii++) { if (widths[ii] > widths[largest]) { largest = ii; } } // Add left padding to the view - Note: layout inherits LTR textView.setPadding((int) (gapPadding * widths[largest]), 0, 0, 0); }
From source file:com.huyn.demogroup.relativetop.PagerSlidingTabStrip.java
private void addIconAndTextTab(int position, int resId, String title) { LinearLayout tab = new LinearLayout(getContext()); tab.setGravity(Gravity.CENTER);/* ww w . ja va 2 s .c o m*/ TextView text = new TextView(getContext()); text.setText(title); text.setTextColor(Color.WHITE); text.setGravity(Gravity.CENTER); text.setSingleLine(); ImageView img = new ImageView(getContext()); img.setImageBitmap(iProvider.getBitmap(resId)); tab.addView(img); tab.addView(text); text.setPadding(10, 0, 0, 0); text.setTag("TEXT"); addTab(position, tab); }
From source file:com.itheima.googlemarket.PagerSlidingTabStrip.java
@SuppressWarnings("deprecation") private void updateTabStyles() { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); // StateListDrawable?????. StateListDrawable selector = createSelector(tabBackgroundPressed, tabBackgroundNormal); v.setBackgroundDrawable(selector); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab.setTypeface(tabTypeface, tabTypefaceStyle); tab.setTextColor(tabTextColor); tab.setPadding(tabPadding, 0, tabPadding, 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)); }//from w ww. j a va 2 s . c om } } } }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventFragment.java
@Override public void onActivityCreated(Bundle bundle) { if (null != bundle) { //Log.e("Saving","Found a bundle!!!!"); if (bundle.containsKey("eventStateAcknowledged") && bundle.getBoolean("eventStateAcknowledged")) { ackIcon.setImageResource(R.drawable.ic_acknowledged); isAcknowledged = true;//from www . j ava 2 s .co m } if (bundle.containsKey("Title")) Title.setText(bundle.getString("Title")); if (bundle.containsKey("Component")) Component.setText(bundle.getString("Component")); if (bundle.containsKey("EventClass")) EventClass.setText(bundle.getString("EventClass")); if (bundle.containsKey("Summary")) Summary.setText(Html.fromHtml(bundle.getString("Summary"), null, null)); if (bundle.containsKey("FirstTime")) FirstTime.setText(bundle.getString("FirstTime")); if (bundle.containsKey("LastTime")) LastTime.setText(bundle.getString("LastTime")); if (bundle.containsKey("EventCount")) EventCount.setText(bundle.getString("EventCount")); if (bundle.containsKey("agent")) agent.setText(bundle.getString("agent")); if (bundle.containsKey("LogEntries")) { try { String[] LogEntries = bundle.getStringArray("LogEntries"); int LogEntryCount = LogEntries.length; for (int i = 0; i < LogEntryCount; i++) { TextView newLog = new TextView(getActivity()); newLog.setText(Html.fromHtml(LogEntries[i])); newLog.setPadding(0, 6, 0, 6); logList.addView(newLog); } } catch (Exception e) { e.printStackTrace(); BugSenseHandler.sendExceptionMessage("ViewZenossEventFragment", "oncreate bundle", e); } } if (bundle.containsKey("img")) { try { img.setImageBitmap((Bitmap) bundle.getParcelable("img")); img.invalidate(); } catch (Exception e) { e.printStackTrace(); BugSenseHandler.sendExceptionMessage("ViewZenossEventFragment", "oncreate bundle image", e); } } progressbar.setVisibility(View.INVISIBLE); } else { //Log.e("Saving","Didn't find any data so getting it"); preLoadData(); } super.onActivityCreated(bundle); }
From source file:com.mk4droid.IMC_Activities.FActivity_TabHost.java
private LinearLayout InActivateColorize(LinearLayout ll, String text, Drawable dr) { // text/*ww w.j a v a 2 s . co m*/ TextView v = (TextView) ll.findViewWithTag("tv"); v.setText(text); v.setTextSize(10); v.setTextColor(Color.GRAY); v.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); dr.setColorFilter(0xFF888888, android.graphics.PorterDuff.Mode.SRC_ATOP); v.setCompoundDrawablesWithIntrinsicBounds(null, dr, null, null); v.setPadding(0, 5, 0, 2); v.setBackgroundDrawable(resources.getDrawable(R.drawable.gradient_tabs)); // hbar View hbar = ll.findViewWithTag("hbar"); hbar.setBackgroundDrawable(null); hbar.setBackgroundColor(resources.getColor(R.color.graylight)); return ll; }
From source file:com.timothy.android.api.fragment.PageFragment.java
public void setAllComponent(List<HtmlCleanAPI.HtmlContent> hcList) { Log.i(LOG_TAG, "setAllComponent()..."); for (HtmlCleanAPI.HtmlContent hc : hcList) { String tag = hc.getTag(); String content = hc.getContent(); String contentRBlank = StringUtil.rmvEnter(StringUtil.trim(StringUtil.mergeBlank(content))); String contentRSpecial = StringUtil.rmvSpecial(contentRBlank); if (StringUtil.isEmpty(content) || StringUtil.isEmpty(contentRBlank) || StringUtil.isEmpty(contentRSpecial)) { continue; }//from www. j a v a 2s. c om Log.i(LOG_TAG, "tag:" + tag); Log.i(LOG_TAG, "content:" + content); if (tag.equalsIgnoreCase("P")) { final TextView tagPTV = new TextView(mContext); tagPTV.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagPTV.setLayoutParams(lp); tagPTV.setPadding(3, 3, 3, 3); tagPTV.setPaddingRelative(3, 3, 3, 3); tagPTV.setMovementMethod(ScrollingMovementMethod.getInstance()); tagPTV.setTextColor(Color.BLACK); tagPTV.setText(contentRSpecial); tagPTV.setTextSize(TEXT_SIZE); tagPTV.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagPTV.getText().toString()); return false; } }); lineLayout.addView(tagPTV); } else if (tag.equalsIgnoreCase("pre")) { final TextView tagPre = new TextView(mContext); tagPre.setBackgroundColor(Color.parseColor("#D2EADE")); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagPre.setLayoutParams(lp); tagPre.setPadding(2, 2, 2, 2); tagPre.setPaddingRelative(2, 2, 2, 2); tagPre.setMovementMethod(ScrollingMovementMethod.getInstance()); tagPre.setTextColor(Color.BLACK); // String contentRSpecial = StringUtil.rmvSpecial(content); tagPre.setText(StringUtil.rmvSpecial(content)); tagPre.setTextSize(TEXT_SIZE); tagPre.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagPre.getText().toString()); return false; } }); lineLayout.addView(tagPre); } else if (tag.equalsIgnoreCase("dt") || tag.equalsIgnoreCase("H1") || tag.equalsIgnoreCase("H2") || tag.equalsIgnoreCase("H3")) {//title TextView tagDtHTV = new TextView(mContext); tagDtHTV.setBackgroundColor(Color.DKGRAY); tagDtHTV.setTypeface(null, Typeface.BOLD); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 0, 2, 0); tagDtHTV.setLayoutParams(lp); tagDtHTV.setPadding(2, 2, 2, 2); tagDtHTV.setPaddingRelative(2, 2, 2, 2); tagDtHTV.setMovementMethod(ScrollingMovementMethod.getInstance()); tagDtHTV.setTextColor(Color.WHITE); tagDtHTV.setText(contentRSpecial); tagDtHTV.setTextSize(TEXT_SIZE); lineLayout.addView(tagDtHTV); } else if (tag.equalsIgnoreCase("dd")) { final TextView tagDD = new TextView(mContext); tagDD.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagDD.setLayoutParams(lp); tagDD.setPadding(3, 3, 3, 3); tagDD.setPaddingRelative(3, 3, 3, 3); tagDD.setMovementMethod(ScrollingMovementMethod.getInstance()); tagDD.setTextColor(Color.BLACK); tagDD.setText(contentRSpecial); tagDD.setTextSize(TEXT_SIZE); tagDD.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagDD.getText().toString()); return false; } }); lineLayout.addView(tagDD); } else if (tag.equalsIgnoreCase("li")) { final TextView tagLigTV = new TextView(mContext); tagLigTV.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); tagLigTV.setLayoutParams(lp); tagLigTV.setPaddingRelative(2, 2, 2, 2); tagLigTV.setMovementMethod(ScrollingMovementMethod.getInstance()); tagLigTV.setTextColor(Color.BLACK); tagLigTV.setText(contentRSpecial); tagLigTV.setTextSize(TEXT_SIZE); tagLigTV.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { openDialog(tagLigTV.getText().toString()); return false; } }); lineLayout.addView(tagLigTV); } else if (tag.equalsIgnoreCase("img")) { final TextView imgTV = new TextView(mContext); imgTV.setBackgroundResource(R.drawable.tag_p_drawable); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); lp.setMargins(2, 2, 2, 2); imgTV.setLayoutParams(lp); imgTV.setPaddingRelative(2, 2, 2, 2); imgTV.setMovementMethod(ScrollingMovementMethod.getInstance()); imgTV.setTextColor(Color.BLACK); imgTV.setText(content); imgTV.setTextSize(TEXT_SIZE); imgTV.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { TextView tv = (TextView) v; String path = tv.getText().toString(); if (path != null && path.trim().length() > 0) { openDialog2(path); } } }); lineLayout.addView(imgTV); } } }
From source file:edu.cens.loci.ui.widget.GenericEditorView.java
private void updateWifiList(TableLayout table, LociWifiFingerprint wifi) { ArrayList<WifiViewListItem> items = new ArrayList<WifiViewListItem>(); HashMap<String, APInfoMapItem> apMap = wifi.getAps(); Set<String> keys = apMap.keySet(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { String bssid = iter.next(); APInfoMapItem ap = apMap.get(bssid); items.add(new WifiViewListItem(bssid, ap.ssid, ap.rss, ap.count, ap.rssBuckets)); }/*from w w w . j a v a 2 s. c om*/ Collections.sort(items); table.setColumnCollapsed(0, false); table.setColumnCollapsed(1, true); table.setColumnShrinkable(0, true); for (int i = 0; i < mAddedRows.size(); i++) { table.removeView(mAddedRows.get(i)); } mAddedRows.clear(); int totalCount = wifi.getScanCount(); Context context = getContext(); for (WifiViewListItem item : items) { TableRow row = new TableRow(context); TextView ssidView = new TextView(context); ssidView.setText(item.ssid); //ssidView.setText("very very very veryvery very very very very very"); ssidView.setPadding(2, 2, 2, 2); ssidView.setTextColor(0xffffffff); TextView bssidView = new TextView(context); bssidView.setText(item.bssid); bssidView.setPadding(2, 2, 2, 2); bssidView.setTextColor(0xffffffff); TextView cntView = new TextView(context); cntView.setText("" + (item.count * 100) / totalCount); cntView.setPadding(2, 2, 2, 2); cntView.setGravity(Gravity.CENTER); cntView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); TextView rssView = new TextView(context); rssView.setText("" + item.rss); rssView.setPadding(2, 2, 6, 2); rssView.setGravity(Gravity.CENTER); rssView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12); row.addView(ssidView, new TableRow.LayoutParams(0)); row.addView(bssidView, new TableRow.LayoutParams(1)); row.addView(cntView, new TableRow.LayoutParams(2)); row.addView(rssView, new TableRow.LayoutParams(3)); //Log.d(TAG, item.ssid); for (int i = 0; i < item.rssBuckets.length; i++) { TextView box = new TextView(context); box.setText(" "); box.setGravity(Gravity.RIGHT); box.setPadding(2, 2, 2, 2); box.setHeight(15); box.setGravity(Gravity.CENTER_VERTICAL); float colorVal = 256 * ((float) item.rssBuckets[i] / (float) wifi.getScanCount()); //Log.d(TAG, "colorVal=" + (int) colorVal + ", " + item.histogram[i]); int colorValInt = ((int) colorVal) - 1; if (colorValInt < 0) colorValInt = 0; box.setBackgroundColor(0xff000000 + colorValInt);//+ 0x000000ff * (item.histogram[i]/totScan)); box.setTextColor(0xffffffff); row.addView(box, new TableRow.LayoutParams(4 + i)); } row.setGravity(Gravity.CENTER); table.addView(row, new TableLayout.LayoutParams()); table.setColumnStretchable(3, true); mAddedRows.add(row); } }
From source file:com.prey.activities.CheckPasswordActivity.java
@Override protected void onResume() { super.onResume(); bindPasswordControls();/*from ww w. j a v a2 s . com*/ TextView device_ready_h2_text = (TextView) findViewById(R.id.device_ready_h2_text); final TextView textForgotPassword = (TextView) findViewById(R.id.link_forgot_password); Button password_btn_login = (Button) findViewById(R.id.password_btn_login); EditText password_pass_txt = (EditText) findViewById(R.id.password_pass_txt); TextView textView1 = (TextView) findViewById(R.id.textView1); TextView textView2 = (TextView) findViewById(R.id.textView2); Typeface titilliumWebRegular = Typeface.createFromAsset(getAssets(), "fonts/Titillium_Web/TitilliumWeb-Regular.ttf"); Typeface titilliumWebBold = Typeface.createFromAsset(getAssets(), "fonts/Titillium_Web/TitilliumWeb-Bold.ttf"); Typeface magdacleanmonoRegular = Typeface.createFromAsset(getAssets(), "fonts/MagdaClean/magdacleanmono-regular.ttf"); textView1.setTypeface(magdacleanmonoRegular); textView2.setTypeface(magdacleanmonoRegular); device_ready_h2_text.setTypeface(titilliumWebRegular); textForgotPassword.setTypeface(titilliumWebBold); password_btn_login.setTypeface(titilliumWebBold); password_pass_txt.setTypeface(magdacleanmonoRegular); try { textForgotPassword.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelUrl(); Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url)); startActivity(browserIntent); } catch (Exception e) { } } }); } catch (Exception e) { } TextView textView5_1 = (TextView) findViewById(R.id.textView5_1); TextView textView5_2 = (TextView) findViewById(R.id.textView5_2); textView5_1.setTypeface(magdacleanmonoRegular); textView5_2.setTypeface(titilliumWebBold); TextView textViewUninstall = (TextView) findViewById(R.id.textViewUninstall); LinearLayout linearLayoutTour = (LinearLayout) findViewById(R.id.linearLayoutTour); textViewUninstall.setTypeface(titilliumWebBold); if (PreyConfig.getPreyConfig(getApplication()).getProtectTour()) { linearLayoutTour.setVisibility(View.GONE); textViewUninstall.setVisibility(View.VISIBLE); textViewUninstall.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url = PreyConfig.getPreyConfig(getApplication()).getPreyUninstallUrl(); Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url)); startActivity(browserIntent); finish(); } }); } else { linearLayoutTour.setVisibility(View.VISIBLE); textViewUninstall.setVisibility(View.GONE); try { linearLayoutTour.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplication(), TourActivity1.class); Bundle b = new Bundle(); b.putInt("id", 1); intent.putExtras(b); startActivity(intent); finish(); } }); } catch (Exception e) { } } boolean showLocation = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { boolean canAccessFineLocation = PreyPermission.canAccessFineLocation(this); boolean canAccessCoarseLocation = PreyPermission.canAccessCoarseLocation(this); boolean canAccessCamera = PreyPermission.canAccessCamera(this); boolean canAccessReadPhoneState = PreyPermission.canAccessReadPhoneState(this); boolean canAccessReadExternalStorage = PreyPermission.canAccessReadExternalStorage(this); if (!canAccessFineLocation || !canAccessCoarseLocation || !canAccessCamera || !canAccessReadPhoneState || !canAccessReadExternalStorage) { AlertDialog.Builder builder = new AlertDialog.Builder(this); final FrameLayout frameView = new FrameLayout(this); builder.setView(frameView); final AlertDialog alertDialog = builder.create(); LayoutInflater inflater = alertDialog.getLayoutInflater(); View dialoglayout = inflater.inflate(R.layout.warning, frameView); TextView warning_title = (TextView) dialoglayout.findViewById(R.id.warning_title); TextView warning_body = (TextView) dialoglayout.findViewById(R.id.warning_body); warning_title.setTypeface(magdacleanmonoRegular); warning_body.setTypeface(titilliumWebBold); Button button_ok = (Button) dialoglayout.findViewById(R.id.button_ok); Button button_close = (Button) dialoglayout.findViewById(R.id.button_close); button_ok.setTypeface(titilliumWebBold); button_close.setTypeface(titilliumWebBold); final Activity thisActivity = this; button_ok.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PreyLogger.d("askForPermission"); askForPermission(); alertDialog.dismiss(); } }); button_close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PreyLogger.d("close ask"); alertDialog.dismiss(); } }); alertDialog.show(); showLocation = false; } else { showLocation = true; } } else { showLocation = true; } if (showLocation) { LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); boolean isGpsEnabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER); boolean isNetworkEnabled = mlocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (isGpsEnabled || isNetworkEnabled) { PreyLogger.d("isGpsEnabled || isNetworkEnabled"); } else { PreyLogger.d("no gps ni red"); AlertDialog.Builder builder = new AlertDialog.Builder(this); final AlertDialog alertDialog = builder.create(); TextView textview = new TextView(this); textview.setText(getString(R.string.location_settings)); textview.setMaxLines(10); textview.setTextSize(18F); textview.setPadding(20, 0, 20, 20); textview.setTextColor(Color.BLACK); builder.setView(textview); builder.setPositiveButton(getString(R.string.go_to_settings), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { dialoginterface.dismiss(); Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent, 0); return; } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialoginterface, int i) { dialoginterface.dismiss(); } }); builder.create().show(); } } }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossEventFragment.java
private void AddLogMessage(final String Message) { try {/*from www.j a v a 2s . co m*/ addMessageProgressDialog = new ProgressDialog(getActivity()); addMessageProgressDialog.setTitle("Contacting Zenoss"); addMessageProgressDialog.setMessage("Please wait:\nProcessing Event Log Updates"); addMessageProgressDialog.show(); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEventFragment", "AddLogMessage Dialog", e); } addLogMessageHandler = new Handler() { public void handleMessage(Message msg) { addMessageProgressDialog.dismiss(); if (msg.what == 1) { try { String[] tmp = LogEntries.clone(); final int NewArrlength = tmp.length + 1; LogEntries = new String[NewArrlength]; LogEntries[0] = "<strong>" + settings.getString("userName", "") + "</strong> wrote " + Message + "\n<br/><strong>At:</strong> Just now"; for (int i = 1; i < NewArrlength; ++i) // { LogEntries[i] = tmp[(i - 1)]; } TextView newLog = new TextView(getActivity()); newLog.setText(Html.fromHtml(LogEntries[0])); newLog.setPadding(0, 6, 0, 6); logList.addView(newLog); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEvent", "AddMessageProgressHandler", e); try { Toast.makeText(getActivity(), "The log message was successfully sent to Zenoss but an error occured when updating the UI", Toast.LENGTH_LONG).show(); } catch (Exception e1) { BugSenseHandler.sendExceptionMessage("ViewZenossEvent", "AddMessageProgressHandler Toast", e1); } } } else { try { Toast.makeText(getActivity(), "An error was encountered adding your message to the log", Toast.LENGTH_LONG).show(); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEvent", "AddMessageProgressHandler", e); } } } }; addLogMessageThread = new Thread() { public void run() { Boolean Success = false; try { if (API == null) { if (settings.getBoolean(ZenossAPI.PREFERENCE_IS_ZAAS, false)) { API = new ZenossAPIZaas(); } else { API = new ZenossAPICore(); } ZenossCredentials credentials = new ZenossCredentials(getActivity()); API.Login(credentials); } Success = API.AddEventLog(getArguments().getString("EventID"), Message); } catch (Exception e) { BugSenseHandler.sendExceptionMessage("ViewZenossEvent", "AddLogMessageThread", e); addLogMessageHandler.sendEmptyMessage(0); } if (Success) { addLogMessageHandler.sendEmptyMessage(1); } else { addLogMessageHandler.sendEmptyMessage(0); } } }; addLogMessageThread.start(); }
From source file:com.tony.selene.sliding.AbSlidingSmoothTabView.java
/** * ??tab.//from w w w . j a va2s .c om * * @param tabText * the tab text * @param fragment * the fragment */ public void addItemView(String tabText, Fragment fragment) { tabItemTextList.add(tabText); pagerItemList.add(fragment); tabItemList.clear(); mTabLayout.removeAllViews(); for (int i = 0; i < tabItemTextList.size(); i++) { final int index = i; String text = tabItemTextList.get(i); TextView tv = new TextView(this.context); tv.setTextColor(tabColor); tv.setTextSize(tabTextSize); tv.setText(text); tv.setGravity(Gravity.CENTER); tv.setLayoutParams(new LayoutParams(0, LayoutParams.FILL_PARENT, 1)); tv.setPadding(12, 5, 12, 5); tv.setFocusable(false); tabItemList.add(tv); mTabLayout.addView(tv); tv.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { mViewPager.setCurrentItem(index); } }); } // ? AbLogUtil.d(AbSlidingSmoothTabView.class, "addItemView finish"); mFragmentPagerAdapter.notifyDataSetChanged(); mViewPager.setCurrentItem(0); computeTabImg(0); }