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

The following are Jave code examples for showing how to use getContext() 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.
Example 1
Project: navigation-widgets   File: NavigationLayoutFactory.java   Source Code and License Vote up 7 votes
@Override
public View produceLayout(LayoutInflater inflater, @Nullable ViewGroup container) {
    LinearLayout parent = new LinearLayout(inflater.getContext());
    parent.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    parent.setOrientation(VERTICAL);

    View child = origin.produceLayout(inflater, parent);
    LinearLayout.LayoutParams childParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    if (includeBottomBar) {
        childParams.weight = 1;
    }

    if (includeToolbar) {
        inflater.inflate(R.layout.toolbar, parent);
    }
    parent.addView(child, childParams);
    if (includeBottomBar) {
        AHBottomNavigation bottomNavigation = new AHBottomNavigation(parent.getContext());
        bottomNavigation.setId(R.id.bottomNavigation);
        parent.addView(
                bottomNavigation,
                new LinearLayout.LayoutParams(MATCH_PARENT, (int) dp(parent.getContext(), 56)));
    }

    return parent;
}
 
Example 2
Project: fuckView   File: FaqWizard.java   Source Code and License Vote up 6 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    context = inflater.getContext();
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.faq_wizard_layout, null);
    choose = (ListView) layout.findViewById(R.id.faq_wizard_list);
    title = (TextView) layout.findViewById(R.id.faq_wizard_title);
    choose.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (findStepById(currentId).to != null)
                jumpTo(findStepById(currentId).to[i]);
        }
    });
    data = getData();
    jumpTo(FIRST_ID);
    return layout;
}
 
Example 3
Project: FireFiles   File: DirectoryFragment.java   Source Code and License Vote up 6 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
Example 4
Project: simple-share-android   File: DirectoryFragment.java   Source Code and License Vote up 6 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
Example 5
Project: cda-app   File: MainFrameFragment.java   Source Code and License Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    readBundle(getArguments());
    //:::::::::::::::::::::::::::: SUBMENUS ::::::::::::::::::::::::::::
    String [] subMenu = null;
    switch (choiceType){
        case ""+R.string.project:
            subMenu = getResources().getStringArray(R.array.subMenuProject);		            //PROJECT
            break;

        case ""+R.string.member:
            subMenu = getResources().getStringArray(R.array.subMenuMember);		                //INFORMATION
            break;

        case ""+R.string.cda:
            subMenu = getResources().getStringArray(R.array.subMenuCDA);		                //CDA
            break;

    }

    //---------- ListView by Sub-Menu -------------------------
    frameAdapterPager = new MainFrameFragmentPagerAdapter(getFragmentManager(), inflater.getContext(), subMenu, choiceType);
    frameAdapterPager.notifyDataSetChanged();

    // Set up the ViewPager with the sections adapter.
    mViewPager = rootView.findViewById(R.id.pager);
    mViewPager.setAdapter(frameAdapterPager);

    //----------------- Sub-Menu Music ------------------------------
    mIndicator = (TitlePageIndicator)getActivity().findViewById(R.id.indicator);
    mIndicator.setViewPager(mViewPager, R.color.white);

    return rootView;
}
 
Example 6
Project: cda-app   File: FrameMain.java   Source Code and License Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.fragment_main, container, false);
    readBundle(getArguments());
    //:::::::::::::::::::::::::::: SUBMENUS ::::::::::::::::::::::::::::
    String [] subMenu = null;
    switch (choiceType){
        case ""+R.string.project:
            subMenu = getResources().getStringArray(R.array.subMenuProject);		            //PROJECT
            break;

        case ""+R.string.member:
            subMenu = getResources().getStringArray(R.array.subMenuMember);		        //INFORMATION
            break;

        case ""+R.string.cda:
            subMenu = getResources().getStringArray(R.array.subMenuCDA);		                //CDA
            break;

    }

    //---------- ListView by Sub-Menu -------------------------
    frameAdapterPager = new FrameAdapterPager(getFragmentManager(), inflater.getContext(), subMenu);
    frameAdapterPager.notifyDataSetChanged();

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager)rootView.findViewById(R.id.pager);
    mViewPager.setAdapter(frameAdapterPager);

    //----------------- Sub-Menu Music ------------------------------
    mIndicator = (TitlePageIndicator)getActivity().findViewById(R.id.indicator);
    mIndicator.setViewPager(mViewPager, R.color.white);


    return rootView;
}
 
Example 7
Project: Stage   File: FragmentScene.java   Source Code and License Vote up 5 votes
@NonNull
@Override
protected final View onCreateView(@NonNull LayoutInflater inflater,
    @NonNull ViewGroup container) {
  View view = new FrameLayout(inflater.getContext());
  view.setId(getContainerId());
  return view;
}
 
Example 8
Project: easyfilemanager   File: DirectoryFragment.java   Source Code and License Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	final Context context = inflater.getContext();
       final Resources res = context.getResources();
	final View view = inflater.inflate(R.layout.fragment_directory, container, false);

       mProgressBar = (MaterialProgressBar) view.findViewById(R.id.progressBar);

	mEmptyView = (CompatTextView)view.findViewById(android.R.id.empty);

	mListView = (ListView) view.findViewById(R.id.list);
	mListView.setOnItemClickListener(mItemListener);
	mListView.setMultiChoiceModeListener(mMultiListener);
	mListView.setRecyclerListener(mRecycleListener);

       // Indent our list divider to align with text
       final Drawable divider = mListView.getDivider();
       final boolean insetLeft = res.getBoolean(R.bool.list_divider_inset_left);
       final int insetSize = res.getDimensionPixelSize(R.dimen.list_divider_inset);
       if (insetLeft) {
           mListView.setDivider(new InsetDrawable(divider, insetSize, 0, 0, 0));
       } else {
           mListView.setDivider(new InsetDrawable(divider, 0, 0, insetSize, 0));
       }

	mGridView = (GridView) view.findViewById(R.id.grid);
	mGridView.setOnItemClickListener(mItemListener);
	mGridView.setMultiChoiceModeListener(mMultiListener);
	mGridView.setRecyclerListener(mRecycleListener);

	return view;
}
 
Example 9
Project: easyfilemanager   File: RecentsCreateFragment.java   Source Code and License Vote up 5 votes
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();

    final View view = inflater.inflate(R.layout.fragment_directory, container, false);

    mEmptyView = view.findViewById(android.R.id.empty);

    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    return view;
}
 
Example 10
Project: silly-android   File: ParsableFragment.java   Source Code and License Vote up 5 votes
/**
 * {@inheritDoc}
 */
@Nullable
@Override
@CallSuper
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    final View superView = super.onCreateView(inflater, container, savedInstanceState);

    // it seems impossible to go in here, but it's Android, so.. check if not parsed by now
    final Context context = getContext() == null ? inflater.getContext() : getContext();
    if (!mIsParsed && context != null) {
        AnnotationParser.parseType(context, this);
        mIsParsed = true;
    }

    // inflate and parse views now
    if (getLayoutId() > 0 && context != null) {
        final View contentView = inflater.inflate(getLayoutId(), container, false);
        // using 'this' instead of a new wrapper won't work because the wrapper uses #getView(), which will at this point return null
        if (mFoundViews != null) {
            mFoundViews.clear();
        }
        mFoundViews = AnnotationParser.parseFields(context, this, new LayoutWrapper() {
            @Override
            public <ViewType extends View> ViewType findView(@IdRes final int viewId) {
                return SillyAndroid.findViewById(contentView, viewId);
            }
        });
    }

    return superView; // nothing worked, go super.
}
 
Example 11
Project: silly-android   File: EasyFragment.java   Source Code and License Vote up 5 votes
@Nullable
@Override
@CallSuper
public View onCreateView(@NonNull final LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable final Bundle savedInstanceState) {
    final Context fragmentContext = getContext();
    final Context paramContext = container != null ? container.getContext() : inflater.getContext();
    if (fragmentContext instanceof Activity) {
        mKeyboardListener = SillyAndroid.listenToKeyboard(this, (Activity) fragmentContext);
    } else if (paramContext instanceof Activity) {
        mKeyboardListener = SillyAndroid.listenToKeyboard(this, (Activity) paramContext);
    }
    return super.onCreateView(inflater, container, savedInstanceState);
}
 
Example 12
Project: FireFiles   File: RecentsCreateFragment.java   Source Code and License Vote up 5 votes
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();

    final View view = inflater.inflate(R.layout.fragment_directory, container, false);

    mEmptyView = view.findViewById(android.R.id.empty);

    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    return view;
}
 
Example 13
Project: boohee_v5.6   File: GoodsHomeFragment.java   Source Code and License Vote up 5 votes
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
        savedInstanceState) {
    HomeView view = new HomeView(inflater.getContext());
    view.setHeaderView(inflater.inflate(R.layout.h2, container, false));
    this.webview = view.getWebView();
    return view;
}
 
Example 14
Project: simple-share-android   File: RecentsCreateFragment.java   Source Code and License Vote up 5 votes
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();

    final View view = inflater.inflate(R.layout.fragment_directory, container, false);

    mEmptyView = view.findViewById(android.R.id.empty);

    mListView = (ListView) view.findViewById(R.id.list);
    mListView.setOnItemClickListener(mItemListener);
    return view;
}
 
Example 15
Project: SmartRefreshLayout   File: ViewPagerUsingFragment.java   Source Code and License Vote up 4 votes
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return new RecyclerView(inflater.getContext());
}
 
Example 16
Project: Stage   File: SceneLifecycleTest.java   Source Code and License Vote up 4 votes
@NonNull
@Override
protected View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) {
  return new View(inflater.getContext());
}
 
Example 17
Project: backstack   File: ViewGroup4.java   Source Code and License Vote up 4 votes
@Override
public ViewGroup create(LayoutInflater layoutInflater, ViewGroup container) {
    ViewGroup4 viewGroup4 = new ViewGroup4(layoutInflater.getContext(), num);
    container.addView(viewGroup4);
    return viewGroup4;
}
 
Example 18
Project: android-apkbox   File: ApkLayoutInflater.java   Source Code and License Vote up 4 votes
public ApkLayoutInflater(LayoutInflater target) {
    super(target.getContext());
    this.target = target;
}
 
Example 19
Project: PicShow-zhaipin   File: LazyFragment.java   Source Code and License Vote up 4 votes
@Deprecated
protected final void onCreateView(Bundle savedInstanceState) {
    super.onCreateView(savedInstanceState);
    this.savedInstanceState = savedInstanceState;
    Bundle bundle = getArguments();
    if (bundle != null) {
        isLazyLoad = bundle.getBoolean(INTENT_BOOLEAN_LAZYLOAD, isLazyLoad);
    }
    //为什么不直接getUserVisibleHint();而是通过自己存isVisibleToUserState变量判断
    //因为v4的25的版本 已经调用 setUserVisibleHint(true),结果到这里getUserVisibleHint是false
    // (ps:看了FragmentManager源码Fragment被重新创建有直接赋值isVisibleToUser不知道是不是那里和之前v4有改动的地方)
    //所以我默认VISIBLE_STATE_NOTSET,之前没有调用setUserVisibleHint方法,就用系统的getUserVisibleHint,否则就用setUserVisibleHint后保存的值
    //总之就是调用了setUserVisibleHint 就使用setUserVisibleHint的值
    boolean isVisibleToUser;
    if (isVisibleToUserState == VISIBLE_STATE_NOTSET) {
        isVisibleToUser = getUserVisibleHint();
    } else {
        isVisibleToUser = isVisibleToUserState == VISIBLE_STATE_VISIABLE;
    }
    if (isLazyLoad) {
        if (isVisibleToUser && !isInit) {
            isInit = true;
            onCreateViewLazy(savedInstanceState);
        } else {
            LayoutInflater layoutInflater = inflater;
            if (layoutInflater == null) {
                layoutInflater = LayoutInflater.from(getApplicationContext());
            }
            layout = new FrameLayout(layoutInflater.getContext());
            View view = getPreviewLayout(layoutInflater, layout);
            if (view != null) {
                layout.addView(view);
            }
            layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            super.setContentView(layout);
        }
    } else {
        isInit = true;
        onCreateViewLazy(savedInstanceState);
    }
}
 
Example 20
Project: Tusky   File: NotificationsFragment.java   Source Code and License Vote up 4 votes
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_timeline, container, false);

    @NonNull Context context = inflater.getContext(); // from inflater to silence warning
    // Setup the SwipeRefreshLayout.
    swipeRefreshLayout = rootView.findViewById(R.id.swipe_refresh_layout);
    swipeRefreshLayout.setOnRefreshListener(this);
    // Setup the RecyclerView.
    recyclerView = rootView.findViewById(R.id.recycler_view);
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    DividerItemDecoration divider = new DividerItemDecoration(
            context, layoutManager.getOrientation());
    Drawable drawable = ThemeUtils.getDrawable(context, R.attr.status_divider_drawable,
            R.drawable.status_divider_dark);
    divider.setDrawable(drawable);
    recyclerView.addItemDecoration(divider);

    adapter = new NotificationsAdapter(this, this);
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(
            getActivity());
    alwaysShowSensitiveMedia = preferences.getBoolean("alwaysShowSensitiveMedia", false);
    boolean mediaPreviewEnabled = preferences.getBoolean("mediaPreviewEnabled", true);
    adapter.setMediaPreviewEnabled(mediaPreviewEnabled);
    recyclerView.setAdapter(adapter);

    timelineReceiver = new TimelineReceiver(this);
    LocalBroadcastManager.getInstance(context.getApplicationContext())
            .registerReceiver(timelineReceiver, TimelineReceiver.getFilter(null));

    notifications.clear();
    topLoading = false;
    topFetches = 0;
    bottomLoading = false;
    bottomFetches = 0;
    bottomId = null;
    topId = null;

    return rootView;
}