Example usage for android.content Context LAYOUT_INFLATER_SERVICE

List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE

Introduction

In this page you can find the example usage for android.content Context LAYOUT_INFLATER_SERVICE.

Prototype

String LAYOUT_INFLATER_SERVICE

To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.LayoutInflater for inflating layout resources in this context.

Usage

From source file:co.nerdart.ourss.adapter.CursorLoaderExpandableListAdapter.java

/**
 * Constructor./*from  w w w. j av a 2  s.c  o m*/
 *
 * @param collapsedGroupLayout resource identifier of a layout file that defines the views for collapsed groups.
 * @param expandedGroupLayout  resource identifier of a layout file that defines the views for expanded groups.
 * @param childLayout          resource identifier of a layout file that defines the views for all children but the last..
 */
public CursorLoaderExpandableListAdapter(FragmentActivity activity, Uri groupUri, int collapsedGroupLayout,
        int expandedGroupLayout, int childLayout) {
    mActivity = activity;
    mLoaderMgr = activity.getSupportLoaderManager();
    mGroupUri = groupUri;

    mCollapsedGroupLayout = collapsedGroupLayout;
    mExpandedGroupLayout = expandedGroupLayout;
    mChildLayout = childLayout;

    mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mLoaderMgr.restartLoader(0, null, mGroupLoaderCallback);
}

From source file:com.android.contacts.activities.ActionBarAdapter.java

private void setupSearchAndSelectionViews() {
    final LayoutInflater inflater = (LayoutInflater) mToolbar.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // Setup search bar
    mSearchContainer = inflater.inflate(R.layout.search_bar_expanded, mToolbar, /* attachToRoot = */ false);
    mSearchContainer.setVisibility(View.VISIBLE);
    mToolbar.addView(mSearchContainer);/*from w  w  w  . j  av  a2 s . co m*/
    mSearchContainer.setBackgroundColor(mActivity.getResources().getColor(R.color.searchbox_background_color));
    mSearchView = (EditText) mSearchContainer.findViewById(R.id.search_view);
    mSearchView.setHint(mActivity.getString(R.string.hint_findContacts));
    mSearchView.addTextChangedListener(new SearchTextWatcher());
    mSearchContainer.findViewById(R.id.search_back_button).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mListener != null) {
                mListener.onUpButtonPressed();
            }
        }
    });

    mClearSearchView = mSearchContainer.findViewById(R.id.search_close_button);
    mClearSearchView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setQueryString(null);
        }
    });

    // Setup selection bar
    mSelectionContainer = inflater.inflate(R.layout.selection_bar, mToolbar, /* attachToRoot = */ false);
    // Insert the selection container into mToolBarFrame behind the Toolbar, so that
    // the Toolbar's MenuItems can appear on top of the selection container.
    mToolBarFrame.addView(mSelectionContainer, 0);
    mSelectionContainer.findViewById(R.id.selection_close).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mListener != null) {
                mListener.onUpButtonPressed();
            }
        }
    });
}

From source file:fr.univsavoie.ltp.client.map.Popup.java

/**
 * Afficher sur la map un popup qui propose a l'utilisateur
 * de mettre a jours son status/*from  w w  w  . j  a va  2s  .c o m*/
 */
public final void popupPublishStatus() {
    DisplayMetrics dm = new DisplayMetrics();
    this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    //final int height = dm.heightPixels;
    final int width = dm.widthPixels;

    int popupWidth = (int) (width * 0.75);
    //int popupHeight = height / 2;

    // Inflate the popup_layout.xml
    ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupStatus);
    LayoutInflater layoutInflater = (LayoutInflater) this.activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View layout = layoutInflater.inflate(R.layout.popup_set_status, viewGroup);
    layout.setBackgroundResource(R.drawable.popup_gradient);

    // Crer le PopupWindow
    final PopupWindow popupPublishStatus = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true);
    popupPublishStatus.setBackgroundDrawable(new BitmapDrawable());
    popupPublishStatus.setOutsideTouchable(true);

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
    final int OFFSET_X = 0;
    final int OFFSET_Y = 0;

    // Displaying the popup at the specified location, + offsets.
    this.activity.findViewById(R.id.layoutMain).post(new Runnable() {
        public void run() {
            popupPublishStatus.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y);
        }
    });

    /*
     * Evenements composants du PopupWindow
     */

    // Ecouteur d'vnement sur le bouton pour se dconnecter
    Button publish = (Button) layout.findViewById(R.id.btStatusPublish);
    publish.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            EditText userStatus = (EditText) layout.findViewById(R.id.fieldUserStatus);
            if (userStatus.getText().toString().length() == 0) {
                Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show();
                popupPublishStatus.dismiss();
            } else if (userStatus.getText().toString().length() < 3) {
                Toast.makeText(activity, "Impossible de publi ton status !", Toast.LENGTH_LONG).show();
                popupPublishStatus.dismiss();
            } else {
                String json = "{\"ltp\":{\"application\":\"Client LTP\",\"status\":{\"lon\" : \""
                        + String.valueOf(activity.getLongitude()) + "\",\"lat\" : \""
                        + String.valueOf(activity.getLatitude()) + "\",\"content\" : \""
                        + userStatus.getText().toString() + "\"}}}";
                activity.getSession().postJSON("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses",
                        "STATUSES", json);

                Toast.makeText(activity, "Status mise a jours !", Toast.LENGTH_LONG).show();
                popupPublishStatus.dismiss();

                // Actualise les marqueurs
                activity.displayFriends();
            }
        }
    });
}

From source file:ch.ethz.coss.nervousnet.hub.ui.SensorDisplayActivity.java

@Override
public void updateActionBar() {

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.ab_nn, null);
    ActionBar actionBar;//w  w w.  j  a va2s .  com
    Switch mainSwitch;

    actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setCustomView(v);
    mainSwitch = (Switch) findViewById(R.id.mainSwitch);

    byte state = ((Application) getApplication()).getState();
    NNLog.d("SensorDisplayActivity", "state = " + state);
    mainSwitch.setChecked(state == 0 ? false : true);

    mainSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            startStopSensorService(isChecked);
        }
    });

}

From source file:com.diedrico.diedricoapp.PicMenuActivity.java

License:asdf

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    context = this; //set the context

    //Inflate the content in the coordinator layout
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
    LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.content_pic_menu, coordinatorLayout);

    //The toolbar of the app
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from   w  ww  .j  a v a  2 s .c om*/

    //Now we have to put the button in the toolbar and setup the NavigationView
    drawer = (DrawerLayout) findViewById(R.id.drawer_tabs_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    expListView = (ExpandableListView) findViewById(R.id.expandableListView);

    prepareExapandableListNavigationView(); //To load the lists

    listAdapter = new ExpandableListAdapter(this, header, listDataChild);
    expListView.setAdapter(listAdapter);
    expListView.setOnChildClickListener(onExpandableClick());

    //Prepare the ListView, load the items from itemsListView
    listView = (ListView) findViewById(R.id.listView);
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this, R.layout.group_expandable,
            R.id.expandableGroupText, itemsListView);
    listView.setAdapter(arrayAdapter);

    listView.setOnItemClickListener(onListViewItemListener());

    Intent intent = getIntent();
    String originalFile = intent.getStringExtra("file"); //we receive te file of the picture
    copyOfFile = originalFile.substring(0, originalFile.length() - 4) + "2.jpg"; //The path where we will copy the file
    copyFile(originalFile, copyOfFile); //we have to copy the picture for modifying with BOOFCV

    imageView = (android.widget.ImageView) findViewById(R.id.imagePreview); //the imageView

    new Thresholding(BitmapFactory.decodeFile(copyOfFile), new Thresholding.AsyncResponse() { //thresholding, the pictur pass to a filter where blacks are more blacks and whites more whites
        @Override
        public void processFinish(Bitmap result) {
            imageView.setImageBitmap(result);
            thresholdingBitmap = result;
        }
    }).execute(1);

    seekBar = (SeekBar) findViewById(R.id.seekBar); //our SeekBar
    seekBar.setOnSeekBarChangeListener(seekBarChangeListener());

    //Inflate the buttons to confirm the analysis
    layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    confirmationLayout = (LinearLayout) findViewById(R.id.menuLayout);
    layoutInflater.inflate(R.layout.confirmation_buttons, confirmationLayout);

    confirmButton = (ImageButton) confirmationLayout.findViewById(R.id.buttonOk);
    confirmButton.setOnClickListener(confirmClickListener());
    wrongButton = (ImageButton) confirmationLayout.findViewById(R.id.buttonWrong);
    wrongButton.setOnClickListener(wrongButtonClickListener());
}

From source file:com.money.manager.ex.adapter.CategoryExpandableListAdapter.java

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    CategoryListItemViewHolderGroup holder;
    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(mLayout, null);

        holder = new CategoryListItemViewHolderGroup(convertView);

        convertView.setTag(holder);//from  w w  w. j a v a  2s. c om
    } else {
        holder = (CategoryListItemViewHolderGroup) convertView.getTag();
    }

    // prevent exceptions. todo: Find out how this happens in the first place.
    if (mCategories.size() == 0)
        return convertView;

    Category category = mCategories.get(groupPosition);

    holder.text1.setText(category.getName());

    // Selector

    if (mShowSelector) {
        holder.selector.setVisibility(View.VISIBLE);
        // set the tag to be the group position
        holder.selector.setTag(category.getId());

        holder.selector.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String tag = v.getTag().toString();
                Integer groupId = Integer.parseInt(tag);
                setIdGroupChecked(groupId);
                // close
                closeFragment();
            }
        });
    } else {
        holder.selector.setVisibility(View.GONE);
    }

    if (holder.collapseImageView != null) {
        TypedArray expandableListViewStyle = getContext().getTheme()
                .obtainStyledAttributes(new int[] { android.R.attr.expandableListViewStyle });
        TypedArray groupIndicator = getContext().getTheme().obtainStyledAttributes(
                expandableListViewStyle.getResourceId(0, 0), new int[] { android.R.attr.groupIndicator });
        Drawable drawable = groupIndicator.getDrawable(0);
        holder.collapseImageView.setImageDrawable(drawable);
        expandableListViewStyle.recycle();
        groupIndicator.recycle();

        boolean hasChildren = getChildrenCount(groupPosition) != 0;
        if (!hasChildren) {
            holder.collapseImageView.setVisibility(View.INVISIBLE);
        } else {
            holder.collapseImageView.setVisibility(View.VISIBLE);

            if (drawable != null) {
                drawable.setState(isExpanded ? expandedStateSet : emptyStateSet);
            }
        }
    }

    return convertView;
}

From source file:com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.java

protected void initViews() {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.ultimate_recycler_view_layout, this);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.ultimate_list);
    mSwipeRefreshLayout = (VerticalSwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
    setScrollbars();//from  ww  w  .j a va 2 s  .c  o m
    mSwipeRefreshLayout.setEnabled(false);

    if (mRecyclerView != null) {

        mRecyclerView.setClipToPadding(mClipToPadding);
        if (mPadding != -1.1f) {
            mRecyclerView.setPadding(mPadding, mPadding, mPadding, mPadding);
        } else {
            mRecyclerView.setPadding(mPaddingLeft, mPaddingTop, mPaddingRight, mPaddingBottom);
        }
    }

    defaultFloatingActionButton = (FloatingActionButton) view.findViewById(R.id.defaultFloatingActionButton);
    setDefaultScrollListener();

    mEmpty = (ViewStub) view.findViewById(R.id.emptyview);
    mFloatingButtonViewStub = (ViewStub) view.findViewById(R.id.floatingActionViewStub);

    mEmpty.setLayoutResource(mEmptyId);

    mFloatingButtonViewStub.setLayoutResource(mFloatingButtonId);

    if (mEmptyId != 0)
        mEmptyView = mEmpty.inflate();
    mEmpty.setVisibility(View.GONE);

}

From source file:com.conduit.plastic.common.BaseActivity.java

/**
 * toolbar?//w  w  w . java 2  s  .co  m
 */
public void setContentLayout() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View contentView = inflater.inflate(LayoutId(), null);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mContent.addView(contentView, params);
}

From source file:com.irccloud.android.fragment.WhoListFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();//  w  w w .ja  v  a 2 s .co m
    if (ctx == null)
        return null;

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.recyclerview, null);
    recyclerView = v.findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext()));
    empty = v.findViewById(android.R.id.empty);
    empty.setText("No results found.");
    if (savedInstanceState != null && savedInstanceState.containsKey("event")) {
        event = new IRCCloudJSONObject(savedInstanceState.getString("event"));
        users = event.getJsonNode("users");
        adapter = new UsersAdapter();
        recyclerView.setAdapter(adapter);
        if (adapter.getItemCount() > 0) {
            empty.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        } else {
            empty.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        }
    }
    Dialog d = new AlertDialog.Builder(ctx).setTitle("WHO response for " + event.getString("subject"))
            .setView(v).setNegativeButton("Close", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
    return d;
}