List of usage examples for android.widget LinearLayout LinearLayout
public LinearLayout(Context context)
From source file:com.cssweb.android.base.QuoteGridActivity.java
protected void refreshUI(List<CssStock> list, String[] cols) throws JSONException { LinearLayout localLinearLayout1 = (LinearLayout) this.findViewById(R.id.zr_htable_lock); LinearLayout localLinearLayout2 = (LinearLayout) this.findViewById(R.id.zr_htable_linearlayout); this.mLinerLock = localLinearLayout1; this.mLinerHScroll = localLinearLayout2; this.mLinerLock.removeAllViews(); this.mLinerHScroll.removeAllViews(); if (nameOrcode) AddViewItem(cols[0], Utils.getTextColor(mContext, 0), mLinerLock, -1, 0, 0, true); else//w w w. j a va 2 s.co m AddViewItem(cols[1], Utils.getTextColor(mContext, 0), mLinerLock, -1, 0, 0, true); LinearLayout l1 = new LinearLayout(this); for (int i = 2; i < cols.length; i++) { if (i == cols.length - 1) AddViewItem(cols[i], Utils.getTextColor(mContext, 0), l1, -i, 100, 0, true); else AddViewItem(cols[i], Utils.getTextColor(mContext, 0), l1, -i, i - 1, 0, true); } mLinerHScroll.addView(l1); int mDigit = 1; double d0 = 0; for (int i = 1; i <= list.size(); i++) { CssStock cs = list.get(i - 1); d0 = cs.getZrsp(); //?? mDigit = Utils.getNumFormat(cs.getMarket(), cs.getStkcode()); //mLinerLock.setTag(i); if (nameOrcode) AddViewItem(Utils.clearSpace(cs.getStkname()), Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true); else AddViewItem(cs.getStkcode(), Utils.getTextColor(mContext, 1), mLinerLock, i, 0, i, true); l1 = new LinearLayout(this); l1.setTag(i); if (cs.getStkcode() == null || cs.getStkcode().equals("") || cs.getStkname() == null || cs.getStkname().equals("")) { AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 1, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 2, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 3, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 4, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 5, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 6, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 7, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 8, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 9, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 10, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 11, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 12, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 13, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 14, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 15, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 16, i, true); AddViewItem("", Utils.getTextColor(mContext, 0), l1, i, 100, i, true); } else if (cs.getTp() == 1) { AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 1, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 2, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 3, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 4, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 5, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 6, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 7, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 8, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 9, i, true); AddViewItem(Utils.dataFormation(cs.getZrsp(), mDigit), Utils.getTextColor(mContext, 0), l1, i, 10, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 11, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 12, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 13, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 14, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 15, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 16, i, true); AddViewItem(Utils.TP_TAG, Utils.getTextColor(mContext, 0), l1, i, 100, i, true); } else { // String str1; // if(cs.getZf()==0) // str1 = Utils.dataFormation(cs.getZf()*100, 1) + "%"; // else // str1 = Utils.dataFormation(cs.getZf()*100, 1) + "%"; AddViewItem(Utils.dataFormation(cs.getZf() * 100, 1), Utils.getTextColor(mContext, cs.getZf()), l1, i, 1, i, true); AddViewItem(Utils.dataFormation(cs.getZjcj(), mDigit), Utils.getTextColor(mContext, cs.getZjcj(), d0), l1, i, 2, i, true); AddViewItem(Utils.dataFormation(cs.getZd(), mDigit), Utils.getTextColor(mContext, cs.getZd()), l1, i, 3, i, true); AddViewItem(Utils.dataFormation(cs.getBjw1(), mDigit), Utils.getTextColor(mContext, cs.getBjw1(), d0), l1, i, 4, i, true); AddViewItem(Utils.dataFormation(cs.getSjw1(), mDigit), Utils.getTextColor(mContext, cs.getSjw1(), d0), l1, i, 5, i, true); AddViewItem(Utils.getAmountFormat(cs.getZl(), false, 1), Utils.getTextColor(mContext, 1), l1, i, 6, i, true); //AddViewItem(Utils.getAmountFormat(cs.getXs(), false, 1), Utils.getTextColor(mContext, 1), l1, i, 7, i, true); AddViewItem(Utils.getAmountFormat(cs.getXs(), false, 1), Utils.getTextColor(mContext, Utils.getColorFromBS(cs.getBsFlag())), l1, i, 7, i, true); // AddViewItem(Utils.dataFormation(cs.getHs()*100, 1) + "%", Utils.getTextColor(mContext, 5), l1, i, 8, i, true); //%? AddViewItem(Utils.dataFormation(cs.getHs() * 100, 1), Utils.getTextColor(mContext, 5), l1, i, 8, i, true); AddViewItem(Utils.dataFormation(cs.getJrkp(), mDigit), Utils.getTextColor(mContext, cs.getJrkp(), d0), l1, i, 9, i, true); AddViewItem(Utils.dataFormation(cs.getZrsp(), mDigit), Utils.getTextColor(mContext, 0), l1, i, 10, i, true); AddViewItem(Utils.dataFormation(cs.getZgcj(), mDigit), Utils.getTextColor(mContext, cs.getZgcj(), d0), l1, i, 11, i, true); AddViewItem(Utils.dataFormation(cs.getZdcj(), mDigit), Utils.getTextColor(mContext, cs.getZdcj(), d0), l1, i, 12, i, true); AddViewItem(Utils.getAmountFormat(cs.getZje(), false, 1), Utils.getTextColor(mContext, 2), l1, i, 13, i, true); AddViewItem(Utils.dataFormation(cs.getAmp() * 100, 1), Utils.getTextColor(mContext, 5), l1, i, 14, i, true); AddViewItem(Utils.dataFormation(cs.getLb(), 1), Utils.getTextColor(mContext, 1), l1, i, 15, i, true); // AddViewItem(Utils.dataFormation(cs.getWb(), 1), Utils.getTextColor(mContext, 5), l1, i, 16, i, true); //??? AddViewItem(Utils.dataFormation(cs.getWb() * 100, 1), Utils.getTextColor(mContext, cs.getWb()), l1, i, 16, i, true); AddViewItem(Utils.getAmountFormat(cs.getWc(), false), Utils.getTextColor(mContext, cs.getWc()), l1, i, 100, i, true); } mLinerHScroll.addView(l1); } }
From source file:com.freshplanet.nativeExtensions.C2DMBroadcastReceiver.java
private void extractColors(Context context) { if (notification_text_color != null) return;/*www .ja v a2 s . c o m*/ try { Notification ntf = new Notification(); ntf.setLatestEventInfo(context, COLOR_SEARCH_RECURSE_TIP, "Utest", null); LinearLayout group = new LinearLayout(context); ViewGroup event = (ViewGroup) ntf.contentView.apply(context, group); recurseGroup(context, event); group.removeAllViews(); } catch (Exception e) { notification_text_color = android.R.color.black; } }
From source file:com.googlecode.android_scripting.activity.Main.java
protected void initializeViews() { LinearLayout layout = new LinearLayout(this); layout.setOrientation(LinearLayout.VERTICAL); layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); layout.setGravity(Gravity.CENTER_HORIZONTAL); TextView textview = new TextView(this); textview.setText(" PhpForAndroid " + version); ImageView imageView = new ImageView(this); imageView.setImageDrawable(getResources().getDrawable(R.drawable.pfa)); layout.addView(imageView);//from w w w. j a va 2 s . c om mButton = new Button(this); mAboutButton = new Button(this); MarginLayoutParams marginParams = new MarginLayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); final float scale = getResources().getDisplayMetrics().density; int marginPixels = (int) (MARGIN_DIP * scale + 0.5f); marginParams.setMargins(marginPixels, marginPixels, marginPixels, marginPixels); mButton.setLayoutParams(marginParams); mAboutButton.setLayoutParams(marginParams); layout.addView(textview); layout.addView(mButton); layout.addView(mAboutButton); mProgressLayout = new LinearLayout(this); mProgressLayout.setOrientation(LinearLayout.HORIZONTAL); mProgressLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); mProgressLayout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL); LinearLayout bottom = new LinearLayout(this); bottom.setOrientation(LinearLayout.HORIZONTAL); bottom.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); bottom.setGravity(Gravity.CENTER_VERTICAL); mProgressLayout.addView(bottom); TextView message = new TextView(this); message.setText(" In Progress..."); message.setTextSize(20); message.setTypeface(Typeface.DEFAULT_BOLD); message.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); ProgressBar bar = new ProgressBar(this); bar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); bottom.addView(bar); bottom.addView(message); mProgressLayout.setVisibility(View.INVISIBLE); layout.addView(mProgressLayout); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setProgressBarIndeterminateVisibility(false); setContentView(layout); }
From source file:it.redturtle.mobile.apparpav.MeteogramAdapter.java
/** * SINGLE TEXT ROW/*from w ww .jav a2 s . c o m*/ * @param att * @param linear * @return */ public LinearLayout getSingleTextRow(Map<String, String> att, LinearLayout linear) { LinearLayout container_layout = new LinearLayout(context); container_layout.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.view_shape_meteo)); container_layout.setMinimumHeight(46); container_layout.setVerticalGravity(Gravity.CENTER); LinearLayout.LayoutParams value = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5f); TextView tx = new TextView(context); tx.setText(att.get("title")); tx.setTextSize(11); tx.setTypeface(null, Typeface.BOLD); tx.setGravity(Gravity.LEFT); tx.setPadding(3, 0, 0, 2); tx.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(tx, value); LinearLayout.LayoutParams value_params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0.5f); TextView t2 = new TextView(context); t2.setText(att.get("value").equals("") ? " - " : att.get("value")); t2.setTextSize(11); t2.setGravity(Gravity.CENTER_HORIZONTAL); t2.setPadding(2, 0, 0, 2); t2.setTextColor(Color.rgb(66, 66, 66)); container_layout.addView(t2, value_params); linear.addView(container_layout); return linear; }
From source file:com.microsoft.windowsazure.mobileservices.LoginManager.java
/** * Creates the UI for the interactive authentication process * /*from w w w. j av a2 s. c o m*/ * @param provider * The provider used for the authentication process * @param startUrl * The initial URL for the authentication process * @param endUrl * The final URL for the authentication process * @param context * The context used to create the authentication dialog * @param callback * Callback to invoke when the authentication process finishes */ private void showLoginUI(final String startUrl, final String endUrl, final Context context, LoginUIOperationCallback callback) { if (startUrl == null || startUrl == "") { throw new IllegalArgumentException("startUrl can not be null or empty"); } if (endUrl == null || endUrl == "") { throw new IllegalArgumentException("endUrl can not be null or empty"); } if (context == null) { throw new IllegalArgumentException("context can not be null"); } final LoginUIOperationCallback externalCallback = callback; final AlertDialog.Builder builder = new AlertDialog.Builder(context); // Create the Web View to show the login page final WebView wv = new WebView(context); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException("User Canceled")); } } }); wv.getSettings().setJavaScriptEnabled(true); DisplayMetrics displaymetrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int webViewHeight = displaymetrics.heightPixels; wv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, webViewHeight)); wv.requestFocus(View.FOCUS_DOWN); wv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) { if (!view.hasFocus()) { view.requestFocus(); } } return false; } }); // Create a LinearLayout and add the WebView to the Layout LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(wv); // Add a dummy EditText to the layout as a workaround for a bug // that prevents showing the keyboard for the WebView on some devices EditText dummyEditText = new EditText(context); dummyEditText.setVisibility(View.GONE); layout.addView(dummyEditText); // Add the layout to the dialog builder.setView(layout); final AlertDialog dialog = builder.create(); wv.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { // If the URL of the started page matches with the final URL // format, the login process finished if (isFinalUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(url, null); } dialog.dismiss(); } super.onPageStarted(view, url, favicon); } // Checks if the given URL matches with the final URL's format private boolean isFinalUrl(String url) { if (url == null) { return false; } return url.startsWith(endUrl); } // Checks if the given URL matches with the start URL's format private boolean isStartUrl(String url) { if (url == null) { return false; } return url.startsWith(startUrl); } @Override public void onPageFinished(WebView view, String url) { if (isStartUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException( "Logging in with the selected authentication provider is not enabled")); } dialog.dismiss(); } } }); wv.loadUrl(startUrl); dialog.show(); }
From source file:edu.rowan.app.fragments.FoodRatingFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout view = new LinearLayout(getActivity()); view.setOrientation(LinearLayout.VERTICAL); // view pager indicator TitlePageIndicator pageIndicator = new TitlePageIndicator(getActivity()); pageIndicator.setBackgroundResource(R.color.rowanBrown); fragmentPager = new ViewPager(getActivity()); fragmentPager.setId(VIEW_PAGER_ID);//from w ww.j av a 2 s.co m fragmentAdapter = new FoodRatingAdapter(getChildFragmentManager()); fragmentPager.setAdapter(fragmentAdapter); //View view = inflater.inflate(R.layout.activity_main, container, false); pageIndicator.setViewPager(fragmentPager); view.addView(pageIndicator); view.addView(fragmentPager); return view; }
From source file:org.openremote.android.console.GroupActivity.java
/** * Init group and screen, if it is first access, init the first group * and first screen, else init the last time group and screen. If no * group or screen found, can configure settings. * //from w w w . j a va 2 s .c om */ private void recoverLastGroupScreen() { int lastGroupID = UserCache.getLastGroupId(this); Group lastGroup = XMLEntityDataBase.getGroup(lastGroupID); if (lastGroup == null) { lastGroup = XMLEntityDataBase.getFirstGroup(); } if (lastGroup == null || lastGroup.getScreens().size() == 0) { if (!useLocalCache) { ViewHelper.showAlertViewWithSetting(this, "No Group Found", "please config Settings again"); } return; } screenSize = lastGroup.getScreenSizeByOrientation(isLandscape); if (screenSize == 0) { ViewHelper.showAlertViewWithTitle(this, "Info", "The group " + lastGroup.getName() + " has no " + (isLandscape ? "landscape" : "portrait") + " screen."); isLandscape = !isLandscape; screenSize = lastGroup.getScreenSizeByOrientation(isLandscape); } currentGroupView = new GroupView(this, lastGroup); groupViews.put(lastGroup.getGroupId(), currentGroupView); currentScreenViewFlipper = currentGroupView.getScreenViewFlipperByOrientation(isLandscape); int lastScreenID = UserCache.getLastScreenId(this); if (lastScreenID > 0 && lastGroup.canfindScreenByIdAndOrientation(lastScreenID, isLandscape)) { currentScreenViewFlipper.setDisplayedChild(getScreenIndex(lastScreenID, isLandscape)); } contentLayout = new LinearLayout(this); contentLayout.addView(currentScreenViewFlipper); this.setContentView(contentLayout); ScreenView currentScreenView = (ScreenView) currentScreenViewFlipper.getCurrentView(); if (currentScreenView == null) { return; } UserCache.saveLastGroupIdAndScreenId(GroupActivity.this, currentGroupView.getGroup().getGroupId(), currentScreenView.getScreen().getScreenId()); currentScreen = currentScreenView.getScreen(); addNaviagateListener(); }
From source file:busradar.madison.StopDialog.java
StopDialog(final Context ctx, final int stopid, final int lat, final int lon) { super(ctx);/* w w w . j ava 2 s . c om*/ this.stopid = stopid; // getWindow().requestFeature(Window.FEATURE_LEFT_ICON); getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); final String name = DB.getStopName(stopid); setTitle(name); routes = get_time_urls(StopDialog.this.stopid); // getWindow().setLayout(LayoutParams.FILL_PARENT, // LayoutParams.FILL_PARENT); setContentView(new RelativeLayout(ctx) { { addView(new TextView(ctx) { { setId(stop_num_id); setText(Html.fromHtml(String.format( "[<a href='http://www.cityofmadison.com/metro/BusStopDepartures/StopID/%04d.pdf'>%04d</a>]", stopid, stopid))); setPadding(0, 0, 5, 0); this.setMovementMethod(LinkMovementMethod.getInstance()); } }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) { { addRule(ALIGN_PARENT_RIGHT); } }); addView(new ImageView(ctx) { boolean enabled; @Override public void setEnabled(boolean e) { enabled = e; setImageResource(e ? R.drawable.love_enabled : R.drawable.love_disabled); if (e) { G.favorites.add_favorite_stop(stopid, name, lat, lon); Toast.makeText(ctx, "Added stop to Favorites", Toast.LENGTH_SHORT).show(); } else { G.favorites.remove_favorite_stop(stopid); Toast.makeText(ctx, "Removed stop from Favorites", Toast.LENGTH_SHORT).show(); } } { enabled = G.favorites.is_stop_favorite(stopid); setImageResource(enabled ? R.drawable.love_enabled : R.drawable.love_disabled); setPadding(0, 0, 10, 0); setOnClickListener(new OnClickListener() { public void onClick(View v) { setEnabled(!enabled); } }); } }, new RelativeLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT) { { addRule(LEFT_OF, stop_num_id); setMargins(0, -3, 0, 0); } }); addView(cur_loading_text = new TextView(ctx) { { setText("Loading..."); setPadding(5, 0, 0, 0); } }); addView(new HorizontalScrollView(ctx) { { setId(route_list_id); setHorizontalScrollBarEnabled(false); addView(new LinearLayout(ctx) { float text_size; Button cur_button; { int last_route = -1; for (int i = 0; i < routes.length; i++) { final RouteURL route = routes[i]; if (route.route == last_route) continue; last_route = route.route; addView(new Button(ctx) { public void setEnabled(boolean e) { if (e) { setBackgroundColor(0xff000000 | G.route_points[route.route].color); setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size * 1.5f); } else { setBackgroundColor(0x90000000 | G.route_points[route.route].color); setTextSize(TypedValue.COMPLEX_UNIT_PX, text_size); } } { setText(G.route_points[route.route].name); setTextColor(0xffffffff); setTypeface(Typeface.DEFAULT_BOLD); text_size = getTextSize(); if (G.active_route == route.route) { setEnabled(true); cur_button = this; } else setEnabled(false); final Button b = this; setOnClickListener(new OnClickListener() { public void onClick(View v) { if (cur_button != null) { cur_button.setEnabled(false); } if (cur_button == b) { cur_button.setEnabled(false); cur_button = null; selected_route = null; update_time_display(); } else { cur_button = b; cur_button.setEnabled(true); selected_route = route; update_time_display(); } } }); } }); } } }); } }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) { { addRule(RelativeLayout.BELOW, stop_num_id); addRule(RelativeLayout.CENTER_HORIZONTAL); } }); addView(status_text = new TextView(ctx) { { setText(""); } }, new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT) { { addRule(RelativeLayout.BELOW, route_list_id); addRule(RelativeLayout.CENTER_HORIZONTAL); } }); addView(list_view = new ListView(ctx) { { setId(time_list_id); setVerticalScrollBarEnabled(false); setAdapter(times_adapter = new BaseAdapter() { public View getView(final int position, View convertView, ViewGroup parent) { CellView v; if (convertView == null) v = new CellView(ctx); else v = (CellView) convertView; RouteTime rt = curr_times.get(position); v.setBackgroundColor(G.route_points[rt.route].color | 0xff000000); v.route_textview.setText(G.route_points[rt.route].name); if (rt.dir != null) v.dir_textview.setText("to " + rt.dir); v.time_textview.setText(rt.time); return v; } public int getCount() { return curr_times.size(); } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } }); } }, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT) { { addRule(RelativeLayout.BELOW, route_list_id); } }); } }); TextView title = (TextView) findViewById(android.R.id.title); title.setEllipsize(TextUtils.TruncateAt.MARQUEE); title.setSelected(true); title.setTextColor(0xffffffff); title.setMarqueeRepeatLimit(-1); // getWindow().set, value) // getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, // android.R.drawable.ic_dialog_info); // title.setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL); if (G.active_route >= 0) for (int i = 0; i < routes.length; i++) if (routes[i].route == G.active_route) { selected_route = routes[i]; RouteURL[] rnew = new RouteURL[routes.length]; rnew[0] = selected_route; for (int j = 0, k = 1; j < routes.length; j++) if (j != i) rnew[k++] = routes[j]; routes = rnew; break; } update_time_display(); }
From source file:com.example.fragmentdemo.views.PagerSlidingTabStrip.java
private void addTab(final int position, CharSequence title, int iconResId, int iLayoutResId, int iTextId, int iIconLocation) { // final View tabView = ((Activity) getContext()).getLayoutInflater() // .inflate(iLayoutResId, null); // TextView tab_text_textview = (TextView) // tabView.findViewById(iTextId); // tab_text_textview.setText(title); LinearLayout tabView = new LinearLayout(getContext()); tabView.setGravity(Gravity.CENTER);//from w ww.j a v a 2s. co m TextView tab_text_textview = new TextView(getContext()); tab_text_textview.setId(position); tab_text_textview.setText(title); tab_text_textview.setGravity(Gravity.CENTER_VERTICAL); tab_text_textview.setSingleLine(); // tab_text_textview.setTextColor(tabTextColor); // tab_text_textview.setTextColor(getResources().getColor(R.color.indicator_tab_main_text_color)); XmlPullParser xrp = getResources().getXml(tabTextColor); try { ColorStateList csl = ColorStateList.createFromXml(getResources(), xrp); if (tab_text_textview != null) { tab_text_textview.setTextColor(csl); } } catch (Exception e) { } tab_text_textview.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize); tab_text_textview.setTypeface(tabTypeface, tabTypefaceStyle); LinearLayout.LayoutParams lpText = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); if (iconResId != 0) { // tab_text_textview.setCompoundDrawablesWithIntrinsicBounds( // iconResId, 0, 0, 0); // Drawable mDrawable = ((Activity) getContext()).getResources() // .getDrawable(iconResId); // mDrawable.setBounds(0, 0, mDrawable.getMinimumWidth(), // mDrawable.getMinimumHeight()); int iPandding = (int) ((Activity) getContext()).getResources().getDimension(R.dimen.common_padding); ImageView icon = new ImageView(getContext()); icon.setImageResource(iconResId); icon.setScaleType(ScaleType.CENTER_INSIDE); LinearLayout.LayoutParams lpImage = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, iIconHeight); switch (iIconLocation) { case 1: // tab_text_textview.setCompoundDrawables(mDrawable, null, null, // null); tabView.setOrientation(LinearLayout.HORIZONTAL); // tabView.setGravity(Gravity.CENTER_VERTICAL); tabView.addView(icon, lpImage); lpText.leftMargin = iPandding; tabView.addView(tab_text_textview, lpText); break; case 2: // tab_text_textview.setCompoundDrawables(null, mDrawable, null, // null); tabView.setOrientation(LinearLayout.VERTICAL); // tabView.setGravity(Gravity.CENTER_HORIZONTAL); tabView.addView(icon, lpImage); lpText.topMargin = iPandding; tabView.addView(tab_text_textview, lpText); break; case 3: // tab_text_textview.setCompoundDrawables(null, null, mDrawable, // null); tabView.setOrientation(LinearLayout.HORIZONTAL); // tabView.setGravity(Gravity.CENTER_VERTICAL); tabView.addView(tab_text_textview, lpText); lpImage.leftMargin = iPandding; tabView.addView(icon, lpImage); break; case 4: // tab_text_textview.setCompoundDrawables(null, null, null, // mDrawable); tabView.setOrientation(LinearLayout.VERTICAL); // tabView.setGravity(Gravity.CENTER_HORIZONTAL); tabView.addView(tab_text_textview, lpText); lpImage.topMargin = iPandding; tabView.addView(icon, lpImage); break; default: // tab_text_textview.setCompoundDrawables(mDrawable, null, null, // null); tabView.setOrientation(LinearLayout.HORIZONTAL); // tabView.setGravity(Gravity.CENTER_VERTICAL); tabView.addView(icon, lpImage); lpText.leftMargin = iPandding; tabView.addView(tab_text_textview, lpText); break; } // tab_text_textview // .setCompoundDrawablePadding((int) ((Activity) getContext()) // .getResources() // .getDimension(R.dimen.common_padding)); } else { tabView.addView(tab_text_textview, lpText); } tabView.setFocusable(true); tabView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); // tab_text_textview.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }