本文整理匯總了Java中android.view.ViewStub.setLayoutResource方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewStub.setLayoutResource方法的具體用法?Java ViewStub.setLayoutResource怎麽用?Java ViewStub.setLayoutResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.ViewStub
的用法示例。
在下文中一共展示了ViewStub.setLayoutResource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findViewFromViewStub
import android.view.ViewStub; //導入方法依賴的package包/類
/**
* @param parentView
* @param viewStubId
* @param inflatedViewId
* @param inflateLayoutResId
* @return
*/
public static View findViewFromViewStub(View parentView, int viewStubId, int inflatedViewId, int inflateLayoutResId) {
if (null == parentView) {
return null;
}
View view = parentView.findViewById(inflatedViewId);
if (null == view) {
ViewStub vs = (ViewStub) parentView.findViewById(viewStubId);
if (null == vs) {
return null;
}
if (vs.getLayoutResource() < 1 && inflateLayoutResId > 0) {
vs.setLayoutResource(inflateLayoutResId);
}
view = vs.inflate();
if (null != view) {
view = view.findViewById(inflatedViewId);
}
}
return view;
}
示例2: initViews
import android.view.ViewStub; //導入方法依賴的package包/類
protected void initViews() {
inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.ultimate_recycler_view_layout, this);
mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list);
mSwipeRefreshLayout = (VerticalSwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
setScrollbars();
mSwipeRefreshLayout.setEnabled(false);
if (mRecyclerView != null) {
mRecyclerView.setClipToPadding(mClipToPadding);
if (mPadding != -1.1f) {
mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
} else {
mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
}
}
defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
setDefaultScrollListener();
/**
* empty view setup
*/
mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
if (mEmptyId != 0) {
mEmpty.setLayoutResource(mEmptyId);
mEmptyView = mEmpty.inflate();
mEmpty.setVisibility(View.GONE);
}
/**
* floating button setup
*/
mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);
mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);
}
示例3: initViews
import android.view.ViewStub; //導入方法依賴的package包/類
@Override
protected void initViews() {
//super.initViews();
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.custom_recycler_view_layout, this);
mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list);
mSwipeRefreshLayout = null;
if (mRecyclerView != null) {
mRecyclerView.setClipToPadding(mClipToPadding);
if (mPadding != -1.1f) {
mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
} else {
mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
}
}
defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
setDefaultScrollListener();
mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);
mEmpty.setLayoutResource(mEmptyId);
mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);
if (mEmptyId != 0)
mEmptyView = mEmpty.inflate();
mEmpty.setVisibility(View.GONE);
if (mFloatingButtonId != 0) {
mFloatingButtonView = mFloatingButtonViewStub.inflate();
mFloatingButtonView.setVisibility(View.VISIBLE);
}
}
示例4: onCreateView
import android.view.ViewStub; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_page, container, false);
ViewStub sampleStub = (ViewStub) view.findViewById(R.id.sampleStub);
sampleStub.setLayoutResource(sampleLayoutRes);
sampleStub.inflate();
ViewStub practiceStub = (ViewStub) view.findViewById(R.id.practiceStub);
practiceStub.setLayoutResource(practiceLayoutRes);
practiceStub.inflate();
return view;
}
示例5: onCreate
import android.view.ViewStub; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
String html = this.getIntent().getStringExtra("html");
lessonName = this.getIntent().getStringExtra("lesson_name");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setTitle(lessonName);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
ViewStub stub = (ViewStub) findViewById(R.id.layout_stub);
stub.setLayoutResource(R.layout.activity_web_view);
View inflated = stub.inflate();
String mime = "text/html";
String encoding = "utf-8";
final WebView myWebView = (WebView) findViewById(R.id.webViewArcticle);
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.setWebViewClient(webViewClient);
myWebView.loadDataWithBaseURL(null, html, mime, encoding, null);
}
示例6: LinkShareViewHolder
import android.view.ViewStub; //導入方法依賴的package包/類
public LinkShareViewHolder(View itemView) {
super(itemView);
ViewStub viewStub = (ViewStub) itemView.findViewById(R.id.vs_share_fragment_item_main);
viewStub.setLayoutResource(R.layout.share_fragment_item_link_layout);
viewStub.inflate();
// display = (LinearLayout) viewStub.inflate().findViewById(R.id.ll_share_fragment_item_container);
}
示例7: initHeadView
import android.view.ViewStub; //導入方法依賴的package包/類
private void initHeadView() {
int headLayoutId = bindHeadLayoutId();
appBar = (AppBarLayout) findViewById(R.id.app_bar);
ViewStub headViewStub = (ViewStub) findViewById(R.id.base_state_head);
if (headLayoutId != 0 && headViewStub != null) {
appBar.setVisibility(View.VISIBLE);
headViewStub.setLayoutResource(headLayoutId);
headViewStub.inflate();
}
}
示例8: showBody
import android.view.ViewStub; //導入方法依賴的package包/類
protected void showBody() {
ViewStub bodyViewStub = (ViewStub) findViewById(R.id.base_state_body);
//如果這個布局已經被渲染出來,那麽就會為空
if (bodyViewStub != null) {
bodyViewStub.setLayoutResource(bodyLayoutId);
bodyViewStub.inflate();
bodyLayoutId = 0;
}
initViews();
setViewsListener();
}
示例9: initHeadView
import android.view.ViewStub; //導入方法依賴的package包/類
private void initHeadView() {
appBar = (AppBarLayout) findViewById(R.id.app_bar);
int headLayoutId = bindHeadLayoutId();
ViewStub headViewStub = (ViewStub) findViewById(R.id.base_state_head);
if (headLayoutId != 0 && headViewStub != null) {
appBar.setVisibility(View.VISIBLE);
headViewStub.setLayoutResource(headLayoutId);
headViewStub.inflate();
}
}
示例10: initViews
import android.view.ViewStub; //導入方法依賴的package包/類
@Override
protected void initViews() {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.swipeable_ultimate_recycler_view_layout, this);
mRecyclerView = (SwipeListView) view.findViewById(R.id.ultimate_list);
mSwipeRefreshLayout = (VerticalSwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
setScrollbars();
mSwipeRefreshLayout.setEnabled(false);
if (mRecyclerView != null) {
mRecyclerView.setClipToPadding(mClipToPadding);
if (mPadding != -1.1f) {
mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
} else {
mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
}
}
defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
setDefaultScrollListener();
mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);
mEmpty.setLayoutResource(mEmptyId);
mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);
if (mEmptyId != 0)
mEmptyView = mEmpty.inflate();
mEmpty.setVisibility(View.GONE);
if (mFloatingButtonId != 0) {
mFloatingButtonView = mFloatingButtonViewStub.inflate();
mFloatingButtonView.setVisibility(View.VISIBLE);
}
}
示例11: errorView
import android.view.ViewStub; //導入方法依賴的package包/類
/**
* 自定義加載錯誤布局
*/
public Builder errorView(@LayoutRes int errorViewId) {
errorVs = new ViewStub(context);
errorVs.setLayoutResource(errorViewId);
return this;
}
示例12: errorView
import android.view.ViewStub; //導入方法依賴的package包/類
public Builder errorView(@LayoutRes int errorViewId) {
errorVs = new ViewStub(context);
errorVs.setLayoutResource(errorViewId);
return this;
}
示例13: emptyDataView
import android.view.ViewStub; //導入方法依賴的package包/類
public Builder emptyDataView(@LayoutRes int noDataViewId) {
emptyDataVs = new ViewStub(context);
emptyDataVs.setLayoutResource(noDataViewId);
return this;
}
示例14: VideoShareViewHolder
import android.view.ViewStub; //導入方法依賴的package包/類
public VideoShareViewHolder(View itemView) {
super(itemView);
ViewStub viewStub = (ViewStub) itemView.findViewById(R.id.vs_share_fragment_item_main);
viewStub.setLayoutResource(R.layout.share_fragment_item_image_layout);
display = (ListImageView) viewStub.inflate().findViewById(R.id.liv_share_fragment_item_main_image_display);
}
示例15: ImageShareViewHolder
import android.view.ViewStub; //導入方法依賴的package包/類
public ImageShareViewHolder(View itemView) {
super(itemView);
ViewStub viewStub = (ViewStub) itemView.findViewById(R.id.vs_share_fragment_item_main);
viewStub.setLayoutResource(R.layout.share_fragment_item_image_layout);
display = (ListImageView) viewStub.inflate().findViewById(R.id.liv_share_fragment_item_main_image_display);
}