Example usage for android.view LayoutInflater getContext

List of usage examples for android.view LayoutInflater getContext

Introduction

In this page you can find the example usage for android.view LayoutInflater getContext.

Prototype

public Context getContext() 

Source Link

Document

Return the context we are running in, for access to resources, class loader, etc.

Usage

From source file:kz.tanikin.inapppurchase2.SkusFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_list, container, false);
    titleView = (TextView) view.findViewById(R.id.list_title);
    listView = (ListView) view.findViewById(android.R.id.list);
    progressBar = (ProgressBar) view.findViewById(android.R.id.progress);
    emptyView = (TextView) view.findViewById(android.R.id.empty);
    adapter = new SkusAdapter(inflater.getContext());
    listView.setAdapter(adapter);//from  w w  w .jav  a2 s.  c  om

    listView.setOnItemClickListener(new OnSkuClickListener());
    titleView.setText(R.string.items_for_purchase);
    emptyView.setText(R.string.skus_empty);
    Log.i(tag, adapter.getCount() + "");
    return view;
}

From source file:org.y20k.trackbook.MainActivityMapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // create basic map
    mMapView = new MapView(inflater.getContext());

    // get map controller
    mController = mMapView.getController();

    // basic map setup
    mMapView.setTileSource(TileSourceFactory.MAPNIK);
    mMapView.setTilesScaledToDpi(true);/*  w  w w . j  ava  2  s  .  co m*/

    // add multi-touch capability
    mMapView.setMultiTouchControls(true);

    // add compass to map
    CompassOverlay compassOverlay = new CompassOverlay(mActivity,
            new InternalCompassOrientationProvider(mActivity), mMapView);
    compassOverlay.enableCompass();
    mMapView.getOverlays().add(compassOverlay);

    // initiate map state
    if (savedInstanceState != null) {
        // restore saved instance of map
        GeoPoint position = new GeoPoint(
                savedInstanceState.getDouble(INSTANCE_LATITUDE_MAIN_MAP, DEFAULT_LATITUDE),
                savedInstanceState.getDouble(INSTANCE_LONGITUDE_MAIN_MAP, DEFAULT_LONGITUDE));
        mController.setCenter(position);
        mController.setZoom(savedInstanceState.getInt(INSTANCE_ZOOM_LEVEL_MAIN_MAP, 16));
        // restore current location
        mCurrentBestLocation = savedInstanceState.getParcelable(INSTANCE_CURRENT_LOCATION);
    } else if (mCurrentBestLocation != null) {
        // fallback or first run: set map to current position
        GeoPoint position = convertToGeoPoint(mCurrentBestLocation);
        mController.setCenter(position);
        mController.setZoom(16);
    }

    // inform user that new/better location is on its way
    if (mFirstStart && !mTrackerServiceRunning) {
        Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_acquiring_location),
                Toast.LENGTH_LONG).show();
        mFirstStart = false;
    }

    // load track from saved instance
    if (savedInstanceState != null) {
        mTrack = savedInstanceState.getParcelable(INSTANCE_TRACK_MAIN_MAP);
    }

    // mark user's location on map
    if (mCurrentBestLocation != null && !mTrackerServiceRunning) {
        mMyLocationOverlay = MapHelper.createMyLocationOverlay(mActivity, mCurrentBestLocation,
                LocationHelper.isNewLocation(mCurrentBestLocation));
        mMapView.getOverlays().add(mMyLocationOverlay);
    }

    return mMapView;
}

From source file:com.wit.and.dialog.ListDialog.java

/**
 *///from   w  w  w  .j  a v  a  2  s .  co m
@Override
protected View onCreateBodyView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();

    // There will be default empty view behind the list view in relative layout.
    RelativeLayout layout = new RelativeLayout(context);
    if (container instanceof LinearLayout) {
        // Apply valid linear layout params to fit with list view just left space in the dialog main view.
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, 0);
        layoutParams.weight = 1;
        layout.setLayoutParams(layoutParams);
    } else {
        // Apply neutral layout params.
        layout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
    }
    layout.setGravity(Gravity.CENTER);
    // Do not allow to apply style to body view.
    // layout.setId(R.id.Dialog_Layout_Body);

    // Create empty view and insert it into body layout behind the list view.
    View emptyView = onCreateEmptyView(inflater, container, savedInstanceState);
    if (emptyView != null) {
        layout.addView(emptyView);
    }

    // Create list view and insert it into body layout.
    ListView listView = onCreateListView(inflater, layout, savedInstanceState);
    if (listView != null) {
        layout.addView(listView);
    }
    return layout;
}

From source file:com.silentcircle.contacts.list.ScDefaultContactBrowseListFragment.java

@Override
protected void onCreateView(LayoutInflater inflater, ViewGroup container) {
    super.onCreateView(inflater, container);
    mCounterHeaderView = (TextView) getOwnView().findViewById(R.id.contacts_count);

    // Create an empty user profile header and hide it for now (it will be visible if the
    // contacts list will have no user profile).
    addEmptyUserProfileHeader(inflater);
    showEmptyUserProfile(false);/* w  w w  .ja va2  s  .  c o m*/

    // Putting the header view inside a container will allow us to make
    // it invisible later. See checkHeaderViewVisibility()
    FrameLayout headerContainer = new FrameLayout(inflater.getContext());
    mSearchHeaderView = inflater.inflate(R.layout.search_header, null, false);
    headerContainer.addView(mSearchHeaderView);
    getListView().addHeaderView(headerContainer, null, false);
    checkHeaderViewVisibility();

    mSearchProgress = getOwnView().findViewById(R.id.search_progress);
    mSearchProgressText = (TextView) mSearchHeaderView.findViewById(R.id.totalContactsText);
}

From source file:org.kde.kdeconnect.UserInterface.PairingFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    //Log.e("PairingFragmen", "OnCreateView");

    mActivity.getSupportActionBar().setTitle(R.string.pairing_title);

    setHasOptionsMenu(true);//www  .  j a  v a2  s.  c o  m

    rootView = inflater.inflate(R.layout.activity_refresh_list, container, false);
    listRootView = rootView.findViewById(R.id.listView1);
    mSwipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.refresh_list_layout);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            updateComputerListAction();
        }
    });
    headerText = new TextView(inflater.getContext());
    headerText.setText(getString(R.string.pairing_description));
    headerText.setPadding(0, (int) (16 * getResources().getDisplayMetrics().density), 0,
            (int) (12 * getResources().getDisplayMetrics().density));
    ((ListView) listRootView).addHeaderView(headerText);

    return rootView;
}

From source file:com.gh4a.fragment.PullRequestFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View listContent = super.onCreateView(inflater, container, savedInstanceState);
    View v = inflater.inflate(R.layout.pull_request, container, false);

    FrameLayout listContainer = (FrameLayout) v.findViewById(R.id.list_container);
    listContainer.addView(listContent);/*from  ww  w.  j a  v a2 s  .  c  o  m*/

    mImageGetter = new HttpImageGetter(inflater.getContext());
    updateCommentSectionVisibility(v);

    return v;
}

From source file:com.ycdyng.onemulti.MultiFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    if (DEBUG)//from   ww w. java2  s  .c  o m
        Log.d(TAG, getClass().getSimpleName() + ": onCreateView");
    int layoutResId = getLayoutResourceId();
    if (layoutResId <= 0) {
        throw new IllegalStateException("Layout resource id can't be zero");
    }
    int themeResId = getThemeResId();
    if (themeResId != R.style.AppTheme) {
        ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(getActivity(), themeResId);
        inflater = inflater.cloneInContext(contextThemeWrapper);
    }
    mColorPrimaryDark = getColorPrimaryDark(inflater.getContext().getTheme());
    setStatusBarColor();

    mRootView = inflater.inflate(layoutResId, container, false);

    onCreateView(mRootView, container, savedInstanceState);
    return mRootView;
}

From source file:com.keylesspalace.tusky.fragment.NotificationsFragment.java

@Nullable
@Override//w ww. ja v  a 2  s . co  m
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);
    recyclerView = rootView.findViewById(R.id.recycler_view);
    progressBar = rootView.findViewById(R.id.progress_bar);
    nothingMessageView = rootView.findViewById(R.id.nothing_message);

    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.primary);
    swipeRefreshLayout.setProgressBackgroundColorSchemeColor(
            ThemeUtils.getColor(context, android.R.attr.colorBackground));
    // Setup the RecyclerView.
    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);

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

    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    setupNothingView();

    return rootView;
}

From source file:org.dmfs.webcal.fragments.CalendarSettingsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View root = inflater.inflate(R.layout.fragment_calendar_settings, container, false);

    root.findViewById(R.id.color_setting).setOnClickListener(this);
    root.findViewById(R.id.name_setting).setOnClickListener(this);
    root.findViewById(R.id.alarm_setting).setOnClickListener(this);

    mColorPreview = (ImageView) root.findViewById(R.id.color_preview);
    mCalendarName = (TextView) root.findViewById(R.id.calendar_name);
    mAlarmSpinner = (Spinner) root.findViewById(R.id.calendar_reminder);

    mColorPreview.setBackgroundColor(mNewColor);
    mCalendarName.setText(mNewName);//from   w w  w .  j  av  a 2 s.  c  om
    if (mAlarmSpinner != null) {
        ArrayAdapter<CharSequence> mAlarmAdapter = ArrayAdapter.createFromResource(inflater.getContext(),
                R.array.alarm_names, R.layout.simple_spinner_item);
        mAlarmAdapter.setDropDownViewResource(R.layout.simple_spinner_dropdown_item);
        mAlarmSpinner.setAdapter(mAlarmAdapter);
    }

    LoaderManager loaderManage = getLoaderManager();
    loaderManage.initLoader(ID_SUBSCRIPTION_LOADER, null, this);

    return root;
}

From source file:com.wit.and.dialog.ListDialog.java

/**
 * <p>//from w  ww.j  a v  a 2 s. co  m
 * Invoked to create dialog list view.
 * </p>
 * <p>
 * Here is the best place to provide custom list view.
 * </p>
 *
 * @param inflater           Layout inflater.
 * @param container          Layout created in the {@link #onCreateBodyView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)}
 * @param savedInstanceState Saved dialog state.
 * @return Created dialog list view.
 */
protected ListView onCreateListView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ListView listView;

    final ListOptions options = getOptions();
    if (options.getListViewRes() != DEFAULT_RES) {
        // Inflate custom list view.
        listView = (ListView) inflater.inflate(options.getListViewRes(), null, false);
    } else {
        // Create default list view.
        listView = new ListView(inflater.getContext(), null, android.R.attr.listViewStyle);
        listView.setId(R.id.And_Dialog_ListView);
        RelativeLayout.LayoutParams listViewParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        listViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        listView.setLayoutParams(listViewParams);
    }
    return listView;
}