List of usage examples for android.widget RelativeLayout CENTER_HORIZONTAL
int CENTER_HORIZONTAL
To view the source code for android.widget RelativeLayout CENTER_HORIZONTAL.
Click Source Link
From source file:edu.htl3r.schoolplanner.gui.timetable.ViewPagerIndicator.java
/** * Create all views, build the layout//from w w w . j ava 2s .co m */ private void addContent() { mFocusedTextColor = new int[] { 0, 0, 0 }; mUnfocusedTextColor = new int[] { 190, 190, 190 }; // Text views mPrevious = new TextView(getContext()); mCurrent = new TextView(getContext()); mNext = new TextView(getContext()); RelativeLayout.LayoutParams previousParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); previousParams.addRule(RelativeLayout.ALIGN_LEFT); RelativeLayout.LayoutParams currentParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); currentParams.addRule(RelativeLayout.CENTER_HORIZONTAL); RelativeLayout.LayoutParams nextParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); nextParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); // Groups holding text and arrows mPreviousGroup = new LinearLayout(getContext()); mPreviousGroup.setOrientation(LinearLayout.HORIZONTAL); mNextGroup = new LinearLayout(getContext()); mNextGroup.setOrientation(LinearLayout.HORIZONTAL); mPreviousGroup.addView(mPrevious, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); mNextGroup.addView(mNext, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); addView(mPreviousGroup, previousParams); addView(mCurrent, currentParams); addView(mNextGroup, nextParams); mPrevious.setSingleLine(); mCurrent.setSingleLine(); mNext.setSingleLine(); mPrevious.setText("previous"); mCurrent.setText("current"); mNext.setText("next"); // Set colors mNext.setTextColor(Color.argb(255, mUnfocusedTextColor[0], mUnfocusedTextColor[1], mUnfocusedTextColor[2])); mPrevious.setTextColor( Color.argb(255, mUnfocusedTextColor[0], mUnfocusedTextColor[1], mUnfocusedTextColor[2])); updateColor(0); }
From source file:com.dazone.crewchat.libGallery.activity.BucketHomeFragmentActivity.java
@SuppressLint("ResourceAsColor") @Override//from w w w . j av a 2s . c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Instance = this; requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_home_media_chooser); headerBarTitle = (TextView) findViewById(R.id.titleTextViewFromMediaChooserHeaderBar); headerBarCamera = (ImageView) findViewById(R.id.cameraImageViewFromMediaChooserHeaderBar); headerBarBack = (ImageView) findViewById(R.id.backArrowImageViewFromMediaChooserHeaderView); headerBarDone = (TextView) findViewById(R.id.doneTextViewViewFromMediaChooserHeaderView); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); headerBarTitle.setText(getResources().getString(R.string.app_name)); headerBarCamera.setBackgroundResource(R.drawable.ic_camera_unselect_from_media_chooser_header_bar); headerBarCamera.setTag(getResources().getString(R.string.image)); headerBarBack.setOnClickListener(clickListener); headerBarCamera.setOnClickListener(clickListener); headerBarDone.setOnClickListener(clickListener); if (!MediaChooserConstants.showCameraVideo) { headerBarCamera.setVisibility(View.GONE); } mTabHost.setup(this, getSupportFragmentManager(), R.id.realTabcontent); if (MediaChooserConstants.showVideo) { mTabHost.addTab( mTabHost.newTabSpec("tab2") .setIndicator(getResources().getString(R.string.videos_tab) + " "), BucketVideoFragment.class, null); } if (MediaChooserConstants.showImage) { mTabHost.addTab( mTabHost.newTabSpec("tab1") .setIndicator(getResources().getString(R.string.images_tab) + " "), BucketImageFragment.class, null); } mTabHost.getTabWidget().setBackgroundColor(getResources().getColor(R.color.tabs_color)); mTabHost.getTabWidget().getChildAt(0).setVisibility(View.GONE); for (int i = 0; i < mTabHost.getTabWidget().getChildCount(); i++) { View childView = mTabHost.getTabWidget().getChildAt(i); TextView textView = (TextView) childView.findViewById(android.R.id.title); if (textView.getLayoutParams() instanceof RelativeLayout.LayoutParams) { RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) textView.getLayoutParams(); params.addRule(RelativeLayout.CENTER_HORIZONTAL); params.addRule(RelativeLayout.CENTER_VERTICAL); params.height = RelativeLayout.LayoutParams.MATCH_PARENT; params.width = RelativeLayout.LayoutParams.WRAP_CONTENT; textView.setLayoutParams(params); } else if (textView.getLayoutParams() instanceof LinearLayout.LayoutParams) { LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) textView.getLayoutParams(); params.gravity = Gravity.CENTER; textView.setLayoutParams(params); } textView.setTextColor(ContextCompat.getColor(this, R.color.tabs_title_color)); textView.setTextSize(convertDipToPixels(10)); } /* ((TextView)(mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))).setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView)(mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))).setTextColor(Color.WHITE);*/ mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { FragmentManager fragmentManager = getSupportFragmentManager(); BucketImageFragment imageFragment = (BucketImageFragment) fragmentManager.findFragmentByTag("tab1"); BucketVideoFragment videoFragment = (BucketVideoFragment) fragmentManager.findFragmentByTag("tab2"); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); if (tabId.equalsIgnoreCase("tab1")) { headerBarTitle.setText(getResources().getString(R.string.image)); headerBarCamera.setBackgroundResource(R.drawable.selector_camera_button); headerBarCamera.setTag(getResources().getString(R.string.image)); if (imageFragment == null) { BucketImageFragment newImageFragment = new BucketImageFragment(); fragmentTransaction.add(R.id.realTabcontent, newImageFragment, "tab1"); } else { if (videoFragment != null) { fragmentTransaction.hide(videoFragment); } fragmentTransaction.show(imageFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); } else { headerBarTitle.setText(getResources().getString(R.string.video)); headerBarCamera.setBackgroundResource(R.drawable.selector_video_button); headerBarCamera.setTag(getResources().getString(R.string.video)); if (videoFragment == null) { final BucketVideoFragment newVideoFragment = new BucketVideoFragment(); fragmentTransaction.add(R.id.realTabcontent, newVideoFragment, "tab2"); } else { if (imageFragment != null) { fragmentTransaction.hide(imageFragment); } fragmentTransaction.show(videoFragment); } ((TextView) (mTabHost.getTabWidget().getChildAt(0).findViewById(android.R.id.title))) .setTextColor(Color.WHITE); ((TextView) (mTabHost.getTabWidget().getChildAt(1).findViewById(android.R.id.title))) .setTextColor(getResources().getColor(R.color.headerbar_selected_tab_color)); } fragmentTransaction.commit(); } }); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) headerBarCamera.getLayoutParams(); params.height = convertDipToPixels(40); params.width = convertDipToPixels(40); headerBarCamera.setLayoutParams(params); headerBarCamera.setScaleType(ScaleType.CENTER_INSIDE); headerBarCamera.setPadding(convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15), convertDipToPixels(15)); }
From source file:edu.rowan.app.carousel.CarouselFeature.java
private void setupView() { imageView.setId(1);// w ww . jav a 2 s.c o m RelativeLayout.LayoutParams imageParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); imageParams.addRule(RelativeLayout.CENTER_HORIZONTAL); imageView.setLayoutParams(imageParams); // imageView.setAdjustViewBounds(true); Resources r = context.getResources(); int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5, r.getDisplayMetrics()); TextView descriptionView = new TextView(context); descriptionView.setId(2); descriptionView.setPadding(padding, 0, padding, padding); descriptionView.setText(description); descriptionView.setBackgroundColor(Color.argb(220, 63, 26, 10)); descriptionView.setTextColor(Color.WHITE); RelativeLayout.LayoutParams descParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); descParams.addRule(RelativeLayout.ALIGN_BOTTOM, imageView.getId()); carouselView.addView(descriptionView, descParams); TextView titleView = new TextView(context); titleView.setText(title); titleView.setPadding(padding, 0, padding, 0); RelativeLayout.LayoutParams titleParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); titleParams.addRule(RelativeLayout.ABOVE, descriptionView.getId()); titleView.setLayoutParams(titleParams); titleView.setTextColor(Color.WHITE); titleView.setShadowLayer(2, 3, 3, Color.argb(230, 0, 0, 0)); titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); carouselView.addView(titleView); }
From source file:com.githang.androidkit.app.IntroActivity.java
/** * /*from w w w . j ava2s.c om*/ */ private void createContentView() { // ? mIntroResource = new IntroResource(); setIntroViews(mIntroResource); // RelativeLayout rootView = new RelativeLayout(this); rootView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // mViewPager = new ViewPager(this); RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); rootView.addView(mViewPager, pagerParams); // LinearLayout indicatorLayout = new LinearLayout(this); RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom; indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL); indicatorLayout.setLayoutParams(indicatorParams); indicatorLayout.setOrientation(LinearLayout.HORIZONTAL); // int indicatorCount = mIntroResource.views.size(); int padding = mIntroResource.indicatorImagePadding; mIndicator = new ArrayList<ImageView>(); for (int i = 0; i < indicatorCount; i++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); imageView.setPadding(padding, padding, padding, padding); imageView.setClickable(true); imageView.setOnClickListener(this); imageView.setImageResource(mIntroResource.indicatorNoSelectedId); imageView.setTag(i); mIndicator.add(imageView); indicatorLayout.addView(imageView, imageParams); } rootView.addView(indicatorLayout); setContentView(rootView); }
From source file:com.lurencun.cfuture09.androidkit.uilibs.IntroActivity.java
/** * //from ww w .ja v a2s .c o m */ private void createContentView() { // ? mIntroResource = new IntroResource(); setIntroViews(mIntroResource); // RelativeLayout rootView = new RelativeLayout(this); rootView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // mViewPager = new ViewPager(this); RelativeLayout.LayoutParams pagerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT); rootView.addView(mViewPager, pagerParams); // LinearLayout indicatorLayout = new LinearLayout(this); RelativeLayout.LayoutParams indicatorParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); indicatorParams.bottomMargin = mIntroResource.indicatorMarginBottom; indicatorParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); indicatorParams.addRule(RelativeLayout.CENTER_HORIZONTAL); indicatorLayout.setLayoutParams(indicatorParams); indicatorLayout.setOrientation(LinearLayout.HORIZONTAL); // int indicatorCount = mIntroResource.views.size(); int padding = mIntroResource.indicatorImagePadding; mIndicator = new ArrayList<ImageView>(); for (int i = 0; i < indicatorCount; i++) { ImageView imageView = new ImageView(this); LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); imageView.setPadding(padding, padding, padding, padding); imageView.setClickable(true); imageView.setOnClickListener(this); imageView.setImageResource(mIntroResource.indicatorNoSelectedId); imageView.setTag(i); mIndicator.add(imageView); indicatorLayout.addView(imageView, imageParams); } rootView.addView(indicatorLayout); setContentView(rootView); }
From source file:net.homelinux.penecoptero.android.citybikes.donation.app.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w ww.j a v a 2 s . co m PreferenceManager.setDefaultValues(this, R.xml.preferences, false); mapView = (MapView) findViewById(R.id.mapview); mSlidingDrawer = (StationSlidingDrawer) findViewById(R.id.drawer); infoLayer = (InfoLayer) findViewById(R.id.info_layer); scale = getResources().getDisplayMetrics().density; //Log.i("CityBikes","ON CREATEEEEEEEEE!!!!!"); infoLayerPopulator = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == InfoLayer.POPULATE) { infoLayer.inflateStation(stations.getCurrent()); } if (msg.what == CityBikes.BOOKMARK_CHANGE) { int id = msg.arg1; boolean bookmarked; if (msg.arg2 == 0) { bookmarked = false; } else { bookmarked = true; } StationOverlay station = stations.getById(id); try { BookmarkManager bm = new BookmarkManager(getApplicationContext()); bm.setBookmarked(station.getStation(), !bookmarked); } catch (Exception e) { Log.i("CityBikes", "Error bookmarking station"); e.printStackTrace(); } if (!view_all) { view_near(); } mapView.postInvalidate(); } } }; infoLayer.setHandler(infoLayerPopulator); RelativeLayout.LayoutParams zoomControlsLayoutParams = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); zoomControlsLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); zoomControlsLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); mapView.addView(mapView.getZoomControls(), zoomControlsLayoutParams); modeButton = (ToggleButton) findViewById(R.id.mode_button); modeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { changeMode(!getBike); } }); applyMapViewLongPressListener(mapView); settings = getSharedPreferences(CityBikes.PREFERENCES_NAME, 0); List<Overlay> mapOverlays = mapView.getOverlays(); locator = new Locator(this, new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == Locator.LOCATION_CHANGED) { GeoPoint point = new GeoPoint(msg.arg1, msg.arg2); hOverlay.moveCenter(point); mapView.getController().animateTo(point); mDbHelper.setCenter(point); // Location has changed try { mDbHelper.updateDistances(point); infoLayer.update(); if (!view_all) { view_near(); } } catch (Exception e) { } ; } } }); hOverlay = new HomeOverlay(locator.getCurrentGeoPoint(), new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == HomeOverlay.MOTION_CIRCLE_STOP) { try { if (!view_all) { view_near(); } mapView.postInvalidate(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); stations = new StationOverlayList(mapOverlays, new Handler() { @Override public void handleMessage(Message msg) { //Log.i("CityBikes","Message: "+Integer.toString(msg.what)+" "+Integer.toString(msg.arg1)); if (msg.what == StationOverlay.TOUCHED && msg.arg1 != -1) { // One station has been touched stations.setCurrent(msg.arg1, getBike); infoLayer.inflateStation(stations.getCurrent()); //Log.i("CityBikes","Station touched: "+Integer.toString(msg.arg1)); } } }); stations.addOverlay(hOverlay); mNDBAdapter = new NetworksDBAdapter(getApplicationContext()); mDbHelper = new StationsDBAdapter(this, mapView, new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case StationsDBAdapter.FETCH: break; case StationsDBAdapter.UPDATE_MAP: progressDialog.dismiss(); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("reload_network", false); editor.commit(); case StationsDBAdapter.UPDATE_DATABASE: StationOverlay current = stations.getCurrent(); if (current == null) { infoLayer.inflateMessage(getString(R.string.no_bikes_around)); } if (current != null) { current.setSelected(true, getBike); infoLayer.inflateStation(current); if (view_all) view_all(); else view_near(); } else { } mapView.invalidate(); infoLayer.update(); ////Log.i("openBicing", "Database updated"); break; case StationsDBAdapter.NETWORK_ERROR: ////Log.i("openBicing", "Network error, last update from " + mDbHelper.getLastUpdated()); Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.network_error) + " " + mDbHelper.getLastUpdated(), Toast.LENGTH_LONG); toast.show(); break; } } }, stations); mDbHelper.setCenter(locator.getCurrentGeoPoint()); mSlidingDrawer.setHandler(new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case StationSlidingDrawer.ITEMCLICKED: StationOverlay clicked = (StationOverlay) msg.obj; stations.setCurrent(msg.arg1, getBike); Message tmp = new Message(); tmp.what = InfoLayer.POPULATE; tmp.arg1 = msg.arg1; infoLayerPopulator.dispatchMessage(tmp); mapView.getController().animateTo(clicked.getCenter()); } } }); if (savedInstanceState != null) { locator.unlockCenter(); hOverlay.setRadius(savedInstanceState.getInt("homeRadius")); this.view_all = savedInstanceState.getBoolean("view_all"); } else { updateHome(); } try { mDbHelper.loadStations(); if (savedInstanceState == null) { String strUpdated = mDbHelper.getLastUpdated(); Boolean dirty = settings.getBoolean("reload_network", false); if (strUpdated == null || dirty) { this.fillData(view_all); } else { Toast toast = Toast.makeText(this.getApplicationContext(), "Last Updated: " + mDbHelper.getLastUpdated(), Toast.LENGTH_LONG); toast.show(); Calendar cal = Calendar.getInstance(); long now = cal.getTime().getTime(); if (Math.abs(now - mDbHelper.getLastUpdatedTime()) > 60000 * 5) this.fillData(view_all); } } } catch (Exception e) { ////Log.i("openBicing", "SHIT ... SUCKS"); } ; if (view_all) view_all(); else view_near(); ////Log.i("openBicing", "CREATE!"); }
From source file:com.inter.trade.view.slideplayview.AbSlidingPlayView.java
/** * /* w w w. ja va 2 s . com*/ * ???View * @param context * @throws */ public void initView(Context context) { this.context = context; layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT); layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsWF = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT); pageLineLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); //this.setBackgroundColor(Color.rgb(255, 255, 255)); RelativeLayout mRelativeLayout = new RelativeLayout(context); mViewPager = new AbInnerViewPager(context); //ViewPager,fragmentsetId()id mViewPager.setId(1985); // mPageLineLayoutParent = new LinearLayout(context); mPageLineLayoutParent.setPadding(0, 5, 0, 5); pageLineLayout = new LinearLayout(context); pageLineLayout.setPadding(15, 1, 15, 1); pageLineLayout.setVisibility(View.INVISIBLE); mPageLineLayoutParent.addView(pageLineLayout, new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mRelativeLayout.addView(mViewPager, lp1); RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mRelativeLayout.addView(mPageLineLayoutParent, lp2); addView(mRelativeLayout, layoutParamsFW); displayImage = AbFileUtil.getBitmapFormSrc("image/play_display.png"); hideImage = AbFileUtil.getBitmapFormSrc("image/play_hide.png"); mListViews = new ArrayList<View>(); mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews); mViewPager.setAdapter(mAbViewPagerAdapter); mViewPager.setFadingEdgeLength(0); mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { makesurePosition(); onPageSelectedCallBack(position); } @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { onPageScrolledCallBack(position); } }); }
From source file:fr.cph.stock.android.activity.AccountActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "Account Activity onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.account_activity); Bundle b = getIntent().getExtras();// ww w .ja v a 2 s . c om portfolio = b.getParcelable("portfolio"); errorView = (TextView) findViewById(R.id.errorMessage); totalValueView = (TextView) findViewById(R.id.totalValue); totalGainView = (TextView) findViewById(R.id.totalGain); totalPlusMinusValueView = (TextView) findViewById(R.id.totalPlusMinusValue); lastUpateView = (TextView) findViewById(R.id.lastUpdate); liquidityView = (TextView) findViewById(R.id.liquidity); yieldYearView = (TextView) findViewById(R.id.yieldYear); shareValueView = (TextView) findViewById(R.id.shareValue); gainView = (TextView) findViewById(R.id.gain2); perfView = (TextView) findViewById(R.id.perf); yieldView = (TextView) findViewById(R.id.yieldPerf); taxesView = (TextView) findViewById(R.id.taxes); RelativeLayout accLayout = (RelativeLayout) findViewById(R.id.accountsLayout); TextView recent = new TextView(getApplicationContext()); textViews = new ArrayList<TextView>(); int id = 1; int nameID = 100; int viewId1 = 500; int currencyId = 1000; for (int i = 0; i < portfolio.getAccounts().size(); i++) { Account account = portfolio.getAccounts().get(i); TextView currentAccountNameTextView = new TextView(getApplicationContext()); currentAccountNameTextView.setText(account.getName()); currentAccountNameTextView.setTextColor(Color.GRAY); currentAccountNameTextView.setId(nameID); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } params.addRule(RelativeLayout.ALIGN_PARENT_LEFT); currentAccountNameTextView.setLayoutParams(params); accLayout.addView(currentAccountNameTextView, params); textViews.add(currentAccountNameTextView); View viewPoint1 = new View(getApplicationContext()); viewPoint1.setId(viewId1); viewPoint1.setBackgroundColor(getResources().getColor(R.color.grey_light)); params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2); params.addRule(RelativeLayout.RIGHT_OF, nameID); params.addRule(RelativeLayout.LEFT_OF, currencyId); params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } viewPoint1.setLayoutParams(params); accLayout.addView(viewPoint1, params); TextView currentCurrencyTextView = new TextView(getApplicationContext()); currentCurrencyTextView.setText(account.getCurrency()); currentCurrencyTextView.setTextColor(Color.GRAY); currentCurrencyTextView.setId(currencyId); params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); params.addRule(RelativeLayout.CENTER_HORIZONTAL); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } currentCurrencyTextView.setLayoutParams(params); accLayout.addView(currentCurrencyTextView, params); textViews.add(currentCurrencyTextView); View viewPoint2 = new View(getApplicationContext()); viewPoint2.setBackgroundColor(getResources().getColor(R.color.grey_light)); params = new RelativeLayout.LayoutParams((int) LayoutParams.MATCH_PARENT, 2); params.addRule(RelativeLayout.RIGHT_OF, currencyId); params.addRule(RelativeLayout.LEFT_OF, id); params.setMargins(0, Util.convertDpToPxl(15, getApplicationContext()), 0, 0); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } viewPoint2.setLayoutParams(params); accLayout.addView(viewPoint2, params); TextView currentTextView = new TextView(getApplicationContext()); currentTextView.setText(account.getLiquidity()); currentTextView.setTextColor(Color.GRAY); currentTextView.setId(id); params = new RelativeLayout.LayoutParams((int) LayoutParams.WRAP_CONTENT, (int) LayoutParams.WRAP_CONTENT); if (i != 0) { params.addRule(RelativeLayout.BELOW, recent.getId()); } params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); currentTextView.setLayoutParams(params); recent = currentTextView; accLayout.addView(currentTextView, params); textViews.add(currentTextView); id++; nameID++; viewId1++; currencyId++; } buildUi(false); // Set context EasyTracker.getInstance().setContext(getApplicationContext()); // Instantiate the Tracker tracker = EasyTracker.getTracker(); }
From source file:com.admin.control.ab.AbSlidingPlayView.java
/** * ???View./*from ww w.j a va 2 s .c o m*/ * * @param context the context */ public void initView(Context context) { this.context = context; //TODO >> layoutParamsFF = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); layoutParamsFW = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); layoutParamsWF = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); //TODO << navLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); this.setOrientation(LinearLayout.VERTICAL); RelativeLayout mRelativeLayout = new RelativeLayout(context); mViewPager = new AbInnerViewPager(context); //ViewPager,fragmentsetId()id // mViewPager.setId(1985); // mNavLayoutParent = new LinearLayout(context); mNavLayoutParent.setPadding(0, 5, 0, 5); navLinearLayout = new LinearLayout(context); navLinearLayout.setPadding(15, 1, 15, 1); navLinearLayout.setVisibility(View.INVISIBLE); mNavLayoutParent.addView(navLinearLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); RelativeLayout.LayoutParams lp1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp1.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE); lp1.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mRelativeLayout.addView(mViewPager, lp1); RelativeLayout.LayoutParams lp2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); mRelativeLayout.addView(mNavLayoutParent, lp2); addView(mRelativeLayout, layoutParamsFW); // addView(mRelativeLayout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); //? displayImage = ABFileUtil.getBitmapFromSrc("play_display.png"); hideImage = ABFileUtil.getBitmapFromSrc("play_hide.png"); mListViews = new ArrayList<>(); mAbViewPagerAdapter = new AbViewPagerAdapter(context, mListViews); mViewPager.setAdapter(mAbViewPagerAdapter); mViewPager.setFadingEdgeLength(0); mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { if (mAbScrolledListener != null) { if (position == 0) mAbScrolledListener.onScrollToLeft(); if (position == mListViews.size() - 1) mAbScrolledListener.onScrollToRight(); } setNowPlayIndex(position); makesurePosition(); onPageSelectedCallBack(position); } @Override public void onPageScrollStateChanged(int state) { } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { onPageScrolledCallBack(position); } }); }
From source file:net.homelinux.penecoptero.android.citybikes.app.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/*from www. j ava 2s. co m*/ PreferenceManager.setDefaultValues(this, R.xml.preferences, false); mapView = (MapView) findViewById(R.id.mapview); mSlidingDrawer = (StationSlidingDrawer) findViewById(R.id.drawer); infoLayer = (InfoLayer) findViewById(R.id.info_layer); scale = getResources().getDisplayMetrics().density; //Log.i("CityBikes","ON CREATEEEEEEEEE!!!!!"); infoLayerPopulator = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == InfoLayer.POPULATE) { infoLayer.inflateStation(stations.getCurrent()); } if (msg.what == CityBikes.BOOKMARK_CHANGE) { int id = msg.arg1; boolean bookmarked; if (msg.arg2 == 0) { bookmarked = false; } else { bookmarked = true; } StationOverlay station = stations.getById(id); try { BookmarkManager bm = new BookmarkManager(getApplicationContext()); bm.setBookmarked(station.getStation(), !bookmarked); } catch (Exception e) { Log.i("CityBikes", "Error bookmarking station"); e.printStackTrace(); } if (!view_all) { view_near(); } mapView.postInvalidate(); } } }; infoLayer.setHandler(infoLayerPopulator); RelativeLayout.LayoutParams zoomControlsLayoutParams = new RelativeLayout.LayoutParams( android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT); zoomControlsLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); zoomControlsLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL); mapView.addView(mapView.getZoomControls(), zoomControlsLayoutParams); modeButton = (ToggleButton) findViewById(R.id.mode_button); modeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { changeMode(!getBike); } }); applyMapViewLongPressListener(mapView); settings = getSharedPreferences(CityBikes.PREFERENCES_NAME, 0); List<Overlay> mapOverlays = mapView.getOverlays(); locator = new Locator(this, new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == Locator.LOCATION_CHANGED) { GeoPoint point = new GeoPoint(msg.arg1, msg.arg2); hOverlay.moveCenter(point); mapView.getController().animateTo(point); mDbHelper.setCenter(point); // Location has changed try { mDbHelper.updateDistances(point); infoLayer.update(); if (!view_all) { view_near(); } } catch (Exception e) { } ; } } }); hOverlay = new HomeOverlay(locator.getCurrentGeoPoint(), new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == HomeOverlay.MOTION_CIRCLE_STOP) { try { if (!view_all) { view_near(); } mapView.postInvalidate(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); stations = new StationOverlayList(mapOverlays, new Handler() { @Override public void handleMessage(Message msg) { //Log.i("CityBikes","Message: "+Integer.toString(msg.what)+" "+Integer.toString(msg.arg1)); if (msg.what == StationOverlay.TOUCHED && msg.arg1 != -1) { // One station has been touched stations.setCurrent(msg.arg1, getBike); infoLayer.inflateStation(stations.getCurrent()); //Log.i("CityBikes","Station touched: "+Integer.toString(msg.arg1)); } } }); stations.addOverlay(hOverlay); mNDBAdapter = new NetworksDBAdapter(getApplicationContext()); mDbHelper = new StationsDBAdapter(this, mapView, new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case StationsDBAdapter.FETCH: break; case StationsDBAdapter.UPDATE_MAP: progressDialog.dismiss(); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("reload_network", false); editor.commit(); case StationsDBAdapter.UPDATE_DATABASE: StationOverlay current = stations.getCurrent(); if (current == null) { infoLayer.inflateMessage(getString(R.string.no_bikes_around)); } if (current != null) { infoLayer.inflateStation(current); if (view_all) view_all(); else view_near(); } else { } mapView.invalidate(); infoLayer.update(); ////Log.i("openBicing", "Database updated"); break; case StationsDBAdapter.NETWORK_ERROR: ////Log.i("openBicing", "Network error, last update from " + mDbHelper.getLastUpdated()); Toast toast = Toast.makeText(getApplicationContext(), getString(R.string.network_error) + " " + mDbHelper.getLastUpdated(), Toast.LENGTH_LONG); toast.show(); break; } } }, stations); mDbHelper.setCenter(locator.getCurrentGeoPoint()); mSlidingDrawer.setHandler(new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case StationSlidingDrawer.ITEMCLICKED: StationOverlay clicked = (StationOverlay) msg.obj; stations.setCurrent(msg.arg1, getBike); Message tmp = new Message(); tmp.what = InfoLayer.POPULATE; tmp.arg1 = msg.arg1; infoLayerPopulator.dispatchMessage(tmp); mapView.getController().animateTo(clicked.getCenter()); } } }); if (savedInstanceState != null) { locator.unlockCenter(); hOverlay.setRadius(savedInstanceState.getInt("homeRadius")); this.view_all = savedInstanceState.getBoolean("view_all"); } else { updateHome(); } try { mDbHelper.loadStations(); if (savedInstanceState == null) { String strUpdated = mDbHelper.getLastUpdated(); Boolean dirty = settings.getBoolean("reload_network", false); if (strUpdated == null || dirty) { this.fillData(view_all); } else { Toast toast = Toast.makeText(this.getApplicationContext(), "Last Updated: " + mDbHelper.getLastUpdated(), Toast.LENGTH_LONG); toast.show(); Calendar cal = Calendar.getInstance(); long now = cal.getTime().getTime(); if (Math.abs(now - mDbHelper.getLastUpdatedTime()) > 60000 * 5) this.fillData(view_all); } } } catch (Exception e) { ////Log.i("openBicing", "SHIT ... SUCKS"); } ; if (view_all) view_all(); else view_near(); ////Log.i("openBicing", "CREATE!"); }