本文整理汇总了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);
}