本文整理汇总了Java中android.view.LayoutInflater.inflate方法的典型用法代码示例。如果您正苦于以下问题:Java LayoutInflater.inflate方法的具体用法?Java LayoutInflater.inflate怎么用?Java LayoutInflater.inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.LayoutInflater
的用法示例。
在下文中一共展示了LayoutInflater.inflate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_qiita_items, container, false);
RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
QiitaItemsAdapter adapter = new QiitaItemsAdapter();
recyclerView.setAdapter(adapter);
Subscription qiitaFavsUpdateSubscription = qiitaItemsSubject
.subscribeOn(Schedulers.io())
.flatMap(itemList -> Observable.from(itemList).filter(item -> item.isFaved).toList())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(adapter::setQiitaItemList);
subscriptions.addAll(qiitaFavsUpdateSubscription);
return rootView;
}
示例2: getView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v;
final int i = position;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.iconbutton, parent, false);
} else {
v = convertView;
}
v.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Toast.makeText(ThemerActivity.this, " "+i, Toast.LENGTH_LONG).show();
}
});
return v;
}
示例3: onCreateView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Nullable @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_mvi, container, false);
TextView tv = (TextView) view.findViewById(R.id.text);
tv.setText(getClass().getSimpleName());
return view;
}
示例4: onCreateView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_video_pager, container, false);
listView = (RecyclerView) view.findViewById(R.id.list);
listView.setHasFixedSize(true);
listView.setLayoutManager(new StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL));
List<ItemList> lists = new ArrayList<ItemList>();
videoadapter = new VideoAdapter(lists);
listView.setAdapter(videoadapter);
mPresent = new VideoPresenter((VideoData.View) this);
srfLayout = (SwipeRefreshLayout) view.findViewById(R.id.srf_layout);
srfLayout.setOnRefreshListener(this);
srfLayout.post(() -> onRefresh());
return view;
}
示例5: onCreateView
import android.view.LayoutInflater; //导入方法依赖的package包/类
/**
* @param inflater
* @param container
* @param savedInstanceState
* @param layoutResID fragment全局视图view的布局资源id。 <= 0 ? R.layout.base_tab_activity : layoutResID
* @return
* @must 1.不要在子类重复这个类中onCreateView中的代码;
* 2.在子类onCreateView中super.onCreateView(inflater, container, savedInstanceState, layoutResID);
* initView();initData();initEvent(); return view;
*/
public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState
, int layoutResID) {
//类相关初始化,必须使用<<<<<<<<<<<<<<<<<<
super.onCreateView(inflater, container, savedInstanceState);
//调用这个类的setContentView而崩溃 super.setContentView(layoutResID <= 0 ? R.layout.base_tab_activity : layoutResID);
view = inflater.inflate(layoutResID <= 0 ? R.layout.base_tab_activity : layoutResID, container, false);
//类相关初始化,必须使用>>>>>>>>>>>>>>>>
fragmentManager = context.getSupportFragmentManager();
return view;
}
示例6: createView
import android.view.LayoutInflater; //导入方法依赖的package包/类
public AppWidgetHostView createView(Context context, int appWidgetId,
LauncherAppWidgetProviderInfo appWidget) {
if (appWidget.isCustomWidget) {
LauncherAppWidgetHostView lahv = new LauncherAppWidgetHostView(context);
LayoutInflater inflater = (LayoutInflater)
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(appWidget.initialLayout, lahv);
lahv.setAppWidget(0, appWidget);
lahv.updateLastInflationOrientation();
return lahv;
} else {
try {
return super.createView(context, appWidgetId, appWidget);
} catch (Exception e) {
if (!Utilities.isBinderSizeError(e)) {
throw new RuntimeException(e);
}
// If the exception was thrown while fetching the remote views, let the view stay.
// This will ensure that if the widget posts a valid update later, the view
// will update.
LauncherAppWidgetHostView view = mViews.get(appWidgetId);
if (view == null) {
view = onCreateView(mLauncher, appWidgetId, appWidget);
}
view.setAppWidget(appWidgetId, appWidget);
view.switchToErrorView();
return view;
}
}
}
示例7: onCreate
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
appContext = getApplicationContext();
boolean canDraw = true;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// If the version requires a permission to draw over apps,
canDraw = Settings.canDrawOverlays(appContext);
}
if (canDraw) {
// If Forge is allowed to draw over other apps
// Close the notifications status bar
Intent closeStatusBarIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
appContext.sendBroadcast(closeStatusBarIntent);
// Load the current account
account = CurrentManager.loadCurrentAccount(appContext);
// Get the window manager
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
// Get the layout inflater
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
// Create the view from the forge overlay layout
view = layoutInflater.inflate(R.layout.forge_overlay, null);
setUpEditTexts();
setUpButtons();
// Set up window manager parameters
WindowManager.LayoutParams params;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// If the device is version Oreo or greater
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
PixelFormat.TRANSPARENT);
} else {
// If the device is pre-Oreo
params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
PixelFormat.TRANSPARENT);
}
params.gravity = Gravity.CENTER;
// Display the view over the app
windowManager.addView(view, params);
} else {
this.stopSelf();
}
}
示例8: onCreateView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
示例9: inflateActionBarView
import android.view.LayoutInflater; //导入方法依赖的package包/类
protected View inflateActionBarView(int resId){
// Inflate the custom view
if (actionBarView == null || actionBarView.getId() != resId) {
LayoutInflater inflater = LayoutInflater.from(this);
actionBarView = inflater.inflate(resId, null);
}
return actionBarView;
}
示例10: onCreateView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
context = getActivity();
rootView = inflater.inflate(getRootViewId(),container,false);
mUnbinder = ButterKnife.bind(this,rootView);
LogUtils.d("onCreateView");
initUI();
return rootView;
}
示例11: onCreateView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_home, container, false);
initView(view);
initListener();
initData();
return view;
}
示例12: onCreateView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View mView = inflater.inflate(R.layout.fragment_pager, null);
ivBack = (ImageView) mView.findViewById(R.id.iv_back);
rvContent = (RecyclerView) mView.findViewById(R.id.rv_content);
tvBtn = (TextView) mView.findViewById(R.id.tv_btn);
return mView;
}
示例13: getView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
BookmarkViewHolder holder;
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new BookmarkViewHolder();
holder.txtTitle = (TextView) row.findViewById(R.id.textBookmark);
holder.favicon = (ImageView) row.findViewById(R.id.faviconBookmark);
row.setTag(holder);
} else {
holder = (BookmarkViewHolder) row.getTag();
}
HistoryItem web = data.get(position);
holder.txtTitle.setText(web.getTitle());
holder.favicon.setImageBitmap(mWebpageBitmap);
if (web.getBitmap() == null) {
getImage(holder.favicon, web);
} else {
holder.favicon.setImageBitmap(web.getBitmap());
}
return row;
}
示例14: instantiateItem
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, int position) {
Context context = container.getContext();
LayoutInflater layoutInflater = LayoutInflater.from(context);
View view = layoutInflater.inflate(R.layout.page_image, null);
container.addView(view);
ImageView imageView = (ImageView) view.findViewById(R.id.image);
imageView.setImageDrawable(drawables.get(position));
ImageMatrixTouchHandler imageMatrixTouchHandler = new ImageMatrixTouchHandler(context);
imageView.setOnTouchListener(imageMatrixTouchHandler);
return view;
}
示例15: onCreateView
import android.view.LayoutInflater; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ViewGroup view = (ViewGroup)inflater.inflate(R.layout.article_page, null, false);
mTitleGroupView = (LinearLayout) view.findViewById(R.id.title_group);
initToolbar();
initProgressBar();
setupView(view);
return view;
}