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

The following examples show how to use android.view.LayoutInflater#getContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NavigationLayoutFactory.java    From navigation-widgets with MIT License 6 votes vote down vote up
@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
Source File: DurationQuestionBody.java    From ResearchStack with Apache License 2.0 6 votes vote down vote up
private View initView(LayoutInflater inflater, ViewGroup parent) {
    View v = inflater.inflate(R.layout.rsb_item_edit_duration, parent, false);

    String[] hoursStrs = new String[24];
    for (int i = 0; i < 24; i++) hoursStrs[i] = String.valueOf(i);
    ArrayAdapter<String> hoursChoices = new ArrayAdapter<String>(inflater.getContext(), android.R.layout.simple_spinner_item, hoursStrs);
    hoursChoices.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    hoursSpinner = (Spinner) v.findViewById(R.id.hours);
    hoursSpinner.setAdapter(hoursChoices);

    String[] minutesStrs = new String[60];
    for (int i = 0; i < 60; i++) minutesStrs[i] = String.valueOf(i);
    ArrayAdapter<String> minutesChoices = new ArrayAdapter<String>(inflater.getContext(), android.R.layout.simple_spinner_item, minutesStrs);
    minutesChoices.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    minutesSpinner = (Spinner) v.findViewById(R.id.minutes);
    minutesSpinner.setAdapter(minutesChoices);

    Integer result = this.result.getResult();
    if (result != null) {
        hoursSpinner.setSelection(result / 60);
        minutesSpinner.setSelection(result % 60);
    }

    return v;
}
 
Example 3
Source File: DetailFragment.java    From ListItemFold with MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_blank, container, false);

    mWebview = (WebView) view.findViewById(R.id.h5_web);
    WebSettings webSettings = mWebview.getSettings();
    webSettings.setSupportZoom(false);
    webSettings.setPluginState(WebSettings.PluginState.ON);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setJavaScriptEnabled(true);
    mWebview.setWebChromeClient(new WebChromeClient());
    mWebview.setWebViewClient(new WebViewClient());
    mWebview.loadUrl(mUrl);
    DetailAnimViewGroup wrapper = new DetailAnimViewGroup(inflater.getContext(), view, 0);
    wrapper.setReversed(false);
    return wrapper;
}
 
Example 4
Source File: WrapRootViewFragment.java    From Gloading with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    imageView = new ImageView(inflater.getContext());
    holder = Gloading.getDefault().wrap(imageView).withRetry(new Runnable() {
        @Override
        public void run() {
            //change picture url to a correct one
            loadImage(getRandomImage());
        }
    });
    //demo load failed with an error image url
    loadImage(Util.getErrorImage());
    return holder.getWrapper();
}
 
Example 5
Source File: TabFragment.java    From android with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    TextView textView = new TextView(inflater.getContext());
    textView.setText("I'm tab content!" + Math.random());
    textView.setGravity(Gravity.CENTER);
    return textView;
}
 
Example 6
Source File: MainVu.java    From FlyWoo with Apache License 2.0 5 votes vote down vote up
@Override
public void init(LayoutInflater inflater, ViewGroup container) {
    context = inflater.getContext();
    view = inflater.inflate(R.layout.vu_main, container, false);
    bindViews();
    setListener();


}
 
Example 7
Source File: GridItemExercise.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public View getContentView(final LayoutInflater inflater, ViewGroup parent) {
  gridView =
      new GridView(
          inflater.getContext(),
          new GridView.ItemProvider() {
            @Override
            public View getView(ViewGroup parent, final int index) {
              View view = inflater.inflate(R.layout.tutorial_content_grid_item, parent, false);
              TextView title = (TextView) view.findViewById(R.id.title);
              String text =
                  inflater.getContext().getString(R.string.tutorial_template_item, index + 1);
              title.setText(text);
              view.setContentDescription(text);
              view.setOnClickListener(GridItemExercise.this);
              view.setAccessibilityDelegate(new GridItemAccessibilityDelegate(index + 1));
              return view;
            }
          });
  int horizontalPadding =
      inflater
          .getContext()
          .getResources()
          .getDimensionPixelSize(R.dimen.tutorial_grid_horizontal_offset);
  gridView.setPadding(horizontalPadding, 0, horizontalPadding, 0);
  mView = gridView;
  return mView;
}
 
Example 8
Source File: CompactNavigationListFragmentDelegate.java    From material-navigation-drawer with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    if (mTheme > 0) {
        Context newContext = new ContextThemeWrapper(inflater.getContext(), mTheme);
        inflater = inflater.cloneInContext(newContext);
    }
    mInflater = inflater;

    View view = inflater.inflate(R.layout.mnd_list_compact, container, false);
    mListView = (ListView) view.findViewById(R.id.mnd_list_compact);
    return view;
}
 
Example 9
Source File: BbCodesQuickView.java    From 4pdaClient-plus with Apache License 2.0 5 votes vote down vote up
@Override
View createView() {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    webView = new WebView(inflater.getContext());
    webView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    webView.setBackgroundColor(AppTheme.getThemeStyleWebViewBackground());
    loadWebView();
    return webView;
}
 
Example 10
Source File: SampleOfflinePriority.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final MapTileProviderBasic provider = new MapTileProviderBasic(getActivity());
    provider.setOfflineFirst(isOfflineFirst());
    mMapView = new MapView(inflater.getContext(), provider);
    return mMapView;
}
 
Example 11
Source File: MultiTypeLoadMoreAdapter.java    From AndroidUiKit with Apache License 2.0 5 votes vote down vote up
@Override
protected DefaultViewHolder createViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
    TextView view = new TextView(inflater.getContext());
    RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    view.setLayoutParams(params);
    view.setGravity(Gravity.CENTER);
    return new DefaultViewHolder(view);
}
 
Example 12
Source File: LabelSelectionFragment.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mRecyclerView = new RecyclerView(inflater.getContext());
/*    mRecyclerView.setPadding(
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()),
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()),
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, getResources().getDisplayMetrics()),
            0
    );*/
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setClipChildren(false);
    return mRecyclerView;
}
 
Example 13
Source File: RecyclerFragment.java    From ListItemFold with MIT License 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_item_list, container, false);
    mAdapter = new RecyclerDataAdapter(getActivity());
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setAdapter(mAdapter);
    mAdapter.setOnItemClick(this);
    DetailAnimViewGroup wrapper = new DetailAnimViewGroup(inflater.getContext(), view, 0);
    loadData();
    return wrapper;
}
 
Example 14
Source File: FlagSecureHelper.java    From cwac-security with Apache License 2.0 5 votes vote down vote up
public static Object getWrappedSystemService(Object service,
                                             String name,
                                             boolean wrapLayoutInflater) {
  if (Context.WINDOW_SERVICE.equals(name)) {
    boolean goAhead=true;

    for (StackTraceElement entry : Thread.currentThread().getStackTrace()) {
      try {
        Class cls=Class.forName(entry.getClassName());

        if (Dialog.class.isAssignableFrom(cls)) {
          goAhead=false;
          break;
        }
      }
      catch (ClassNotFoundException e) {
        // ???
      }
    }

    if (goAhead) {
      service=new SecureWindowManagerWrapper((WindowManager)service);
    }
  }
  else if (Context.LAYOUT_INFLATER_SERVICE.equals(name) && wrapLayoutInflater) {
    LayoutInflater original=(LayoutInflater)service;
    Context securified=
      new SecureContextWrapper(original.getContext(), true, true);

    service=original.cloneInContext(securified);
  }

  return(service);
}
 
Example 15
Source File: PlacesSearchNoneReviewFragment.java    From Place-Search-Service with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    TextView text = new TextView(inflater.getContext());
    text.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    text.setText("No reviews");
    text.setTextSize(15);
    text.setTextColor(getResources().getColor(android.R.color.darker_gray));
    text.setGravity(Gravity.CENTER);
    return text;
}
 
Example 16
Source File: NavHostFragment.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    FrameLayout frameLayout = new FrameLayout(inflater.getContext());
    // When added via XML, this has no effect (since this FrameLayout is given the ID
    // automatically), but this ensures that the View exists as part of this Fragment's View
    // hierarchy in cases where the NavHostFragment is added programmatically as is required
    // for child fragment transactions
    frameLayout.setId(getId());
    return frameLayout;
}
 
Example 17
Source File: FileAdapterVu.java    From FlyWoo with Apache License 2.0 4 votes vote down vote up
@Override
public void init(LayoutInflater inflater, ViewGroup container) {
    context = inflater.getContext();
    view = inflater.inflate(R.layout.item_file, container, false);
    bindViews();
}
 
Example 18
Source File: VedioAdapterVu.java    From FlyWoo with Apache License 2.0 4 votes vote down vote up
@Override
public void init(LayoutInflater inflater, ViewGroup container) {
    context = inflater.getContext();
    view = inflater.inflate(R.layout.item_vedio, container, false);
    bindViews();
}
 
Example 19
Source File: MusicVu.java    From FlyWoo with Apache License 2.0 4 votes vote down vote up
@Override
public void init(LayoutInflater inflater, ViewGroup container) {
    view = inflater.inflate(R.layout.vu_music, container, false);
    context = inflater.getContext();
    bindView();
}
 
Example 20
Source File: DCMapFragment.java    From deltachat-android with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Creates the fragment view hierarchy.
 *
 * @param inflater           Inflater used to inflate content.
 * @param container          The parent layout for the map fragment.
 * @param savedInstanceState The saved instance state for the map fragment.
 * @return The view created
 */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    Context context = inflater.getContext();
    map = new MapView(context, MapFragmentUtils.resolveArgs(context, getArguments()));
    return map;
}