List of usage examples for android.widget RelativeLayout RelativeLayout
public RelativeLayout(Context context)
From source file:net.ibaixin.chat.view.PagerSlidingTabStrip.java
/** * tab//from w ww . j a v a2s .c o m * @update 2015128 ?9:58:54 * @param position * @param title */ private void addTextTab(final int position, CharSequence title) { //layout RelativeLayout tabLayout = new RelativeLayout(getContext()); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); tabLayout.setLayoutParams(layoutParams); RelativeLayout.LayoutParams textParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); textParams.addRule(RelativeLayout.CENTER_IN_PARENT); //tab TextView tab = new TextView(getContext()); tab.setId(100 + position); tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tabLayout.addView(tab, textParams); //??? RelativeLayout.LayoutParams viewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); viewParams.addRule(RelativeLayout.RIGHT_OF, tab.getId()); viewParams.addRule(RelativeLayout.CENTER_VERTICAL); View view = new View(getContext()); ViewGroup.LayoutParams vParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); view.setLayoutParams(vParams); tabLayout.addView(view, viewParams); addTab(position, tabLayout); }
From source file:com.jomendezdev.cordova.admob.AdMobAds.java
private void createBannerView(String _pid, AdMobAdsAdListener adListener, boolean isBackFill) { boolean isTappx = _pid.equals(tappxId); if (adView != null && !adView.getAdUnitId().equals(_pid)) { if (adView.getParent() != null) { ((ViewGroup) adView.getParent()).removeView(adView); }/* w ww. j a v a 2 s . c o m*/ adView.destroy(); adView = null; } if (adView == null) { adView = new AdView(cordova.getActivity()); if (isTappx) { if (adSize == AdSize.BANNER) { // 320x50 adView.setAdSize(adSize); } else if (adSize == AdSize.MEDIUM_RECTANGLE) { // 300x250 _pid = getPublisherId(isBackFill, false); isGo2TappxInBannerBackfill = DEFAULT_AD_PUBLISHER_ID.equals(_pid); adView.setAdSize(adSize); } else if (adSize == AdSize.FULL_BANNER) { // 468x60 adView.setAdSize(AdSize.BANNER); } else if (adSize == AdSize.LEADERBOARD) { // 728x90 adView.setAdSize(AdSize.BANNER); } else if (adSize == AdSize.SMART_BANNER) { // Screen width x 32|50|90 DisplayMetrics metrics = DisplayInfo(AdMobAds.this.cordova.getActivity()); if (metrics.widthPixels >= 768) { adView.setAdSize(new AdSize(768, 90)); } else { adView.setAdSize(AdSize.BANNER); } } } else { adView.setAdSize(adSize); } adView.setAdUnitId(_pid); adView.setAdListener(adListener); adView.setVisibility(View.GONE); } if (adView.getParent() != null) { ((ViewGroup) adView.getParent()).removeView(adView); } if (adViewLayout == null) { adViewLayout = new RelativeLayout(cordova.getActivity()); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); webView.addView(adViewLayout, params); } isBannerVisible = false; adView.loadAd(buildAdRequest()); }
From source file:com.support.android.designlibdemo.PetsDetailActivity.java
/**********************************************************************************************/ private AlertDialog createPublicationDialog(String titulo, String message) { // Instanciamos un nuevo AlertDialog Builder y le asociamos titulo y mensaje AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(titulo); alertDialogBuilder.setMessage(message); RelativeLayout linearLayout = new RelativeLayout(this); final EditText link = new EditText(this); link.setText(buildDescription());//from w w w.ja v a 2 s .c o m link.setTextSize(12); link.setWidth(750); linearLayout.addView(link); linearLayout.setPadding(70, 0, 0, 0); alertDialogBuilder.setView(linearLayout); link.invalidate(); linearLayout.invalidate(); // final String petId = getIntent().getStringExtra("id"); // Creamos un nuevo OnClickListener para el boton OK que realice la conexion DialogInterface.OnClickListener listenerOk = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String texto = link.getText().toString(); shareOnFacebook(texto); Toast.makeText(getApplicationContext(), "Publicacin compartida correctamente", Toast.LENGTH_SHORT) .show(); } }; // Creamos un nuevo OnClickListener para el boton Cancelar DialogInterface.OnClickListener listenerCancelar = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { return; } }; // Asignamos los botones positivo y negativo a sus respectivos listeners //OJO: estan al reves para que sea display si - no en vez de no - si alertDialogBuilder.setPositiveButton(R.string.dialogCancel, listenerCancelar); alertDialogBuilder.setNegativeButton(R.string.dialogPublish, listenerOk); return alertDialogBuilder.create(); }
From source file:com.androzic.MapActivity.java
/** Called when the activity is first created. */ @SuppressLint("ShowToast") @Override/*from w ww . j a va2 s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.e(TAG, "onCreate()"); ready = false; isFullscreen = false; backToast = Toast.makeText(this, R.string.backQuit, Toast.LENGTH_SHORT); finishHandler = new FinishHandler(this); application = (Androzic) getApplication(); // FIXME Should find a better place for this application.mapObjectsOverlay = new MapObjectsOverlay(this); // check if called after crash if (!application.mapsInited) { restarting = true; startActivity(new Intent(this, Splash.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK) .putExtras(getIntent())); finish(); return; } application.setMapActivity(this); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); setRequestedOrientation(Integer.parseInt(settings.getString(getString(R.string.pref_orientation), "-1"))); settings.registerOnSharedPreferenceChangeListener(this); Resources resources = getResources(); if (settings.getBoolean(getString(R.string.pref_hideactionbar), resources.getBoolean(R.bool.def_hideactionbar))) { requestWindowFeature(Window.FEATURE_NO_TITLE); } panelActions = getResources().getStringArray(R.array.panel_action_values); setContentView(R.layout.act_main); coordinates = (TextView) findViewById(R.id.coordinates); satInfo = (TextView) findViewById(R.id.sats); currentFile = (TextView) findViewById(R.id.currentfile); mapZoom = (TextView) findViewById(R.id.currentzoom); waypointName = (TextView) findViewById(R.id.waypointname); waypointExtra = (TextView) findViewById(R.id.waypointextra); routeName = (TextView) findViewById(R.id.routename); routeExtra = (TextView) findViewById(R.id.routeextra); speedValue = (TextView) findViewById(R.id.speed); speedUnit = (TextView) findViewById(R.id.speedunit); trackValue = (TextView) findViewById(R.id.track); trackUnit = (TextView) findViewById(R.id.trackunit); elevationValue = (TextView) findViewById(R.id.elevation); elevationUnit = (TextView) findViewById(R.id.elevationunit); distanceValue = (TextView) findViewById(R.id.distance); distanceUnit = (TextView) findViewById(R.id.distanceunit); xtkValue = (TextView) findViewById(R.id.xtk); xtkUnit = (TextView) findViewById(R.id.xtkunit); bearingValue = (TextView) findViewById(R.id.bearing); bearingUnit = (TextView) findViewById(R.id.bearingunit); turnValue = (TextView) findViewById(R.id.turn); trackBar = (SeekBar) findViewById(R.id.trackbar); waitBar = (TextView) findViewById(R.id.waitbar); map = (MapView) findViewById(R.id.mapview); // set button actions findViewById(R.id.zoomin).setOnClickListener(this); findViewById(R.id.zoomout).setOnClickListener(this); findViewById(R.id.nextmap).setOnClickListener(this); findViewById(R.id.prevmap).setOnClickListener(this); findViewById(R.id.maps).setOnClickListener(this); findViewById(R.id.waypoints).setOnClickListener(this); findViewById(R.id.info).setOnClickListener(this); findViewById(R.id.follow).setOnClickListener(this); findViewById(R.id.locate).setOnClickListener(this); findViewById(R.id.tracking).setOnClickListener(this); findViewById(R.id.expand).setOnClickListener(this); findViewById(R.id.finishedit).setOnClickListener(this); findViewById(R.id.addpoint).setOnClickListener(this); findViewById(R.id.insertpoint).setOnClickListener(this); findViewById(R.id.removepoint).setOnClickListener(this); findViewById(R.id.orderpoints).setOnClickListener(this); findViewById(R.id.finishtrackedit).setOnClickListener(this); findViewById(R.id.cutafter).setOnClickListener(this); findViewById(R.id.cutbefore).setOnClickListener(this); Panel panel = (Panel) findViewById(R.id.panel); panel.setOnPanelListener(this); panel.setInterpolator(new ExpoInterpolator(Type.OUT)); wptQuickAction = new QuickAction3D(this, QuickAction3D.VERTICAL); wptQuickAction.addActionItem(new ActionItem(qaAddWaypointToRoute, getString(R.string.menu_addtoroute), resources.getDrawable(R.drawable.ic_action_add))); wptQuickAction.setOnActionItemClickListener(waypointActionItemClickListener); rteQuickAction = new QuickAction3D(this, QuickAction3D.VERTICAL); rteQuickAction.addActionItem(new ActionItem(qaNavigateToWaypoint, getString(R.string.menu_thisnavpoint), resources.getDrawable(R.drawable.ic_action_directions))); rteQuickAction.setOnActionItemClickListener(routeActionItemClickListener); mobQuickAction = new QuickAction3D(this, QuickAction3D.VERTICAL); mobQuickAction.addActionItem(new ActionItem(qaNavigateToMapObject, getString(R.string.menu_navigate), resources.getDrawable(R.drawable.ic_action_directions))); mobQuickAction.setOnActionItemClickListener(mapObjectActionItemClickListener); trackBar.setOnSeekBarChangeListener(this); map.initialize(application); dimView = new RelativeLayout(this); String navWpt = settings.getString(getString(R.string.nav_wpt), ""); if (!"".equals(navWpt) && savedInstanceState == null) { Intent intent = new Intent(getApplicationContext(), NavigationService.class) .setAction(NavigationService.NAVIGATE_MAPOBJECT); intent.putExtra(NavigationService.EXTRA_NAME, navWpt); intent.putExtra(NavigationService.EXTRA_LATITUDE, (double) settings.getFloat(getString(R.string.nav_wpt_lat), 0)); intent.putExtra(NavigationService.EXTRA_LONGITUDE, (double) settings.getFloat(getString(R.string.nav_wpt_lon), 0)); intent.putExtra(NavigationService.EXTRA_PROXIMITY, settings.getInt(getString(R.string.nav_wpt_prx), 0)); startService(intent); } String navRoute = settings.getString(getString(R.string.nav_route), ""); if (!"".equals(navRoute) && settings.getBoolean(getString(R.string.pref_navigation_loadlast), getResources().getBoolean(R.bool.def_navigation_loadlast)) && savedInstanceState == null) { int ndir = settings.getInt(getString(R.string.nav_route_dir), 0); int nwpt = settings.getInt(getString(R.string.nav_route_wpt), -1); try { int rt = -1; Route route = application.getRouteByFile(navRoute); if (route != null) { route.show = true; rt = application.getRouteIndex(route); } else { File rtf = new File(navRoute); // FIXME It's bad - it can be not a first route in a file route = OziExplorerFiles.loadRoutesFromFile(rtf, application.charset).get(0); rt = application.addRoute(route); } RouteOverlay newRoute = new RouteOverlay(this, route); application.routeOverlays.add(newRoute); startService(new Intent(this, NavigationService.class).setAction(NavigationService.NAVIGATE_ROUTE) .putExtra(NavigationService.EXTRA_ROUTE_INDEX, rt) .putExtra(NavigationService.EXTRA_ROUTE_DIRECTION, ndir) .putExtra(NavigationService.EXTRA_ROUTE_START, nwpt)); } catch (Exception e) { Log.e(TAG, "Failed to start navigation", e); } } // set activity preferences onSharedPreferenceChanged(settings, getString(R.string.pref_exit)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitprecision)); // set map preferences onSharedPreferenceChanged(settings, getString(R.string.pref_mapadjacent)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapcropborder)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapdrawborder)); onSharedPreferenceChanged(settings, getString(R.string.pref_cursorcolor)); onSharedPreferenceChanged(settings, getString(R.string.pref_grid_mapshow)); onSharedPreferenceChanged(settings, getString(R.string.pref_grid_usershow)); onSharedPreferenceChanged(settings, getString(R.string.pref_grid_preference)); onSharedPreferenceChanged(settings, getString(R.string.pref_panelactions)); if (getIntent().getExtras() != null) onNewIntent(getIntent()); ready = true; }
From source file:fr.cph.chicago.core.adapter.FavoritesAdapter.java
private void handleBusRoute(@NonNull final FavoritesViewHolder holder, @NonNull final BusRoute busRoute) { holder.stationNameTextView.setText(busRoute.getId()); holder.favoriteImage.setImageResource(R.drawable.ic_directions_bus_white_24dp); final List<BusDetailsDTO> busDetailsDTOs = new ArrayList<>(); final Map<String, Map<String, List<BusArrival>>> busArrivals = favoritesData .getBusArrivalsMapped(busRoute.getId()); for (final Entry<String, Map<String, List<BusArrival>>> entry : busArrivals.entrySet()) { // Build data for button outside of the loop final String stopName = entry.getKey(); final String stopNameTrimmed = Util.trimBusStopNameIfNeeded(stopName); final Map<String, List<BusArrival>> value = entry.getValue(); for (final String key2 : value.keySet()) { final BusArrival busArrival = value.get(key2).get(0); final String boundTitle = busArrival.getRouteDirection(); final BusDirection.BusDirectionEnum busDirectionEnum = BusDirection.BusDirectionEnum .fromString(boundTitle); final BusDetailsDTO busDetails = BusDetailsDTO.builder().busRouteId(busArrival.getRouteId()) .bound(busDirectionEnum.getShortUpperCase()).boundTitle(boundTitle) .stopId(Integer.toString(busArrival.getStopId())).routeName(busRoute.getName()) .stopName(stopName).build(); busDetailsDTOs.add(busDetails); }/*from w ww . ja v a 2 s. c o m*/ boolean newLine = true; int i = 0; for (final Entry<String, List<BusArrival>> entry2 : value.entrySet()) { final LinearLayout.LayoutParams containParams = getInsideParams(newLine, i == value.size() - 1); final LinearLayout container = new LinearLayout(context); container.setOrientation(LinearLayout.HORIZONTAL); container.setLayoutParams(containParams); // Left final LinearLayout.LayoutParams leftParams = new LinearLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); final RelativeLayout left = new RelativeLayout(context); left.setLayoutParams(leftParams); final RelativeLayout lineIndication = LayoutUtil.createColoredRoundForFavorites(context, TrainLine.NA); int lineId = Util.generateViewId(); lineIndication.setId(lineId); final RelativeLayout.LayoutParams destinationParams = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); destinationParams.addRule(RelativeLayout.RIGHT_OF, lineId); destinationParams.setMargins(pixelsHalf, 0, 0, 0); final String bound = BusDirection.BusDirectionEnum.fromString(entry2.getKey()).getShortLowerCase(); final String leftString = stopNameTrimmed + " " + bound; final SpannableString destinationSpannable = new SpannableString(leftString); destinationSpannable.setSpan(new RelativeSizeSpan(0.65f), stopNameTrimmed.length(), leftString.length(), 0); // set size destinationSpannable.setSpan(new ForegroundColorSpan(grey5), 0, leftString.length(), 0); // set color final TextView boundCustomTextView = new TextView(context); boundCustomTextView.setText(destinationSpannable); boundCustomTextView.setSingleLine(true); boundCustomTextView.setLayoutParams(destinationParams); left.addView(lineIndication); left.addView(boundCustomTextView); // Right final LinearLayout.LayoutParams rightParams = new LinearLayout.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); rightParams.setMargins(marginLeftPixel, 0, 0, 0); final LinearLayout right = new LinearLayout(context); right.setOrientation(LinearLayout.VERTICAL); right.setLayoutParams(rightParams); final List<BusArrival> buses = entry2.getValue(); final StringBuilder currentEtas = new StringBuilder(); for (final BusArrival arri : buses) { currentEtas.append(" ").append(arri.getTimeLeftDueDelay()); } final TextView arrivalText = new TextView(context); arrivalText.setText(currentEtas); arrivalText.setGravity(Gravity.END); arrivalText.setSingleLine(true); arrivalText.setTextColor(grey5); arrivalText.setEllipsize(TextUtils.TruncateAt.END); right.addView(arrivalText); container.addView(left); container.addView(right); holder.mainLayout.addView(container); newLine = false; i++; } } holder.mapButton.setText(activity.getString(R.string.favorites_view_buses)); holder.detailsButton .setOnClickListener(new BusStopOnClickListener(activity, holder.parent, busDetailsDTOs)); holder.mapButton.setOnClickListener(v -> { if (!Util.isNetworkAvailable(context)) { Util.showNetworkErrorMessage(activity); } else { final Set<String> bounds = Stream.of(busDetailsDTOs).map(BusDetailsDTO::getBound) .collect(Collectors.toSet()); final Intent intent = new Intent(activity.getApplicationContext(), BusMapActivity.class); final Bundle extras = new Bundle(); extras.putString(activity.getString(R.string.bundle_bus_route_id), busRoute.getId()); extras.putStringArray(activity.getString(R.string.bundle_bus_bounds), bounds.toArray(new String[bounds.size()])); intent.putExtras(extras); activity.startActivity(intent); } }); }
From source file:com.wit.and.dialog.LoginDialog.java
/** * /* w ww . ja v a 2 s .c o m*/ */ @Override protected View onCreateBodyView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final Context context = inflater.getContext(); RelativeLayout layout = new RelativeLayout(context); // Apply neutral layout params. layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // Do not allow to apply style to body view. // layout.setId(R.id.Dialog_Layout_Body); // Create layout for loading view. LinearLayout loadingLayout = new LinearLayout(context); loadingLayout.setOrientation(LinearLayout.HORIZONTAL); loadingLayout.setGravity(Gravity.CENTER_VERTICAL); // Allow styling of loading layout as body layout. loadingLayout.setId(R.id.And_Dialog_Layout_Body); // Create text view for message. TextView msgTextView = new TextView(context); msgTextView.setId(R.id.And_Dialog_TextView_Message); // Create circle progress bar. ProgressBar circleProgressBar = new ProgressBar(context); circleProgressBar.setId(R.id.And_Dialog_ProgressBar); // Build loading view. loadingLayout.addView(circleProgressBar, new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); loadingLayout.addView(msgTextView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT)); loadingLayout.setVisibility(View.GONE); // Insert loading layout into main body layout. RelativeLayout.LayoutParams loadingLayoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); loadingLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); layout.addView(loadingLayout, loadingLayoutParams); // Create layout for edit texts. LinearLayout editLayout = new LinearLayout(context); editLayout.setOrientation(LinearLayout.VERTICAL); editLayout.setId(R.id.And_Dialog_Layout_LoginDialog_EditView); // Create edit texts for username and password. EditText userEdit = new EditText(context); userEdit.setId(R.id.And_Dialog_EditText_Username); userEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); EditText passEdit = new EditText(context); passEdit.setId(R.id.And_Dialog_EditText_Password); passEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // Create edit texts divider. DialogDivider divider = new DialogDivider(context); divider.setId(R.id.And_Dialog_Divider_LoginDialog_EditTexts); // Build edit layout. editLayout.addView(userEdit, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); editLayout.addView(divider, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); editLayout.addView(passEdit, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); // Add custom layout. View customView = onCreateCustomView(inflater, editLayout, savedInstanceState); if (customView != null) { editLayout.addView(this.mCustomView = customView); } // Insert edit layout into main body layout. RelativeLayout.LayoutParams editLayoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); editLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT); layout.addView(editLayout, editLayoutParams); return layout; }
From source file:io.github.data4all.activity.MapViewActivity.java
private void bodyheightdialog() { PreferenceManager.setDefaultValues(this, R.xml.settings, false); this.prefs = PreferenceManager.getDefaultSharedPreferences(this); final SharedPreferences userPrefs = getSharedPreferences("UserPrefs", 0); firstUse = userPrefs.getBoolean("firstUse", true); if (firstUse) { RelativeLayout linearLayout = new RelativeLayout(this); final NumberPicker numberPicker = new NumberPicker(this); numberPicker.setMaxValue(250);/*from ww w . java 2 s . co m*/ numberPicker.setMinValue(80); numberPicker.setValue(180); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(50, 50); RelativeLayout.LayoutParams numPicerParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); numPicerParams.addRule(RelativeLayout.CENTER_HORIZONTAL); linearLayout.setLayoutParams(params); linearLayout.addView(numberPicker, numPicerParams); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.pref_bodyheight_dialog_title); alertDialogBuilder.setMessage(R.string.pref_bodyheight_dialog_message); alertDialogBuilder.setView(linearLayout); alertDialogBuilder.setCancelable(false).setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Log.d(TAG, "set bodyheight to: " + numberPicker.getValue()); prefs.edit().putString("PREF_BODY_HEIGHT", String.valueOf(numberPicker.getValue())) .commit(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); // set firstUse to false so this dialog is not shown again. ever. userPrefs.edit().putBoolean("firstUse", false).commit(); firstUse = false; } }
From source file:com.cranberrygame.cordova.plugin.ad.admob.Util.java
private void _preloadBannerAd_overlap() { if (bannerViewLayout == null) { bannerViewLayout = new RelativeLayout(cordova.getActivity());// RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); //webView.addView(bannerViewLayout, params); bannerViewLayout.setLayoutParams(params); //webView.addView(bannerViewLayout);//cordova5 build error ((ViewGroup) getView(webView)).addView(bannerViewLayout); }/*from w ww .ja va 2s .c om*/ if (bannerView != null) { //if banner is showing RelativeLayout bannerViewLayout = (RelativeLayout) bannerView.getParent(); if (bannerViewLayout != null) { bannerViewLayout.removeView(bannerView); bannerView.destroy(); bannerView = null; } } }
From source file:org.openremote.android.console.AppSettingsActivity.java
/** * Creates the clear image cache button, add listener for clear image cache. * @return the relative layout//from w w w . ja v a 2 s . c o m */ private RelativeLayout createClearImageCacheButton() { RelativeLayout clearImageView = new RelativeLayout(this); clearImageView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); Button clearImgCacheBtn = new Button(this); clearImgCacheBtn.setText("Clear Image Cache"); RelativeLayout.LayoutParams clearButtonLayout = new RelativeLayout.LayoutParams(150, LayoutParams.WRAP_CONTENT); clearButtonLayout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); clearImgCacheBtn.setLayoutParams(clearButtonLayout); clearImgCacheBtn.setOnClickListener(new OnClickListener() { public void onClick(View v) { ViewHelper.showAlertViewWithTitleYesOrNo(AppSettingsActivity.this, "", "Are you sure you want to clear image cache?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { FileUtil.clearImagesInCache(AppSettingsActivity.this); } }); } }); clearImageView.addView(clearImgCacheBtn); return clearImageView; }
From source file:com.nextgis.ngm_clink_monitoring.fragments.MapFragment.java
protected void addMapButtons() { Context context = getActivity(); if (mivZoomIn == null || mivZoomOut == null) { mivZoomIn = new ImageView(context); mivZoomIn.setImageResource(R.drawable.ic_plus); mivZoomIn.setId(ViewUtil.generateViewId()); mivZoomOut = new ImageView(context); mivZoomOut.setImageResource(R.drawable.ic_minus); mivZoomOut.setId(ViewUtil.generateViewId()); mivZoomIn.setOnClickListener(new OnClickListener() { public void onClick(View v) { mMapView.zoomIn();//www . java2s .c o m } }); mivZoomOut.setOnClickListener(new OnClickListener() { public void onClick(View v) { mMapView.zoomOut(); } }); } mButtonsRelativeLayout = (RelativeLayout) mMapRelativeLayout.findViewById(mButtonsRelativeLayoutId); if (null == mButtonsRelativeLayout) { mButtonsRelativeLayout = new RelativeLayout(context); mButtonsRelativeLayout.setId(mButtonsRelativeLayoutId); RelativeLayout.LayoutParams paramsButtonIn = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams paramsButtonOut = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout.LayoutParams paramsButtonsRl = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); paramsButtonIn.setMargins(mMargins + 5, mMargins - 5, mMargins + 5, mMargins + 5); paramsButtonOut.setMargins(mMargins + 5, mMargins + 5, mMargins + 5, mMargins - 5); paramsButtonOut.addRule(RelativeLayout.BELOW, mivZoomIn.getId()); paramsButtonsRl.addRule(RelativeLayout.ALIGN_PARENT_LEFT); paramsButtonsRl.addRule(RelativeLayout.CENTER_IN_PARENT); mButtonsRelativeLayout.addView(mivZoomIn, paramsButtonIn); mButtonsRelativeLayout.addView(mivZoomOut, paramsButtonOut); mMapRelativeLayout.addView(mButtonsRelativeLayout, paramsButtonsRl); } setZoomInEnabled(mMapView.canZoomIn()); setZoomOutEnabled(mMapView.canZoomOut()); }