日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
基于Android8.0分析源碼的ViewStub源碼解析

源碼基于安卓8.0分析結(jié)果

創(chuàng)新互聯(lián)公司基于分布式IDC數(shù)據(jù)中心構(gòu)建的平臺(tái)為眾多戶提供成都西云數(shù)據(jù)中心 四川大帶寬租用 成都機(jī)柜租用 成都服務(wù)器租用。

ViewStub是一種不可見的并且大小為0的試圖,它可以延遲到運(yùn)行時(shí)才填充inflate 布局資源,當(dāng)Viewstub設(shè)為可見或者是inflate的時(shí)候,就會(huì)填充布局資源,這個(gè)布局和普通的試圖就基本上沒有任何區(qū)別,比如說,加載網(wǎng)絡(luò)失敗,或者是一個(gè)比較消耗性能的功能,需要用戶去點(diǎn)擊才可以加載!從而這樣更加的節(jié)約了性能。對(duì)安卓布局很友好!

ViewStub用法

 
 
 
 
  1.     android:padding="10dp"
  2.     android:background="@color/colorPrimary"
  3.     android:layout_gravity="center"
  4.     android:inflatedId="@+id/view_stub_inflateid"
  5.     android:id="@+id/view_stub"
  6.     android:layout="@layout/view_stub_imageview"
  7.     android:layout_width="wrap_content"
  8.     android:layout_height="wrap_content" />

這篇文章安卓代碼、圖片、布局、網(wǎng)絡(luò)和電量優(yōu)化說如果這個(gè)根布局是個(gè)View,比如說是個(gè)ImagView,那么找出來的id為null,得必須注意這一點(diǎn) -----2018.6.7修正這個(gè)說法,以前我說的是錯(cuò)誤的,根本上的原因是ViewStub設(shè)置了 inflateid ,這才是更本身的原因

在這里記住一點(diǎn),如果在 ViewStub標(biāo)簽中設(shè)置了android:inflatedId="@+id/view_stub_inflateid",在layout布局中的根布局在設(shè)置android:id="@+id/view_stub_layout",這個(gè)id永遠(yuǎn)找出來都是為null的,原因會(huì)在下面說明

 
 
 
 
  1.     android:padding="10dp"
  2.     android:id="@+id/view_stub_layout"
  3.     android:src="@drawable/ic_launcher_background"
  4.     android:layout_width="match_parent"
  5.     android:layout_height="match_parent">
  6.     
  7.         android:text="如果這個(gè)根布局是個(gè)View,比如說是個(gè)ImagView,那么找出來的id為null,得必須注意這一點(diǎn)  -----2018.6.7修正這個(gè)說法,以前我說的是錯(cuò)誤的,根本上的原因是ViewStub設(shè)置了 inflateid ,這才是更本身的原因"
  8.         android:layout_width="wrap_content"
  9.         android:layout_height="wrap_content" />
  10.     
  11.         android:layout_marginTop="20dp"
  12.         android:id="@+id/imageview"
  13.         android:padding="10dp"
  14.         android:src="@drawable/ic_launcher_background"
  15.         android:layout_width="match_parent"
  16.         android:layout_height="match_parent"/>

在activity或者是fragment中的使用,mViewStub.getParent()==null就是說明沒有被填充,需要填充,如果填充了,那么它的parent不會(huì)為null,具體的騷操作,后續(xù)我介紹View的繪制流程的時(shí)候在詳細(xì)說明。

第一種使用的方法

 
 
 
 
  1.  mViewStub = findViewById(R.id.view_stub);
  2.  if (null!=mViewStub.getParent()){
  3.  View inflate = mViewStub.inflate();
  4.  ....
  5. }

第二種方式:mViewStub.setVisibility(View.VISIBLE);和inflate()方法一樣。

 
 
 
 
  1.  mViewStub = findViewById(R.id.view_stub);
  2.  if (null!=mViewStub.getParent()){
  3.    mViewStub.setVisibility(View.VISIBLE);
  4.  ....
  5. }

第三種方式,my_title_parent_id是layout的根布局的id

 
 
 
 
  1. mViewStub = findViewById(R.id.view_stub);
  2.  // 成員變量commLv2為空則代表未加載 commLv2 的id為ViewStub中的根布局的id
  3.  View commLv2=findViewById(R.id.my_title_parent_id);
  4. if ( commLv2 == null ) {
  5.    // 加載評(píng)論列表布局, 并且獲取評(píng)論ListView,inflate函數(shù)直接返回ListView對(duì)象
  6.      commLv2 = (View)mViewStub.inflate();
  7.    } else {
  8.       // ViewStub已經(jīng)加載
  9.   }

ViewStub構(gòu)造方法,注意獲取了幾個(gè)值mInflatedId就是android:inflatedId="@+id/find_view_stub"這個(gè)值, mLayoutResource就是layout的resId,ViewStub的 mIDid。可以看出ViewStub是View的子類.

 
 
 
 
  1. public final class ViewStub extends View {
  2.  public ViewStub(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
  3.         super(context);
  4.         final TypedArray a = context.obtainStyledAttributes(attrs,
  5.                 R.styleable.ViewStub, defStyleAttr, defStyleRes);
  6.         // TODO: 2018/5/23  ViewStub 中設(shè)置的標(biāo)簽id 如果設(shè)置了 這里就一定有值 mInflatedId!=NO_Id
  7.         mInflatedId = a.getResourceId(R.styleable.ViewStub_inflatedId, NO_ID);
  8.         mLayoutResource = a.getResourceId(R.styleable.ViewStub_layout, 0);
  9.         mID = a.getResourceId(R.styleable.ViewStub_id, NO_ID);
  10.         a.recycle();
  11.         //不可見
  12.         setVisibility(GONE);
  13.         // 設(shè)置不繪制
  14.         setWillNotDraw(true);
  15.     }
  16. }

在構(gòu)造方法中:同時(shí)注意不可見 setVisibility(GONE); ,設(shè)置不繪制setWillNotDraw(true);,同時(shí)通過下面的方法看出,ViewStub 是一個(gè)大小為0的視圖。

 
 
 
 
  1. @Override
  2.   protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  3.       // 寬高都為0   onMeasure的時(shí)候 寬高都為0
  4.       setMeasuredDimension(0, 0);
  5.   }
  6.   //todo 為啥這個(gè)控件 是個(gè)大小為0的控件 ,那是因?yàn)樗麐尩倪@里更不就沒有畫
  7.   @Override
  8.   public void draw(Canvas canvas) {
  9.   }
  10.   @Override
  11.   protected void dispatchDraw(Canvas canvas) {
  12.   }

關(guān)于inflate()方法

 
 
 
 
  1. public View inflate() {
  2.       // 1、獲取ViewStub的parent view,也是目標(biāo)布局根元素的parent view
  3.       final ViewParent viewParent = getParent();
  4.       if (viewParent != null && viewParent instanceof ViewGroup) {
  5.           if (mLayoutResource != 0) {
  6.               final ViewGroup parent = (ViewGroup) viewParent;
  7.               /// 2、加載目標(biāo)布局  牛逼的方法
  8.               final View view = inflateViewNoAdd(parent);
  9.               // 3、將ViewStub自身從parent中移除
  10.               replaceSelfWithView(view, parent);
  11.               mInflatedViewRef = new WeakReference<>(view);
  12.               if (mInflateListener != null) {
  13.                   mInflateListener.onInflate(this, view);
  14.               }
  15.               return view;
  16.           } else {
  17.               // TODO: 2018/5/23 必須設(shè)置布局的文件
  18.               throw new IllegalArgumentException("ViewStub must have a valid layoutResource");
  19.           }
  20.       } else {
  21.           // TODO: 2018/5/23 iewParent instanceof ViewGroup 不屬于的話,就好比在一個(gè)TextView創(chuàng)建一個(gè)ViewStub直接爆炸
  22.           throw new IllegalStateException("ViewStub must have a non-null ViewGroup viewParent");
  23.       }
  24.   }
  • 第一點(diǎn),ViewStup也只能在ViewGroup中使用,不能在View中去使用,要不然會(huì)拋出異常IllegalStateException("ViewStub must have a non-null ViewGroup viewParent");
  • 第二點(diǎn),也必須設(shè)置layout屬性,要不然也會(huì)拋出異常throw new IllegalArgumentException("ViewStub must have a valid layoutResource");;

關(guān)于方法inflateViewNoAdd(parent);

 
 
 
 
  1. private View inflateViewNoAdd(ViewGroup parent) {
  2.       final LayoutInflater factory;
  3.       if (mInflater != null) {
  4.           factory = mInflater;
  5.       } else {
  6.           factory = LayoutInflater.from(mContext);
  7.       }
  8.       final View view = factory.inflate(mLayoutResource, parent, false);
  9.       //和 LayoutInflater一個(gè)道理,設(shè)置了,ViewStub 引用進(jìn)來的根布局的id找出來為null  非常有些意思
  10.       if (mInflatedId != NO_ID) {
  11.           view.setId(mInflatedId);
  12.       }
  13.       return view;
  14.   }
  • 第一點(diǎn),底層調(diào)用的還是LayoutInflater.from(mContext).inflate(mLayoutResource, parent, false);
  • 第二點(diǎn),又看到這個(gè)方法,似曾相識(shí),對(duì),這也是為什么ViewStub找不到根布局id的原因,因?yàn)閙InflatedId != NO_ID,就會(huì)view.setId(mInflatedId);
 
 
 
 
  1.  if (mInflatedId != NO_ID) {
  2.         view.setId(mInflatedId);
  3. }

將ViewStub自身從parent中移除replaceSelfWithView(view, parent);,具體的原因,這里不做分析,因?yàn)橛悬c(diǎn)小復(fù)雜,這里就大概明白就行,對(duì)于理解這個(gè)ViewStub不困難,哈哈

 
 
 
 
  1. private void replaceSelfWithView(View view, ViewGroup parent) {
  2.      final int index = parent.indexOfChild(this);
  3.      // 3、將ViewStub自身從parent中移除
  4.      parent.removeViewInLayout(this);
  5.      final ViewGroup.LayoutParams layoutParams = getLayoutParams();
  6.      if (layoutParams != null) {
  7.          // 4、將目標(biāo)布局的根元素添加到parent中,有參數(shù)
  8.          parent.addView(view, index, layoutParams);
  9.      } else {
  10.         // 5、將目標(biāo)布局的根元素添加到parent中
  11.          parent.addView(view, index);
  12.      }
  13.  }

這里使用到了弱引用,只有弱引用指向的對(duì)象的生命周期更短,當(dāng)垃圾回收器掃描到只有具有弱引用的對(duì)象的時(shí)候,不論當(dāng)前空間是否不足,都會(huì)對(duì)弱引用對(duì)象進(jìn)行回收,當(dāng)然弱引用也可以和一個(gè)隊(duì)列配合著使用,為了更好地釋放內(nèi)存,安卓代碼、圖片、布局、網(wǎng)絡(luò)和電量優(yōu)化這篇文章有很好的解釋,而且這個(gè)mInflatedViewRef只在這里初始化,如果說沒有調(diào)用inflate的方法的話,這個(gè)對(duì)象一定為null;

 
 
 
 
  1. //更好的釋放內(nèi)存
  2.  private WeakReference mInflatedViewRef;
  3.  mInflatedViewRef = new WeakReference<>(view);
  4.                if (mInflateListener != null) {
  5.               mInflateListener.onInflate(this, view)
  6.  }

為啥setVisibility(View.VISIBLE)等同于inflate,原因是ViewStub進(jìn)行了重寫??梢钥闯龃a的邏輯,只要沒有調(diào)用過,inflate()方法,setVisibility(VISIBLE )和setVisibility(INVISIBLE)這個(gè)兩個(gè)參數(shù)走的方法一樣,只不過,一個(gè)看不到,實(shí)際上的位置已經(jīng)確定了(INVISIBLE)。但是如果調(diào)用多次的話setVisibility()記得也得判斷下null!=mViewStub.getParent()

 
 
 
 
  1. @Override
  2.     @android.view.RemotableViewMethod(asyncImpl = "setVisibilityAsync")
  3.     public void setVisibility(int visibility) {
  4.         // TODO: 2018/5/23  弱引用的使用
  5.         //如果已經(jīng)加載過則只設(shè)置Visibility屬性
  6.         if (mInflatedViewRef != null) {
  7.             View view = mInflatedViewRef.get();
  8.             if (view != null) {
  9.                 view.setVisibility(visibility);
  10.             } else {
  11.                 throw new IllegalStateException("setVisibility called on un-referenced view");
  12.             }
  13.         } else {
  14.             // 如果未加載,這加載目標(biāo)布局
  15.             super.setVisibility(visibility);
  16.             if (visibility == VISIBLE || visibility == INVISIBLE) {
  17.                 inflate();// 調(diào)用inflate來加載目標(biāo)布局
  18.             }
  19.         }
  20.     }

貼出全部的代碼,有空的話,可以研究下。

 
 
 
 
  1. @RemoteView
  2. public final class ViewStub extends View {
  3.     private int mInflatedId;
  4.     private int mLayoutResource;
  5.     // TODO: 2018/5/23 弱引用:弱引用是比軟引用更弱的一種的引用的類型,
  6.     // 只有弱引用指向的對(duì)象的生命周期更短,當(dāng)垃圾回收器掃描到只有具有弱引用的對(duì)象的時(shí)候,
  7.     // 不敢當(dāng)前空間是否不足,都會(huì)對(duì)弱引用對(duì)象進(jìn)行回收,當(dāng)然弱引用也可以和一個(gè)隊(duì)列配合著使用
  8.     //更好的釋放內(nèi)存
  9.     private WeakReference mInflatedViewRef;
  10.     private LayoutInflater mInflater;
  11.     private OnInflateListener mInflateListener;
  12.     public ViewStub(Context context) {
  13.         this(context, 0);
  14.     }
  15.     /**
  16.      * Creates a new ViewStub with the specified layout resource.
  17.      *
  18.      * @param context The application's environment.
  19.      * @param layoutResource The reference to a layout resource that will be inflated.
  20.      */
  21.     public ViewStub(Context context, @LayoutRes int layoutResource) {
  22.         this(context, null);
  23.         mLayoutResource = layoutResource;
  24.     }
  25.     public ViewStub(Context context, AttributeSet attrs) {
  26.         this(context, attrs, 0);
  27.     }
  28.     public ViewStub(Context context, AttributeSet attrs, int defStyleAttr) {
  29.         this(context, attrs, defStyleAttr, 0);
  30.     }
  31.     public ViewStub(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
  32.         super(context);
  33.         final TypedArray a = context.obtainStyledAttributes(attrs,
  34.                 R.styleable.ViewStub, defStyleAttr, defStyleRes);
  35.         // TODO: 2018/5/23  ViewStub 中設(shè)置的標(biāo)簽id 如果設(shè)置了 這里就一定有值 mInflatedId!=NO_Id
  36.         mInflatedId = a.getResourceId(R.styleable.ViewStub_inflatedId, NO_ID);
  37.         mLayoutResource = a.getResourceId(R.styleable.ViewStub_layout, 0);
  38.         mID = a.getResourceId(R.styleable.ViewStub_id, NO_ID);
  39.         a.recycle();
  40.         //不可見
  41.         setVisibility(GONE);
  42.         // 設(shè)置不繪制
  43.         setWillNotDraw(true);
  44.     }
  45.     /**
  46.      * Returns the id taken by the inflated view. If the inflated id is
  47.      * {@link View#NO_ID}, the inflated view keeps its original id.
  48.      *
  49.      * @return A positive integer used to identify the inflated view or
  50.      *         {@link #NO_ID} if the inflated view should keep its id.
  51.      *
  52.      * @see #setInflatedId(int)
  53.      * @attr ref android.R.styleable#ViewStub_inflatedId
  54.      */
  55.     @IdRes
  56.     public int getInflatedId() {
  57.         return mInflatedId;
  58.     }
  59.     /**
  60.      * Defines the id taken by the inflated view. If the inflated id is
  61.      * {@link View#NO_ID}, the inflated view keeps its original id.
  62.      *
  63.      * @param inflatedId A positive integer used to identify the inflated view or
  64.      *                   {@link #NO_ID} if the inflated view should keep its id.
  65.      *
  66.      * @see #getInflatedId()
  67.      * @attr ref android.R.styleable#ViewStub_inflatedId
  68.      */
  69.     @android.view.RemotableViewMethod(asyncImpl = "setInflatedIdAsync")
  70.     public void setInflatedId(@IdRes int inflatedId) {
  71.         mInflatedId = inflatedId;
  72.     }
  73.     /** @hide **/
  74.     public Runnable setInflatedIdAsync(@IdRes int inflatedId) {
  75.         mInflatedId = inflatedId;
  76.         return null;
  77.     }
  78.     /**
  79.      * Returns the layout resource that will be used by {@link #setVisibility(int)} or
  80.      * {@link #inflate()} to replace this StubbedView
  81.      * in its parent by another view.
  82.      *
  83.      * @return The layout resource identifier used to inflate the new View.
  84.      *
  85.      * @see #setLayoutResource(int)
  86.      * @see #setVisibility(int)
  87.      * @see #inflate()
  88.      * @attr ref android.R.styleable#ViewStub_layout
  89.      */
  90.     @LayoutRes
  91.     public int getLayoutResource() {
  92.         return mLayoutResource;
  93.     }
  94.     /**
  95.      * Specifies the layout resource to inflate when this StubbedView becomes visible or invisible
  96.      * or when {@link #inflate()} is invoked. The View created by inflating the layout resource is
  97.      * used to replace this StubbedView in its parent.
  98.      *
  99.      * @param layoutResource A valid layout resource identifier (different from 0.)
  100.      *
  101.      * @see #getLayoutResource()
  102.      * @see #setVisibility(int)
  103.      * @see #inflate()
  104.      * @attr ref android.R.styleable#ViewStub_layout
  105.      */
  106.     @android.view.RemotableViewMethod(asyncImpl = "setLayoutResourceAsync")
  107.     public void setLayoutResource(@LayoutRes int layoutResource) {
  108.         mLayoutResource = layoutResource;
  109.     }
  110.     /** @hide **/
  111.     public Runnable setLayoutResourceAsync(@LayoutRes int layoutResource) {
  112.         mLayoutResource = layoutResource;
  113.         return null;
  114.     }
  115.     /**
  116.      * Set {@link LayoutInflater} to use in {@link #inflate()}, or {@code null}
  117.      * to use the default.
  118.      */
  119.     public void setLayoutInflater(LayoutInflater inflater) {
  120.         mInflater = inflater;
  121.     }
  122.     /**
  123.      * Get current {@link LayoutInflater} used in {@link #inflate()}.
  124.      */
  125.     public LayoutInflater getLayoutInflater() {
  126.         return mInflater;
  127.     }
  128.     @Override
  129.     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  130.         // 寬高都為0   onMeasure的時(shí)候 寬高都為0
  131.         setMeasuredDimension(0, 0);
  132.     }
  133.     //todo 為啥這個(gè)控件 是個(gè)大小為0的控件 ,那是因?yàn)樗麐尩倪@里更不就沒有畫
  134.     @Override
  135.     public void draw(Canvas canvas) {
  136.     }
  137.     @Override
  138.     protected void dispatchDraw(Canvas canvas) {
  139.     }
  140.     /**
  141.      * When visibility is set to {@link #VISIBLE} or {@link #INVISIBLE},
  142.      * {@link #inflate()} is invoked and this StubbedView is replaced in its parent
  143.      * by the inflated layout resource. After that calls to this function are passed
  144.      * through to the inflated view.
  145.      *
  146.      * @param visibility One of {@link #VISIBLE}, {@link #INVISIBLE}, or {@link #GONE}.
  147.      *
  148.      * @see #inflate()
  149.      */
  150.     @Override
  151.     @android.view.RemotableViewMethod(asyncImpl = "setVisibilityAsync")
  152.     public void setVisibility(int visibility) {
  153.         // TODO: 2018/5/23  弱引用的使用
  154.         //如果已經(jīng)加載過則只設(shè)置Visibility屬性
  155.         if (mInflatedViewRef != null) {
  156.             View view = mInflatedViewRef.get();
  157.             if (view != null) {
  158.                 view.setVisibility(visibility);
  159.             } else {
  160.                 throw new IllegalStateException("setVisibility called on un-referenced view");
  161.             }
  162.         } else {
  163.             // 如果未加載,這加載目標(biāo)布局
  164.             super.setVisibility(visibility);
  165.             if (visibility == VISIBLE || visibility == INVISIBLE) {
  166.                 inflate();// 調(diào)用inflate來加載目標(biāo)布局
  167.             }
  168.         }
  169.     }
  170.     /** @hide **/
  171.     public Runnable setVisibilityAsync(int visibility) {
  172.         if (visibility == VISIBLE || visibility == INVISIBLE) {
  173.             ViewGroup parent = (ViewGroup) getParent();
  174.             return new ViewReplaceRunnable(inflateViewNoAdd(parent));
  175.         } else {
  176.             return null;
  177.         }
  178.     }
  179.     private View inflateViewNoAdd(ViewGroup parent) {
  180.         final LayoutInflater factory;
  181.         if (mInflater != null) {
  182.             factory = mInflater;
  183.         } else {
  184.             factory = LayoutInflater.from(mContext);
  185.         }
  186.         final View view = factory.inflate(mLayoutResource, parent, false);
  187.         //和 LayoutInflater一個(gè)道理,設(shè)置了,ViewStub 引用進(jìn)來的根布局的id找出來為null  非常有些意思
  188.         if (mInflatedId != NO_ID) {
  189.             view.setId(mInflatedId);
  190.         }
  191.         return view;
  192.     }
  193.     // TODO: 2018/5/23 關(guān)注他
  194.     private void replaceSelfWithView(View view, ViewGroup parent) {
  195.         final int index = parent.indexOfChild(this);
  196.         // 3、將ViewStub自身從parent中移除
  197.         parent.removeViewInLayout(this);
  198.         final ViewGroup.LayoutParams layoutParams = getLayoutParams();
  199.         if (layoutParams != null) {
  200.             // 4、將目標(biāo)布局的根元素添加到parent中,有參數(shù)
  201.             parent.addView(view, index, layoutParams);
  202.         } else {
  203.            // 5、將目標(biāo)布局的根元素添加到parent中
  204.             parent.addView(view, index);
  205.         }
  206.     }
  207.     /**
  208.      * Inflates the layout resource identified by {@link #getLayoutResource()}
  209.      * and replaces this StubbedView in its parent by the inflated layout resource.
  210.      *
  211.      * @return The inflated layout resource.
  212.      *
  213.      */
  214.     public View inflate() {
  215.         // 1、獲取ViewStub的parent view,也是目標(biāo)布局根元素的parent view
  216.         final ViewParent viewParent = getParent();
  217.         if (viewParent != null && viewParent instanceof ViewGroup) {
  218.             if (mLayoutResource != 0) {
  219.                 final ViewGroup parent = (ViewGroup) viewParent;
  220.                 /// 2、加載目標(biāo)布局  牛逼的方法
  221.                 final View view = inflateViewNoAdd(parent);
  222.                 // 3、將ViewStub自身從parent中移除
  223.                 replaceSelfWithView(view, parent);
  224.                 mInflatedViewRef = new WeakReference<>(view);
  225.                 if (mInflateListener != null) {
  226.                     mInflateListener.onInflate(this, view);
  227.                 }
  228.                 return view;
  229.             } else {
  230.                 // TODO: 2018/5/23 必須設(shè)置布局的文件
  231.                 throw new IllegalArgumentException("ViewStub must have a valid layoutResource");
  232.             }
  233.         } else {
  234.             // TODO: 2018/5/23 iewParent instanceof ViewGroup 不屬于的話,就好比在一個(gè)TextView創(chuàng)建一個(gè)ViewStub直接爆炸
  235.             throw new IllegalStateException("ViewStub must have a non-null ViewGroup viewParent");
  236.         }
  237.     }
  238.     /**
  239.      * Specifies the inflate listener to be notified after this ViewStub successfully
  240.      * inflated its layout resource.
  241.      *
  242.      * @param inflateListener The OnInflateListener to notify of successful inflation.
  243.      *
  244.      * @see ViewStub.OnInflateListener
  245.      */
  246.     public void setOnInflateListener(OnInflateListener inflateListener) {
  247.         mInflateListener = inflateListener;
  248.     }
  249.     /**
  250.      * Listener used to receive a notification after a ViewStub has successfully
  251.      * inflated its layout resource.
  252.      *
  253.      * @see ViewStub#setOnInflateListener(ViewStub.OnInflateListener)
  254.      */
  255.     public static interface OnInflateListener {
  256.         /**
  257.          * Invoked after a ViewStub successfully inflated its layout resource.  網(wǎng)站名稱:基于Android8.0分析源碼的ViewStub源碼解析
    分享網(wǎng)址:http://www.5511xx.com/article/cddoehc.html