Example usage for android.view View View

List of usage examples for android.view View View

Introduction

In this page you can find the example usage for android.view View View.

Prototype

public View(Context context) 

Source Link

Document

Simple constructor to use when creating a view from code.

Usage

From source file:es.glasspixel.wlanaudit.activities.SlidingMapActivity.java

/**
 * {@inheritDoc}/*  www .  j  a  v  a2s.  c om*/
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(ab_title);
    setContentView(R.layout.responsive_content_frame);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // create our manager instance after the content view is set
    SystemBarTintManager tintManager = new SystemBarTintManager(this);
    // enable status bar tint
    tintManager.setStatusBarTintEnabled(true);
    tintManager.setStatusBarTintResource(R.color.wlanaudit_material);

    // UI form factor check
    if (findViewById(R.id.menu_frame) == null) {
        // If this is phone UI
        showcaseView = true;
        setBehindContentView(R.layout.menu_frame);
        setSlidingActionBarEnabled(false);
        getSlidingMenu().setSlidingEnabled(true);
        //getSlidingMenu().setMode(SlidingMenu.LEFT);
        getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN);
    } else {
        // If this is tablet UI
        getSlidingMenu().setSlidingEnabled(false);
        setBehindContentView(new View(this));
    }

    // set the Above View Fragment
    if (savedInstanceState != null)
        mMapFragment = (GMapsMapFragment) getSupportFragmentManager().getFragment(savedInstanceState,
                MAP_FRAGMENT_KEY);
    if (mMapFragment == null) {
        mMapFragment = GMapsMapFragment.newInstance();
    }

    // Location client setup
    mLocationServicesWrapper = new GMSLocationServicesWrapper(this, this);

    // Set the map fragment
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, mMapFragment).commit();

    // Set the network list fragment
    getSupportFragmentManager().beginTransaction().replace(R.id.menu_frame, new SavedNetworksMenuFragment())
            .commit();

    // customize the SlidingMenu
    SlidingMenu sm = getSlidingMenu();
    setUpSlidingMenu(sm);

    // Set up the showcase view
    setUpShowCaseView(sm);
}

From source file:com.sonvp.tooltip.Tooltip.java

private Tooltip(Builder builder) {
    this.builder = builder;
    this.anchorView = builder.anchorView;
    this.gravity = builder.tooltipGravity;

    if (builder.dismissOutsideTouch) {

        rootView = (ViewGroup) anchorView.getRootView();
        overlay = new View(builder.context);
        overlay.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));
        //        overlay.setBackgroundColor(builder.context.getResources().getColor(android.R.color.holo_green_light));
        overlay.setOnTouchListener(this);
        rootView.addView(overlay);// ww  w .  j a va2  s  .c om
    }

    // TODO container should NOT capture all events
    container = new LinearLayout(builder.context);
    container.setOnClickListener(this);

    int backgroundColor = builder.backgroundColor;

    viewTooltip = getViewTooltip(builder, backgroundColor);

    rectAnchorView = getRectView(anchorView);
    changeGravityToolTip();
    if (builder.arrowDrawable == null) {
        builder.arrowDrawable = new ArrowDrawable(backgroundColor, gravity);
    }

    arrow = new ImageView(builder.context);
    // TODO supports Gravity.NO_GRAVITY
    switch (gravity) {
    case Gravity.LEFT:
        container.setOrientation(LinearLayout.HORIZONTAL);
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        break;
    case Gravity.RIGHT:
        container.setOrientation(LinearLayout.HORIZONTAL);
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        break;
    case Gravity.TOP:
        container.setOrientation(LinearLayout.VERTICAL);
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        break;
    case Gravity.BOTTOM:
        container.setOrientation(LinearLayout.VERTICAL);
        arrow.setImageDrawable(builder.arrowDrawable);
        container.addView(arrow,
                new LinearLayout.LayoutParams((int) builder.arrowWidth, (int) builder.arrowHeight));
        container.addView(viewTooltip, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.WRAP_CONTENT));
        break;
    }

    popupWindow = new PopupWindow(container, ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    popupWindow.setOnDismissListener(this);
    popupWindow.setClippingEnabled(false);
    popupWindow.setAnimationStyle(android.R.style.Animation);
    //        popupWindow.setBackgroundDrawable(builder.context.getResources().getDrawable(android.R.color.holo_blue_bright));

}

From source file:com.prettygirl.avgallery.components.FixedTabsView.java

/**
 * Creates and returns a new Separator View
 * /*  ww  w  .  ja v a 2  s . c o  m*/
 * @return
 */
@SuppressWarnings("deprecation")
private View getSeparator() {
    View v = new View(mContext);

    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(1, LayoutParams.FILL_PARENT);
    params.setMargins(0, mDividerMarginTop, 0, mDividerMarginBottom);
    v.setLayoutParams(params);

    if (mDividerDrawable != null)
        v.setBackgroundDrawable(mDividerDrawable);
    else
        v.setBackgroundColor(mDividerColor);
    v.setVisibility(mDividerVisibility);
    return v;
}

From source file:org.chromium.chrome.browser.omnibox.SuggestionView.java

/**
 * Constructs a new omnibox suggestion view.
 *
 * @param context The context used to construct the suggestion view.
 * @param locationBar The location bar showing these suggestions.
 *///from w w  w.j  a  v a2  s . c  om
public SuggestionView(Context context, LocationBar locationBar) {
    super(context);
    mLocationBar = locationBar;

    mSuggestionHeight = context.getResources().getDimensionPixelOffset(R.dimen.omnibox_suggestion_height);
    mSuggestionAnswerHeight = context.getResources()
            .getDimensionPixelOffset(R.dimen.omnibox_suggestion_answer_height);

    TypedArray a = getContext().obtainStyledAttributes(new int[] { R.attr.selectableItemBackground });
    Drawable itemBackground = a.getDrawable(0);
    a.recycle();

    mContentsView = new SuggestionContentsContainer(context, itemBackground);
    addView(mContentsView);

    mRefineView = new View(context) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);

            if (mRefineIcon == null)
                return;
            canvas.save();
            canvas.translate((getMeasuredWidth() - mRefineIcon.getIntrinsicWidth()) / 2f,
                    (getMeasuredHeight() - mRefineIcon.getIntrinsicHeight()) / 2f);
            mRefineIcon.draw(canvas);
            canvas.restore();
        }

        @Override
        public void setVisibility(int visibility) {
            super.setVisibility(visibility);

            if (visibility == VISIBLE) {
                setClickable(true);
                setFocusable(true);
            } else {
                setClickable(false);
                setFocusable(false);
            }
        }

        @Override
        protected void drawableStateChanged() {
            super.drawableStateChanged();

            if (mRefineIcon != null && mRefineIcon.isStateful()) {
                mRefineIcon.setState(getDrawableState());
            }
        }
    };
    mRefineView.setContentDescription(getContext().getString(R.string.accessibility_omnibox_btn_refine));

    // Although this has the same background as the suggestion view, it can not be shared as
    // it will result in the state of the drawable being shared and always showing up in the
    // refine view.
    mRefineView.setBackground(itemBackground.getConstantState().newDrawable());
    mRefineView.setId(R.id.refine_view_id);
    mRefineView.setClickable(true);
    mRefineView.setFocusable(true);
    mRefineView.setLayoutParams(new LayoutParams(0, 0));
    addView(mRefineView);

    mRefineWidth = getResources().getDimensionPixelSize(R.dimen.omnibox_suggestion_refine_width);

    mUrlBar = (UrlBar) locationBar.getContainerView().findViewById(R.id.url_bar);

    mPhoneUrlBarLeftOffsetPx = getResources()
            .getDimensionPixelOffset(R.dimen.omnibox_suggestion_phone_url_bar_left_offset);
    mPhoneUrlBarLeftOffsetRtlPx = getResources()
            .getDimensionPixelOffset(R.dimen.omnibox_suggestion_phone_url_bar_left_offset_rtl);
}

From source file:com.gqp.duoduo.view.SettlementView.java

private void bindData() {

    viewModel.bindContent(new Action1<Settlement.SettleMessageEntity>() {
        @Override//  www  . ja  va 2 s .co m
        public void call(Settlement.SettleMessageEntity deliverModels) {

            settleMessageEntity = deliverModels;
            moneyText.setText("" + settleMessageEntity.getSettelmentTotal().get("goodstotalamount"));

            if (deliverModels != null) {
                mList = deliverModels.getSettelment();
                dataLayout.setVisibility(View.VISIBLE);
                noDataLayout.setVisibility(View.GONE);

                container.removeAllViews();

                LayoutInflater inflater = LayoutInflater.from(getContext());

                View headerView = inflater.inflate(R.layout.common_item_hearder_layout, null);
                ((TextView) headerView.findViewById(R.id.common_item_01)).setText("??");
                ((TextView) headerView.findViewById(R.id.common_item_02)).setText("?");
                headerView.setBackgroundResource(R.color.gray_whiter);
                container.addView(headerView);
                View headdivider = new View(getContext());
                headdivider.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
                headdivider.setBackgroundColor(Color.parseColor("#DDDDDD"));
                container.addView(headdivider);

                int index = 0;
                for (Settlement.MarketSettleEntity marketModel : mList) {

                    View view = inflater.inflate(R.layout.common_item_layout, null);
                    ViewMarketItemHolder holder = new ViewMarketItemHolder(view);
                    holder.bind(marketModel, index);
                    container.addView(view);

                    View divider = new View(getContext());
                    divider.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
                    divider.setBackgroundColor(Color.parseColor("#DDDDDD"));
                    container.addView(divider);
                    index++;
                }
                if (mList != null && mList.size() > 0) {
                    View footerdivider = new View(getContext());
                    footerdivider.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 38));
                    footerdivider.setBackgroundColor(Color.parseColor("#ededed"));
                    container.addView(footerdivider);
                }
                int sIndex = 0;
                List<CommonItem> tmpList = formatData(deliverModels.getSettelmentTotal());
                for (CommonItem commonItem : tmpList) {

                    View view = inflater.inflate(R.layout.common_item_hearder_layout, null);
                    ViewItemHolder holder = new ViewItemHolder(view);
                    holder.bind(commonItem, index);
                    container.addView(view);
                    View divider = new View(getContext());
                    divider.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
                    divider.setBackgroundColor(Color.parseColor("#DDDDDD"));
                    container.addView(divider);
                    if (sIndex == 0) {
                        View footerView01 = new View(getContext());
                        footerView01.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 38));
                        footerView01.setBackgroundResource(R.color.gray_whiter);
                        container.addView(footerView01);
                        View viewitem = inflater.inflate(R.layout.common_item_header_layout, null);
                        ViewItemHeaderHolder holderitem = new ViewItemHeaderHolder(viewitem);
                        holderitem.bind("?", index);
                        container.addView(viewitem);
                        View divider01 = new View(getContext());
                        divider01.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
                        divider01.setBackgroundColor(Color.parseColor("#DDDDDD"));
                        container.addView(divider01);
                    }
                    if (sIndex <= 2) {
                        if (sIndex == 2) {
                            View footerView01 = new View(getContext());
                            footerView01
                                    .setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 38));
                            footerView01.setBackgroundResource(R.color.gray_whiter);
                            container.addView(footerView01);

                        }
                    }
                    if (sIndex > 2 && sIndex <= 6) {
                        if (sIndex == 6) {
                            View footerView01 = new View(getContext());
                            footerView01
                                    .setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 38));
                            footerView01.setBackgroundResource(R.color.gray_whiter);
                            container.addView(footerView01);
                        }
                    }
                    sIndex++;
                }

            } else {
                dataLayout.setVisibility(View.GONE);
                noDataLayout.setVisibility(View.VISIBLE);
                container.setVisibility(View.GONE);
            }

        }
    });

}

From source file:com.doomonafireball.betterpickers.radialtimepicker.RadialPickerLayout.java

public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;//w ww  .java2 s . co m

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    mLastValueSelected = -1;

    mInputEnabled = true;
    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(getResources().getColor(R.color.transparent_black));
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}

From source file:com.codetroopers.betterpickers.radialtimepicker.RadialPickerLayout.java

public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;/*w ww  .j  av  a 2 s .  co m*/

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    mLastValueSelected = -1;

    mInputEnabled = true;
    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(getResources().getColor(R.color.bpTransparent_black));
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}

From source file:com.a.mirko.android.datetimepicker.time.RadialPickerLayout.java

public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;//w  w w  .  jav a2 s  .  c  o m

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    mVibrator = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
    mLastVibrate = 0;
    mLastValueSelected = -1;

    mInputEnabled = true;
    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(getResources().getColor(R.color.transparent_black));
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}

From source file:com.laer.easycast.ImagePane.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View root = new View(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    root.setBackgroundColor(Color.WHITE);
    root = inflater.inflate(R.layout.imagepane, container, false);
    setHasOptionsMenu(true);/*from  w  w  w  .  j  ava  2 s.  c  o m*/
    myViewGroup = container;

    cursor = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,

            projection, // Which columns to return

            null, // Return all rows

            null,

            MediaStore.Images.Media.DEFAULT_SORT_ORDER);

    GridView gridView = (GridView) root.findViewById(R.id.gridView1);

    gridView.setAdapter(new ImageAdapter(getActivity()));

    gridView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

            columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
            cursor.moveToPosition(position);

            // Get image filename
            String imagePath = cursor.getString(columnIndex);
            Bitmap image = BitmapFactory.decodeFile(imagePath);

            Log.i("ImagePath=", imagePath);
            Log.d(TAG, "Image decoded");
            photoRaw(image, NONE);

            // Use this path to do further processing, i.e. full screen
            // display
        }
    });

    return root;
}

From source file:org.holoeverywhere.widget.datetimepicker.time.RadialPickerLayout.java

public RadialPickerLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    setOnTouchListener(this);
    ViewConfiguration vc = ViewConfiguration.get(context);
    TOUCH_SLOP = vc.getScaledTouchSlop();
    TAP_TIMEOUT = ViewConfiguration.getTapTimeout();
    mDoingMove = false;/*from   w w w.j a  v  a2 s.  co  m*/

    mCircleView = new CircleView(context);
    addView(mCircleView);

    mAmPmCirclesView = new AmPmCirclesView(context);
    addView(mAmPmCirclesView);

    mHourRadialTextsView = new RadialTextsView(context);
    addView(mHourRadialTextsView);
    mMinuteRadialTextsView = new RadialTextsView(context);
    addView(mMinuteRadialTextsView);

    mHourRadialSelectorView = new RadialSelectorView(context);
    addView(mHourRadialSelectorView);
    mMinuteRadialSelectorView = new RadialSelectorView(context);
    addView(mMinuteRadialSelectorView);

    // Prepare mapping to snap touchable degrees to selectable degrees.
    preparePrefer30sMap();

    if (context.getPackageManager().checkPermission(Manifest.permission.VIBRATE,
            context.getPackageName()) == PackageManager.PERMISSION_GRANTED) {
        mVibrator = (Vibrator) context.getSystemService(Service.VIBRATOR_SERVICE);
    }
    mLastVibrate = 0;
    mLastValueSelected = -1;

    mInputEnabled = true;
    mGrayBox = new View(context);
    mGrayBox.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));
    mGrayBox.setBackgroundColor(0x7F000000);
    mGrayBox.setVisibility(View.INVISIBLE);
    addView(mGrayBox);

    mAccessibilityManager = (AccessibilityManager) context.getSystemService(Context.ACCESSIBILITY_SERVICE);

    mTimeInitialized = false;
}