Java Code Examples for android.view.LayoutInflater.inflate()

The following are Jave code examples for showing how to use inflate() of the android.view.LayoutInflater class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: espresso-sample-for-droidkaigi2017   File: QiitaFavsFragment.java   View Source Code Vote up 7 votes
@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;
}
 
Example 2
Project: emerald   File: ThemerActivity.java   View Source Code Vote up 6 votes
@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;
}
 
Example 3
Project: GitHub   File: FirstBackstackMviLifecycleFragment.java   View Source Code Vote up 6 votes
@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;
}
 
Example 4
Project: popomusic   File: JinjiFragment.java   View Source Code Vote up 6 votes
@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;
}
 
Example 5
Project: GitHub   File: BaseTabFragment.java   View Source Code Vote up 5 votes
/**
 * @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;
}
 
Example 6
Project: LaunchEnr   File: LauncherAppWidgetHost.java   View Source Code Vote up 5 votes
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;
        }
    }
}
 
Example 7
Project: Forge   File: OverlayService.java   View Source Code Vote up 5 votes
@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();
    }
}
 
Example 8
Project: Samantha   File: InfoBaseFragment.java   View Source Code Vote up 5 votes
@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;
}
 
Example 9
Project: AndroidBackendlessChat   File: ChatSDKAbstractChatActivity.java   View Source Code Vote up 5 votes
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;
}
 
Example 10
Project: KingTV   File: BaseFragment.java   View Source Code Vote up 5 votes
@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;
}
 
Example 11
Project: Supreme   File: HomeFragment.java   View Source Code Vote up 5 votes
@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;
}
 
Example 12
Project: ECardFlow   File: PagerFragment.java   View Source Code Vote up 5 votes
@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;
}
 
Example 13
Project: browser   File: BrowserActivity.java   View Source Code Vote up 5 votes
@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;
}
 
Example 14
Project: PinchToZoom   File: MainActivity.java   View Source Code Vote up 5 votes
@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;
}
 
Example 15
Project: treasure   File: ArticleFragment.java   View Source Code Vote up 5 votes
@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;
}
 
Example 16
Project: AndroidModulePattern   File: NewsFragment.java   View Source Code Vote up 4 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_news, container, false);
}
 
Example 17
Project: Android-Client   File: SettingsFragment.java   View Source Code Vote up 4 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.settings_fragment, container, false);
}
 
Example 18
Project: Android_watch_magpie   File: FragmentHome.java   View Source Code Vote up 4 votes
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        LayoutInflater lf = getActivity().getLayoutInflater();
        // Inflate the layout for this fragment
        view=lf.inflate(R.layout.fragment_home, container, false);

        initViews();
        HashMap<String, Measure>measureList=MeasuresRepository.getInstance().getLastMeasure();
        displayLastMeasure(measureList);
        setBarLevelArea();

        //set the max variation


//        CustomRules
        //now we get the number based on the rules. The value are in % (ex 98 or 101)





        return view;
    }
 
Example 19
Project: Alligator   File: TabFragment.java   View Source Code Vote up 4 votes
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
	return inflater.inflate(R.layout.fragment_tab, container, false);
}
 
Example 20
Project: LnkShortener   File: LinkHistoryFragment.java   View Source Code Vote up 4 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_link_history, container, false);
}