IT. Expert System.

Android Reference

ViewStub


android.view

Class ViewStub

  • All Implemented Interfaces:
    Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback


    public final class ViewStub
    extends View
    A ViewStub is an invisible, zero-sized View that can be used to lazily inflate layout resources at runtime. When a ViewStub is made visible, or when inflate() is invoked, the layout resource is inflated. The ViewStub then replaces itself in its parent with the inflated View or Views. Therefore, the ViewStub exists in the view hierarchy until setVisibility(int) or inflate() is invoked. The inflated View is added to the ViewStub's parent with the ViewStub's layout parameters. Similarly, you can define/override the inflate View's id by using the ViewStub's inflatedId property. For instance:
         <ViewStub android:id="@+id/stub"
                   android:inflatedId="@+id/subTree"
                   android:layout="@layout/mySubTree"
                   android:layout_width="120dip"
                   android:layout_height="40dip" />
     
    The ViewStub thus defined can be found using the id "stub." After inflation of the layout resource "mySubTree," the ViewStub is removed from its parent. The View created by inflating the layout resource "mySubTree" can be found using the id "subTree," specified by the inflatedId property. The inflated View is finally assigned a width of 120dip and a height of 40dip. The preferred way to perform the inflation of the layout resource is the following:
         ViewStub stub = (ViewStub) findViewById(R.id.stub);
         View inflated = stub.inflate();
     
    When inflate() is invoked, the ViewStub is replaced by the inflated View and the inflated View is returned. This lets applications get a reference to the inflated View without executing an extra findViewById().
    • Constructor Detail

      • ViewStub

        public ViewStub(Context context)
      • ViewStub

        public ViewStub(Context context,
                int layoutResource)
        Creates a new ViewStub with the specified layout resource.
        Parameters:
        context - The application's environment.
        layoutResource - The reference to a layout resource that will be inflated.
    • Method Detail

      • getInflatedId

        public int getInflatedId()
        Returns the id taken by the inflated view. If the inflated id is View.NO_ID, the inflated view keeps its original id.
        Returns:
        A positive integer used to identify the inflated view or View.NO_ID if the inflated view should keep its id.
        See Also:
        setInflatedId(int)
      • setInflatedId

        public void setInflatedId(int inflatedId)
        Defines the id taken by the inflated view. If the inflated id is View.NO_ID, the inflated view keeps its original id.
        Parameters:
        inflatedId - A positive integer used to identify the inflated view or View.NO_ID if the inflated view should keep its id.
        See Also:
        getInflatedId()
      • setLayoutResource

        public void setLayoutResource(int layoutResource)
        Specifies the layout resource to inflate when this StubbedView becomes visible or invisible or when inflate() is invoked. The View created by inflating the layout resource is used to replace this StubbedView in its parent.
        Parameters:
        layoutResource - A valid layout resource identifier (different from 0.)
        See Also:
        getLayoutResource(), setVisibility(int), inflate()
      • draw

        public void draw(Canvas canvas)
        Description copied from class: View
        Manually render this view (and all of its children) to the given Canvas. The view must have already done a full layout before this function is called. When implementing a view, implement View.onDraw(android.graphics.Canvas) instead of overriding this method. If you do need to override this method, call the superclass version.
        Overrides:
        draw in class View
        Parameters:
        canvas - The Canvas to which the View is rendered.
      • dispatchDraw

        protected void dispatchDraw(Canvas canvas)
        Description copied from class: View
        Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).
        Overrides:
        dispatchDraw in class View
        Parameters:
        canvas - the canvas on which to draw the view
      • inflate

        public View inflate()
        Inflates the layout resource identified by getLayoutResource() and replaces this StubbedView in its parent by the inflated layout resource.
        Returns:
        The inflated layout resource.
      • setOnInflateListener

        public void setOnInflateListener(ViewStub.OnInflateListener inflateListener)
        Specifies the inflate listener to be notified after this ViewStub successfully inflated its layout resource.
        Parameters:
        inflateListener - The OnInflateListener to notify of successful inflation.
        See Also:
        ViewStub.OnInflateListener


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 2376 / . Delta: 0.17180 с