List of usage examples for android.view ViewGroup addView
@Override public void addView(View child, LayoutParams params)
From source file:co.paulburke.android.textviewpager.TextViewPagerAdapter.java
@Override public TextView instantiateItem(final ViewGroup container, final int position) { TextView view = null;//w ww. jav a 2 s .c o m if (mLayoutRes > 0) view = (TextView) mInflater.inflate(mLayoutRes, container, false); else view = new TextView(mContext, null, R.attr.textViewPagerStyle); if (mText != null) { int offset = 0; int end = mText.length(); int size = mOffsets.length; if (size == 0) { // Add the OnGlobalLayoutListener, which measures the text and // reports paged character offsets if the text layout is taller // than the container. PagingLayoutListener listener = new PagingLayoutListener(view, mMeasureListener); view.getViewTreeObserver().addOnGlobalLayoutListener(listener); } else { offset = mOffsets[position]; int lastPage = size - 1; // Don't consider the last page measured, in case there is more // text to be displayed. if (position < lastPage) end = mOffsets[position + 1]; } final CharSequence sub = mText.subSequence(offset, end); view.setText(sub != null ? sub : mContext.getText(R.string.unable_to_load_text)); container.addView(view, 0); if (DEBUG) Log.d(TAG, "instantiateItem position = " + position + ", offset = " + offset + ", end = " + end + ", text = " + sub); } return view; }
From source file:com.csipsimple.ui.favorites.FavAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { ContentValues cv = new ContentValues(); DatabaseUtils.cursorRowToContentValues(cursor, cv); int type = ContactsWrapper.TYPE_CONTACT; if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) { type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE); }//from w ww .jav a 2s. c o m showViewForType(view, type); if (type == ContactsWrapper.TYPE_GROUP) { // Get views TextView tv = (TextView) view.findViewById(R.id.header_text); ImageView icon = (ImageView) view.findViewById(R.id.header_icon); PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view .findViewById(R.id.header_presence_spinner); // Get datas SipProfile acc = new SipProfile(cursor); final Long profileId = cv.getAsLong(BaseColumns._ID); final String groupName = acc.android_group; final String displayName = acc.display_name; final String wizard = acc.wizard; final boolean publishedEnabled = (acc.publish_enabled == 1); final String domain = acc.getDefaultDomain(); // Bind datas to view tv.setText(displayName); icon.setImageResource(WizardUtils.getWizardIconRes(wizard)); presSpinner.setProfileId(profileId); // Extra menu view if not already set ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner); MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled); MenuBuilder menuBuilder; if (menuViewWrapper.getTag() == null) { final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext); mActionMenuPresenter.setReserveOverflow(true); menuBuilder = new MenuBuilder(context); menuBuilder.setCallback(newMcb); MenuInflater inflater = new MenuInflater(context); inflater.inflate(R.menu.fav_menu, menuBuilder); menuBuilder.addMenuPresenter(mActionMenuPresenter); ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper); UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null); menuViewWrapper.addView(menuView, layoutParams); menuViewWrapper.setTag(menuBuilder); } else { menuBuilder = (MenuBuilder) menuViewWrapper.getTag(); menuBuilder.setCallback(newMcb); } menuBuilder.findItem(R.id.share_presence).setTitle( publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing); menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName)); } else if (type == ContactsWrapper.TYPE_CONTACT) { ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor); ci.userData = cursor.getPosition(); // Get views TextView tv = (TextView) view.findViewById(R.id.contact_name); QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo); TextView statusText = (TextView) view.findViewById(R.id.status_text); ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon); // Bind if (ci.contactId != null) { tv.setText(ci.displayName); badge.assignContactUri(ci.callerInfo.contactContentUri); ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(), ci.callerInfo, R.drawable.ic_contact_picture_holo_dark); statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusText.setText(ci.status); statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence)); } View v; v = view.findViewById(R.id.contact_view); v.setTag(ci); v.setOnClickListener(mPrimaryActionListener); v = view.findViewById(R.id.secondary_action_icon); v.setTag(ci); v.setOnClickListener(mSecondaryActionListener); } else if (type == ContactsWrapper.TYPE_CONFIGURE) { // We only bind if it's the correct type View v = view.findViewById(R.id.configure_view); v.setOnClickListener(this); ConfigureObj cfg = new ConfigureObj(); cfg.profileId = cv.getAsLong(BaseColumns._ID); v.setTag(cfg); } }
From source file:com.fututel.ui.favorites.FavAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { ContentValues cv = new ContentValues(); DatabaseUtils.cursorRowToContentValues(cursor, cv); int type = ContactsWrapper.TYPE_CONTACT; if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) { type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE); }/* www .j a va 2s . com*/ showViewForType(view, type); if (type == ContactsWrapper.TYPE_GROUP) { // Get views TextView tv = (TextView) view.findViewById(R.id.header_text); ImageView icon = (ImageView) view.findViewById(R.id.header_icon); PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view .findViewById(R.id.header_presence_spinner); // Get datas SipProfile acc = new SipProfile(cursor); final Long profileId = cv.getAsLong(BaseColumns._ID); final String groupName = acc.android_group; final String displayName = acc.display_name; final String wizard = acc.wizard; final boolean publishedEnabled = (acc.publish_enabled == 1); final String domain = acc.getDefaultDomain(); // Bind datas to view tv.setText(displayName); icon.setImageResource(WizardUtils.getWizardIconRes(wizard)); presSpinner.setProfileId(profileId); // Extra menu view if not already set ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner); MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled); MenuBuilder menuBuilder; if (menuViewWrapper.getTag() == null) { final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext); mActionMenuPresenter.setReserveOverflow(true); menuBuilder = new MenuBuilder(context); menuBuilder.setCallback(newMcb); MenuInflater inflater = new MenuInflater(context); inflater.inflate(R.menu.fav_menu, menuBuilder); menuBuilder.addMenuPresenter(mActionMenuPresenter); ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper); UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null); menuViewWrapper.addView(menuView, layoutParams); menuViewWrapper.setTag(menuBuilder); } else { menuBuilder = (MenuBuilder) menuViewWrapper.getTag(); menuBuilder.setCallback(newMcb); } menuBuilder.findItem(R.id.share_presence).setTitle( publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing); menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName)); } else if (type == ContactsWrapper.TYPE_CONTACT) { ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor); ci.userData = cursor.getPosition(); // Get views TextView tv = (TextView) view.findViewById(R.id.contact_name); QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo); TextView statusText = (TextView) view.findViewById(R.id.status_text); ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon); // Bind if (ci.contactId != null) { tv.setText(ci.displayName); badge.assignContactUri(ci.callerInfo.contactContentUri); ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(), ci.callerInfo, R.drawable.ic_contact_picture_holo_light); statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusText.setText(ci.status); statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence)); } View v; v = view.findViewById(R.id.contact_view); v.setTag(ci); v.setOnClickListener(mPrimaryActionListener); v = view.findViewById(R.id.secondary_action_icon); v.setTag(ci); v.setOnClickListener(mSecondaryActionListener); } else if (type == ContactsWrapper.TYPE_CONFIGURE) { // We only bind if it's the correct type View v = view.findViewById(R.id.configure_view); v.setOnClickListener(this); ConfigureObj cfg = new ConfigureObj(); cfg.profileId = cv.getAsLong(BaseColumns._ID); v.setTag(cfg); } }
From source file:com.todoroo.astrid.activity.TaskListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ViewGroup parent = (ViewGroup) getActivity().getLayoutInflater().inflate(R.layout.task_list_activity, container, false);/*from ww w . j av a 2s .c om*/ parent.addView(getListBody(parent), 0); return parent; }
From source file:com.hybris.mobile.lib.ui.view.Alert.java
/** * Show the alert/* ww w. j a va 2 s . c o m*/ * * @param context application-specific resources * @param configuration describes all device configuration information * @param text message to be displayed * @param forceClearPreviousAlert true will clear previous alert else keep it */ @SuppressLint("NewApi") private static void showAlertOnScreen(final Activity context, final Configuration configuration, final String text, boolean forceClearPreviousAlert) { final ViewGroup mainView = ((ViewGroup) context.findViewById(android.R.id.content)); boolean currentlyDisplayed = false; int viewId = R.id.alert_view_top; final TextView textView; boolean alertAlreadyExists = false; if (configuration.getOrientation().equals(Configuration.Orientation.BOTTOM)) { viewId = R.id.alert_view_bottom; } // Retrieving the view RelativeLayout relativeLayout = (RelativeLayout) mainView.findViewById(viewId); if (forceClearPreviousAlert) { mainView.removeView(relativeLayout); relativeLayout = null; } // Creating the view if (relativeLayout == null) { // Main layout relativeLayout = new RelativeLayout(context); relativeLayout.setId(viewId); relativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, configuration.getHeight())); relativeLayout.setGravity(Gravity.CENTER); // Textview textView = new TextView(context); textView.setId(R.id.alert_view_text); textView.setGravity(Gravity.CENTER); textView.setLayoutParams( new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); relativeLayout.addView(textView); setIcon(context, configuration, relativeLayout, textView); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { relativeLayout.setY(-configuration.getHeight()); } else { relativeLayout.setY(mainView.getHeight()); } // Adding the view to the global layout mainView.addView(relativeLayout, 0); relativeLayout.bringToFront(); relativeLayout.requestLayout(); relativeLayout.invalidate(); } // View already exists else { alertAlreadyExists = true; textView = (TextView) relativeLayout.findViewById(R.id.alert_view_text); if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) { if (relativeLayout.getY() == 0) { currentlyDisplayed = true; } } else { if (relativeLayout.getY() < mainView.getHeight()) { currentlyDisplayed = true; } } // The view is currently shown to the user if (currentlyDisplayed) { // If the message is not the same, we hide the current message and display the new one if (!StringUtils.equals(text, textView.getText())) { // Anim out the current message ViewPropertyAnimator viewPropertyAnimator = animOut(configuration, mainView, relativeLayout); final RelativeLayout relativeLayoutFinal = relativeLayout; if (viewPropertyAnimator != null) { // Anim in the new message after the animation out has finished if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { viewPropertyAnimator.setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } else { viewPropertyAnimator.withEndAction(new Runnable() { @Override public void run() { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }); } } else { setIcon(context, configuration, relativeLayoutFinal, textView); animIn(configuration, relativeLayoutFinal, textView, mainView, text); } } } } final RelativeLayout relativeLayoutFinal = relativeLayout; // Close the alert by clicking the layout if (configuration.isCloseable()) { relativeLayout.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { animOut(configuration, mainView, relativeLayoutFinal); v.performClick(); return true; } }); } if (!currentlyDisplayed) { // Set the icon in case the alert already exists but it's not currently displayed if (alertAlreadyExists) { setIcon(context, configuration, relativeLayoutFinal, textView); } // We anim in the alert animIn(configuration, relativeLayoutFinal, textView, mainView, text); } }
From source file:com.intel.xdk.device.Device.java
@Override public void initialize(CordovaInterface cordova, final CordovaWebView webView) { super.initialize(cordova, webView); this.activity = cordova.getActivity(); this.webView = webView; //remote site support remoteLayout = new AbsoluteLayout(activity); remoteLayout.setBackgroundColor(Color.BLACK); //hide the remote site display until needed remoteLayout.setVisibility(View.GONE); //create the close button remoteClose = new ImageButton(activity); remoteClose.setBackgroundColor(Color.TRANSPARENT); Drawable remoteCloseImage = null;/*from w w w .j a v a 2s.c om*/ remoteCloseImage = activity.getResources().getDrawable( activity.getResources().getIdentifier("remote_close", "drawable", activity.getPackageName())); File remoteCloseImageFile = new File(activity.getFilesDir(), "_intelxdk/remote_close.png"); if (remoteCloseImageFile.exists()) { remoteCloseImage = (Drawable.createFromPath(remoteCloseImageFile.getAbsolutePath())); } else { remoteCloseImage = (activity.getResources().getDrawable( activity.getResources().getIdentifier("remote_close", "drawable", activity.getPackageName()))); } //set the button image //remoteClose.setImageDrawable(remoteCloseImage); remoteClose.setBackgroundDrawable(remoteCloseImage); //set up the button click action remoteClose.setOnClickListener(new OnClickListener() { public void onClick(View v) { closeRemoteSite(); } }); //add the close button remoteLayout.addView(remoteClose); final ViewGroup parent = (ViewGroup) webView.getEngine().getView().getParent(); activity.runOnUiThread(new Runnable() { public void run() { if (parent != null) { //add layout to activity root layout parent.addView(remoteLayout, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER)); } } }); //Initialize the orientation. lastOrientation = "unknown"; //Listen to the orientation change. OrientationEventListener listener = new OrientationEventListener(activity) { @Override public void onOrientationChanged(int orientation) { //Log.d("orientation","orientation: " + orientation); String currentOrientation = "unknown"; boolean orientationChanged = false; //int displayOrientation = 0; if (orientation > 345 || orientation < 15) { currentOrientation = "portrait"; displayOrientation = 0; } else if (orientation > 75 && orientation < 105) { currentOrientation = "landscape"; displayOrientation = 90; } else if (orientation > 165 && orientation < 195) { currentOrientation = "portrait"; displayOrientation = 180; } else if (orientation > 255 && orientation < 285) { currentOrientation = "landscape"; displayOrientation = -90; } if (currentOrientation.equals("unknown")) { currentOrientation = lastOrientation; } if (!currentOrientation.equals(lastOrientation)) { orientationChanged = true; Log.d("orientation", "Orientation changes from " + lastOrientation + " to " + currentOrientation + ", current orientation: " + orientation + "."); } if (orientationChanged) { String js = "javascript:try{intel.xdk.device.orientation='" + displayOrientation + "';}catch(e){}var e = document.createEvent('Events');e.initEvent('intel.xdk.device.orientation.change', true, true);e.success=true;e.orientation='" + displayOrientation + "';document.dispatchEvent(e);"; injectJS(js); } lastOrientation = currentOrientation; } }; listener.enable(); registerScreenStatusReceiver(); //cache references to methods for use in injectJS try { evaluateJavascript = webView.getClass().getMethod("evaluateJavascript", String.class, ValueCallback.class); } catch (Exception e) { } try { sendJavascript = webView.getClass().getMethod("sendJavascript", String.class); } catch (Exception e) { } emptyVC = new ValueCallback<String>() { @Override public void onReceiveValue(String s) { } }; }
From source file:com.roamprocess1.roaming4world.ui.favorites.FavAdapter.java
@Override public void bindView(View view, final Context context, Cursor cursor) { ContentValues cv = new ContentValues(); DatabaseUtils.cursorRowToContentValues(cursor, cv); int type = ContactsWrapper.TYPE_CONTACT; if (cv.containsKey(ContactsWrapper.FIELD_TYPE)) { type = cv.getAsInteger(ContactsWrapper.FIELD_TYPE); }//from ww w . j a v a 2s . c o m showViewForType(view, type); if (type == ContactsWrapper.TYPE_GROUP) { // Get views TextView tv = (TextView) view.findViewById(R.id.header_text); ImageView icon = (ImageView) view.findViewById(R.id.header_icon); // PresenceStatusSpinner presSpinner = (PresenceStatusSpinner) view.findViewById(R.id.header_presence_spinner); // Get datas SipProfile acc = new SipProfile(cursor); final Long profileId = cv.getAsLong(BaseColumns._ID); final String groupName = acc.android_group; final String displayName = acc.display_name; final String wizard = acc.wizard; final boolean publishedEnabled = (acc.publish_enabled == 1); final String domain = acc.getDefaultDomain(); // Bind datas to view //tv.setText(displayName); //Commented by Esstel Softwares tv.setText("Starred Android Contacts"); icon.setImageResource(WizardUtils.getWizardIconRes(wizard)); // presSpinner.setProfileId(profileId); // Extra menu view if not already set ViewGroup menuViewWrapper = (ViewGroup) view.findViewById(R.id.header_cfg_spinner); MenuCallback newMcb = new MenuCallback(context, profileId, groupName, domain, publishedEnabled); MenuBuilder menuBuilder; if (menuViewWrapper.getTag() == null) { final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); ActionMenuPresenter mActionMenuPresenter = new ActionMenuPresenter(mContext); mActionMenuPresenter.setReserveOverflow(true); menuBuilder = new MenuBuilder(context); menuBuilder.setCallback(newMcb); MenuInflater inflater = new MenuInflater(context); inflater.inflate(R.menu.fav_menu_new, menuBuilder); menuBuilder.addMenuPresenter(mActionMenuPresenter); ActionMenuView menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(menuViewWrapper); UtilityWrapper.getInstance().setBackgroundDrawable(menuView, null); menuViewWrapper.addView(menuView, layoutParams); menuViewWrapper.setTag(menuBuilder); } else { menuBuilder = (MenuBuilder) menuViewWrapper.getTag(); menuBuilder.setCallback(newMcb); } // menuBuilder.findItem(R.id.share_presence).setTitle(publishedEnabled ? R.string.deactivate_presence_sharing : R.string.activate_presence_sharing); // menuBuilder.findItem(R.id.set_sip_data).setVisible(!TextUtils.isEmpty(groupName)); } else if (type == ContactsWrapper.TYPE_CONTACT) { ContactInfo ci = ContactsWrapper.getInstance().getContactInfo(context, cursor); ci.userData = cursor.getPosition(); // Get views TextView tv = (TextView) view.findViewById(R.id.contact_name); QuickContactBadge badge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo); TextView statusText = (TextView) view.findViewById(R.id.status_text); ImageView statusImage = (ImageView) view.findViewById(R.id.status_icon); // Bind if (ci.contactId != null) { tv.setText(ci.displayName); badge.assignContactUri(ci.callerInfo.contactContentUri); ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(context, badge.getImageView(), ci.callerInfo, R.drawable.ic_contact_picture_holo_dark); statusText.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusText.setText(ci.status); statusImage.setVisibility(ci.hasPresence ? View.VISIBLE : View.GONE); statusImage.setImageResource(ContactsWrapper.getInstance().getPresenceIconResourceId(ci.presence)); } View v; v = view.findViewById(R.id.contact_view); v.setTag(ci); v.setOnClickListener(mPrimaryActionListener); v = view.findViewById(R.id.secondary_action_icon); v.setTag(ci); v.setOnClickListener(mSecondaryActionListener); } else if (type == ContactsWrapper.TYPE_CONFIGURE) { // We only bind if it's the correct type // View v = view.findViewById(R.id.configure_view); //v.setOnClickListener(this); //ConfigureObj cfg = new ConfigureObj(); // cfg.profileId = cv.getAsLong(BaseColumns._ID); // v.setTag(cfg); } }
From source file:cs.umass.edu.prepare.view.custom.CalendarAdapter.java
/** * Populates the calendar cell for the given date key with the adherence data for that date. * @param dateKey a {@link Calendar} object encoding the date. Only month, year and date fields are relevant. * @param insertPoint the {@link ViewGroup} parent to which to append the views. *//*from w ww . j a v a2 s. com*/ private void populateCell(Calendar dateKey, ViewGroup insertPoint) { Map<Medication, Adherence[]> adherenceMap = adherenceData.get(dateKey); for (Medication medication : medications) { View calendarItem = View.inflate(context, R.layout.view_adherence_details_simple, null); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); View pillAdherenceView1 = calendarItem.findViewById(R.id.pill_adherence1); View pillAdherenceView2 = calendarItem.findViewById(R.id.pill_adherence2); Adherence[] adherence = adherenceMap.get(medication); if (adherence[0].getAdherenceType() == Adherence.AdherenceType.NONE) { pillAdherenceView1.setVisibility(View.INVISIBLE); } else { pillAdherenceView1 .setBackground(Utils.getDrawableForAdherence(context, adherence[0].getAdherenceType())); } if (adherence[1].getAdherenceType() == Adherence.AdherenceType.NONE) { pillAdherenceView2.setVisibility(View.INVISIBLE); } else { pillAdherenceView2 .setBackground(Utils.getDrawableForAdherence(context, adherence[1].getAdherenceType())); } layoutParams.setMargins(0, 5, 0, 5); insertPoint.addView(calendarItem, layoutParams); //, 1, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } }
From source file:de.dreier.mytargets.views.MaterialTapTargetPrompt.java
/** * Displays the prompt.//from www .j av a 2 s.c o m */ public void show() { final ViewGroup parent = getParentView(); // If the content view is a drawer layout then that is the parent so // that the prompt can be added behind the navigation drawer if (parent.getClass().getName().equals("android.support.v4.widget.DrawerLayout")) { parent.addView(mView, 1); } else { parent.addView(mView); } addGlobalLayoutListener(); updateFocalCentrePosition(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { startRevealAnimation(); } else { mView.mBackgroundRadius = mBaseBackgroundRadius; mView.mFocalRadius = mBaseFocalRadius; mView.mPaintFocal.setAlpha(255); mView.mPaintBackground.setAlpha(244); mPaintSecondaryText.setAlpha(mSecondaryTextColourAlpha); mPaintPrimaryText.setAlpha(mPrimaryTextColourAlpha); } }
From source file:com.androzic.MapFragment.java
private void onUpdateNavigationState() { boolean isNavigating = application.navigationService != null && application.navigationService.isNavigating(); boolean isNavigatingViaRoute = isNavigating && application.navigationService.isNavigatingViaRoute(); View rootView = getView();/*from w w w. j av a 2s .c o m*/ // waypoint panel rootView.findViewById(R.id.waypointinfo).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // route panel rootView.findViewById(R.id.routeinfo).setVisibility(isNavigatingViaRoute ? View.VISIBLE : View.GONE); // distance distanceValue.setVisibility(isNavigating ? View.VISIBLE : View.GONE); rootView.findViewById(R.id.distancelt).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // bearing bearingValue.setVisibility(isNavigating ? View.VISIBLE : View.GONE); rootView.findViewById(R.id.bearinglt).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // turn turnValue.setVisibility(isNavigating ? View.VISIBLE : View.GONE); rootView.findViewById(R.id.turnlt).setVisibility(isNavigating ? View.VISIBLE : View.GONE); // xtk xtkValue.setVisibility(isNavigatingViaRoute ? View.VISIBLE : View.GONE); rootView.findViewById(R.id.xtklt).setVisibility(isNavigatingViaRoute ? View.VISIBLE : View.GONE); // we hide elevation in portrait mode due to lack of space if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) { if (isNavigatingViaRoute && elevationValue.getVisibility() == View.VISIBLE) { elevationValue.setVisibility(View.GONE); rootView.findViewById(R.id.elevationlt).setVisibility(View.GONE); ViewGroup row = (ViewGroup) rootView.findViewById(R.id.movingrow); int pos = row.indexOfChild(elevationValue); View xtklt = rootView.findViewById(R.id.xtklt); row.removeView(xtkValue); row.removeView(xtklt); row.addView(xtklt, pos); row.addView(xtkValue, pos); row.getParent().requestLayout(); } else if (!isNavigatingViaRoute && elevationValue.getVisibility() == View.GONE) { elevationValue.setVisibility(View.VISIBLE); rootView.findViewById(R.id.elevationlt).setVisibility(View.VISIBLE); ViewGroup row = (ViewGroup) rootView.findViewById(R.id.movingrow); int pos = row.indexOfChild(xtkValue); View elevationlt = rootView.findViewById(R.id.elevationlt); row.removeView(elevationValue); row.removeView(elevationlt); row.addView(elevationlt, pos); row.addView(elevationValue, pos); row.getParent().requestLayout(); } } if (isNavigatingViaRoute) { routeName.setText("\u21d2 " + application.navigationService.navRoute.name); } if (isNavigating) { waypointName.setText("\u2192 " + application.navigationService.navWaypoint.name); } updateMapViewArea(); map.refreshMap(); }