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:com.microsoft.mimickeralarm.mimics.MimicTongueTwisterFragment.java

private void createSharableBitmap() {
    Bitmap sharableBitmap = Bitmap.createBitmap(getView().getWidth(), getView().getHeight(),
            Bitmap.Config.ARGB_8888);/*from  ww w . j  av  a2 s . c  om*/
    Canvas canvas = new Canvas(sharableBitmap);
    canvas.drawColor(ContextCompat.getColor(getContext(), R.color.white));

    // Load the view for the sharable. This will be drawn to the bitmap
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.fragment_sharable_tongue_twister, null);

    TextView textView = (TextView) layout.findViewById(R.id.twister_sharable_tongue_twister);
    textView.setText(mQuestion);

    textView = (TextView) layout.findViewById(R.id.twister_sharable_i_said);
    textView.setText(mUnderstoodText);

    textView = (TextView) layout.findViewById(R.id.mimic_twister_share_success);
    textView.setText(mSuccessMessage);

    // Perform the layout using the dimension of the bitmap
    int widthSpec = View.MeasureSpec.makeMeasureSpec(canvas.getWidth(), View.MeasureSpec.EXACTLY);
    int heightSpec = View.MeasureSpec.makeMeasureSpec(canvas.getHeight(), View.MeasureSpec.EXACTLY);
    layout.measure(widthSpec, heightSpec);
    layout.layout(0, 0, layout.getMeasuredWidth(), layout.getMeasuredHeight());

    // Draw the generated view to canvas
    layout.draw(canvas);

    String title = getString(R.string.app_short_name) + ": " + getString(R.string.mimic_twister_name);
    mSharableUri = ShareFragment.saveShareableBitmap(getActivity(), sharableBitmap, title);
}

From source file:cm.aptoide.com.actionbarsherlock.widget.SearchView.java

public SearchView(Context context, AttributeSet attrs) {
    super(context, attrs);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.FROYO) {
        throw new IllegalStateException("SearchView is API 8+ only.");
    }/*from www .jav  a2  s. c om*/

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.abs__search_view, this, true);

    mSearchButton = findViewById(R.id.abs__search_button);
    mQueryTextView = (SearchAutoComplete) findViewById(R.id.abs__search_src_text);
    mQueryTextView.setSearchView(this);

    mSearchEditFrame = findViewById(R.id.abs__search_edit_frame);
    mSearchPlate = findViewById(R.id.abs__search_plate);
    mSubmitArea = findViewById(R.id.abs__submit_area);
    mSubmitButton = findViewById(R.id.abs__search_go_btn);
    mCloseButton = (ImageView) findViewById(R.id.abs__search_close_btn);
    mVoiceButton = findViewById(R.id.abs__search_voice_btn);
    mSearchHintIcon = (ImageView) findViewById(R.id.abs__search_mag_icon);

    mSearchButton.setOnClickListener(mOnClickListener);
    mCloseButton.setOnClickListener(mOnClickListener);
    mSubmitButton.setOnClickListener(mOnClickListener);
    mVoiceButton.setOnClickListener(mOnClickListener);
    mQueryTextView.setOnClickListener(mOnClickListener);

    mQueryTextView.addTextChangedListener(mTextWatcher);
    mQueryTextView.setOnEditorActionListener(mOnEditorActionListener);
    mQueryTextView.setOnItemClickListener(mOnItemClickListener);
    mQueryTextView.setOnItemSelectedListener(mOnItemSelectedListener);
    mQueryTextView.setOnKeyListener(mTextKeyListener);
    // Inform any listener of focus changes
    mQueryTextView.setOnFocusChangeListener(new OnFocusChangeListener() {

        public void onFocusChange(View v, boolean hasFocus) {
            if (mOnQueryTextFocusChangeListener != null) {
                mOnQueryTextFocusChangeListener.onFocusChange(SearchView.this, hasFocus);
            }
        }
    });

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockSearchView, 0, 0);
    setIconifiedByDefault(a.getBoolean(R.styleable.SherlockSearchView_iconifiedByDefault, true));
    int maxWidth = a.getDimensionPixelSize(R.styleable.SherlockSearchView_android_maxWidth, -1);
    if (maxWidth != -1) {
        setMaxWidth(maxWidth);
    }
    CharSequence queryHint = a.getText(R.styleable.SherlockSearchView_queryHint);
    if (!TextUtils.isEmpty(queryHint)) {
        setQueryHint(queryHint);
    }
    int imeOptions = a.getInt(R.styleable.SherlockSearchView_android_imeOptions, -1);
    if (imeOptions != -1) {
        setImeOptions(imeOptions);
    }
    int inputType = a.getInt(R.styleable.SherlockSearchView_android_inputType, -1);
    if (inputType != -1) {
        setInputType(inputType);
    }

    a.recycle();

    boolean focusable = true;

    a = context.obtainStyledAttributes(attrs, R.styleable.SherlockView, 0, 0);
    focusable = a.getBoolean(R.styleable.SherlockView_android_focusable, focusable);
    a.recycle();
    setFocusable(focusable);

    // Save voice intent for later queries/launching
    mVoiceWebSearchIntent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
    mVoiceWebSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    mVoiceWebSearchIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
            RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);

    mVoiceAppSearchIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    mVoiceAppSearchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    mDropDownAnchor = findViewById(mQueryTextView.getDropDownAnchor());
    if (mDropDownAnchor != null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mDropDownAnchor.addOnLayoutChangeListener(new OnLayoutChangeListener() {
                @Override
                public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft,
                        int oldTop, int oldRight, int oldBottom) {
                    adjustDropDownSizeAndPosition();
                }
            });
        } else {
            mDropDownAnchor.getViewTreeObserver()
                    .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                        @Override
                        public void onGlobalLayout() {
                            adjustDropDownSizeAndPosition();
                        }
                    });
        }
    }

    updateViewsVisibility(mIconifiedByDefault);
    updateQueryHint();
}

From source file:com.example.angelina.travelapp.map.MapFragment.java

@Override
public void showRouteDetail(final int position) {
    // Remove the route header view,
    ////from www.  jav a2s.  c  om
    //since we're replacing it with a different header

    removeRouteHeaderView();
    // State  and stage flags
    mCurrentPosition = position;
    mShowingRouteDetail = true;

    // Hide action bar
    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if (ab != null) {
        ab.hide();
    }

    // Display route detail header
    final LayoutInflater inflater = (LayoutInflater) getActivity()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final LinearLayout.LayoutParams routeDetailLayout = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    if (mRouteHeaderDetail == null) {
        mRouteHeaderDetail = (LinearLayout) inflater.inflate(R.layout.route_detail_header, null);
        TextView title = (TextView) mRouteHeaderDetail.findViewById(R.id.route_txt_detail);
        title.setText("Route Detail");

        mRouteHeaderDetail.setBackgroundColor(Color.WHITE);
        mMapView.addView(mRouteHeaderDetail, routeDetailLayout);
        mMapView.requestLayout();

        // Attach a listener to the back arrow
        ImageView imageBtn = (ImageView) mRouteHeaderDetail.findViewById(R.id.btnDetailHeaderClose);
        imageBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // Navigate back to directions list
                mShowingRouteDetail = false;
                ((MapActivity) getActivity()).showDirections(mRouteDirections);
            }
        });
    }

    // Display arrows to scroll through directions
    if (mSegmentNavigator == null) {
        mSegmentNavigator = (LinearLayout) inflater.inflate(R.layout.navigation_arrows, null);
        final FrameLayout navigatorLayout = (FrameLayout) getActivity()
                .findViewById(R.id.map_fragment_container);
        FrameLayout.LayoutParams frameLayoutParams = new FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
                Gravity.BOTTOM | Gravity.END);
        frameLayoutParams.setMargins(0, 0, 0, 80);
        navigatorLayout.addView(mSegmentNavigator, frameLayoutParams);
        navigatorLayout.requestLayout();
        // Add button click listeners
        Button btnPrev = (Button) getActivity().findViewById(R.id.btnBack);

        btnPrev.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCurrentPosition > 0) {
                    populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition - 1));
                    mCurrentPosition = mCurrentPosition - 1;
                }

            }
        });
        Button btnNext = (Button) getActivity().findViewById(R.id.btnNext);
        btnNext.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCurrentPosition < mRouteDirections.size() - 1) {
                    populateViewWithRouteDetail(mRouteDirections.get(mCurrentPosition + 1));
                    mCurrentPosition = mCurrentPosition + 1;
                }

            }
        });
    }

    // Populate with directions
    DirectionManeuver maneuver = mRouteDirections.get(position);
    populateViewWithRouteDetail(maneuver);

}

From source file:com.hp.map.CustomerMapActivity.java

public void menuDialog() {
    final Dialog dialog = new Dialog(this);
    LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = li.inflate(R.layout.menu_dialog, null, false);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(v);/*from  ww w.  j  a va2s . co  m*/

    dialog.setTitle("Danh mc chnh");

    Display display = getWindowManager().getDefaultDisplay();

    dialog.getWindow().setLayout(2 * display.getWidth() / 3, LayoutParams.FILL_PARENT);
    dialog.getWindow().getAttributes().gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;

    lv = (ListView) dialog.findViewById(R.id.menu_list_view);

    lv.setAdapter(
            new DialogArrayAdapter(context, android.R.layout.simple_list_item_1, DetailListData.MENU_LIST));
    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            // TODO Auto-generated method stub
            DetailsList selectedValue = (DetailsList) lv.getAdapter().getItem(arg2);
            if (selectedValue.activityClass != null) {
                //if sigout
                if (selectedValue.activityClass == LoginActivity.class) {
                    //LoginActivity.threadLooper.quit();
                }
                startActivity(new Intent(context, selectedValue.activityClass));
            }
        }
    });

    dialog.show();

    //      ImageView iv = (ImageView)dialog.findViewById(R.id.menu_list_view);
    //      iv.setImageResource(1);
}

From source file:com.money.manager.ex.fragment.SearchFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Core core = new Core(getSherlockActivity());
    // ****** action bar *****
    getSherlockActivity().getSupportActionBar().setSubtitle(null);
    if (!(core.isTablet() || Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)) {
        getSherlockActivity().getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM,
                ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE
                        | ActionBar.DISPLAY_SHOW_CUSTOM);

        LayoutInflater inflater = (LayoutInflater) getSherlockActivity()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View actionBarButtons = inflater.inflate(R.layout.actionbar_button_cancel_done,
                new LinearLayout(getSherlockActivity()), false);
        View cancelActionView = actionBarButtons.findViewById(R.id.action_cancel);
        cancelActionView.setOnClickListener(new OnClickListener() {

            @Override//from  w ww  . jav a 2  s. co m
            public void onClick(View v) {
                onDoneClick();
            }
        });
        View doneActionView = actionBarButtons.findViewById(R.id.action_done);
        ImageView doneImageView = (ImageView) doneActionView.findViewById(R.id.image_done);
        doneImageView.setImageDrawable(getSherlockActivity().getResources()
                .getDrawable(core.resolveIdAttribute(R.attr.ic_action_search)));
        TextView doneTextView = (TextView) doneActionView.findViewById(R.id.text_done);
        doneTextView.setText(R.string.search);

        doneActionView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onSearchClick();
            }
        });
        getSherlockActivity().getSupportActionBar().setCustomView(actionBarButtons);
    }
    // ****** action bar *****
}

From source file:com.example.survey2.ExpandableListAdapter.java

/**
 * Constructor//  ww w  .j a  v  a 2s. c  o  m
 * 
 * @param context The context where the {@link ExpandableListView}
 *            associated with this {@link SimpleExpandableListAdapter} is
 *            running
 * @param groupData A List of Maps. Each entry in the List corresponds to
 *            one group in the list. The Maps contain the data for each
 *            group, and should include all the entries specified in
 *            "groupFrom"
 * @param groupFrom A list of keys that will be fetched from the Map
 *            associated with each group.
 * @param groupTo The group views that should display column in the
 *            "groupFrom" parameter. These should all be TextViews. The
 *            first N views in this list are given the values of the first N
 *            columns in the groupFrom parameter.
 * @param expandedGroupLayout resource identifier of a view layout that
 *            defines the views for an expanded group. The layout file
 *            should include at least those named views defined in "groupTo"
 * @param collapsedGroupLayout resource identifier of a view layout that
 *            defines the views for a collapsed group. The layout file
 *            should include at least those named views defined in "groupTo"
 * @param childData A List of List of Maps. Each entry in the outer List
 *            corresponds to a group (index by group position), each entry
 *            in the inner List corresponds to a child within the group
 *            (index by child position), and the Map corresponds to the data
 *            for a child (index by values in the childFrom array). The Map
 *            contains the data for each child, and should include all the
 *            entries specified in "childFrom"
 * @param childFrom A list of keys that will be fetched from the Map
 *            associated with each child.
 * @param childTo The child views that should display column in the
 *            "childFrom" parameter. These should all be TextViews. The
 *            first N views in this list are given the values of the first N
 *            columns in the childFrom parameter.
 * @param childLayout resource identifier of a view layout that defines the
 *            views for a child (unless it is the last child within a group,
 *            in which case the lastChildLayout is used). The layout file
 *            should include at least those named views defined in "childTo"
 * @param lastChildLayout resource identifier of a view layout that defines
 *            the views for the last child within each group. The layout
 *            file should include at least those named views defined in
 *            "childTo"
 */
public ExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int expandedGroupLayout,
        int collapsedGroupLayout, String[] groupFrom, int[] groupTo,
        List<? extends List<? extends Map<String, ?>>> childData, int childLayout, int lastChildLayout,
        String[] childFrom, int[] childTo) {
    mContext = context;
    mGroupData = groupData;
    mExpandedGroupLayout = expandedGroupLayout;
    mCollapsedGroupLayout = collapsedGroupLayout;
    mGroupFrom = groupFrom;
    mGroupTo = groupTo;

    mChildData = childData;
    mChildLayout = childLayout;
    mLastChildLayout = lastChildLayout;
    mChildFrom = childFrom;
    mChildTo = childTo;

    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

From source file:com.granita.tasks.ViewTaskFragment.java

/**
 * Update the detail view with the current ContentSet. This removes any previous detail view and creates a new one if {@link #mContentSet} is not
 * <code>null</code>./*from  w ww. j  a v  a  2  s  .c  om*/
 */
private void updateView() {
    Activity activity = getActivity();
    if (mContent != null && activity != null) {
        final LayoutInflater inflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if (mDetailView != null) {
            // remove values, to ensure all listeners get released
            mDetailView.setValues(null);
        }

        mContent.removeAllViews();
        if (mContentSet != null) {
            mDetailView = (TaskView) inflater.inflate(R.layout.task_view, mContent, false);
            mDetailView.setModel(mModel);
            mDetailView.setValues(mContentSet);
            mContent.addView(mDetailView);
        }

        mActionButton = mDetailView.findViewById(R.id.action_button);

        if (mActionButton != null) {
            mActionButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    switch (mActionButtonAction) {
                    case ACTION_COMPLETE: {
                        completeTask();
                        break;
                    }
                    case ACTION_EDIT: {
                        mCallback.onEditTask(mTaskUri, mContentSet);
                        break;
                    }
                    }
                }
            });
        }

        if (mContentSet != null && TaskFieldAdapters.IS_CLOSED.get(mContentSet)) {
            ((ImageView) mActionButton.findViewById(android.R.id.icon))
                    .setImageResource(R.drawable.content_edit);
            mActionButtonAction = ACTION_EDIT;
        } else {
            mActionButtonAction = ACTION_COMPLETE;
        }

        if (mColorBar != null) {
            updateColor((float) mRootView.getScrollY() / mColorBar.getMeasuredHeight());
        }
    }
}

From source file:com.google.samples.apps.iosched.videolibrary.VideoLibraryFilteredFragment.java

@Override
public View newCollectionHeaderView(Context context, int groupId, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    return inflater.inflate(R.layout.list_item_explore_header, parent, false);
}

From source file:mx.com.adolfogarcia.popularmovies.model.view.MovieDetailViewModel.java

/**
 * Removes all views from the {@link LinearLayout} and adds new ones for
 * the specified {@link Review}s.//from  ww w. j  av  a2 s .  c  o m
 *
 * @param container {@link LinearLayout} that will contain the reviews.
 * @param reviews the {@link Review}s to be placed in the container.
 */
@BindingAdapter({ "bind:reviews" })
public static void loadReviewViews(LinearLayout container, List<Review> reviews) {
    container.removeAllViews();
    if (reviews == null || reviews.isEmpty()) {
        return;
    }
    LayoutInflater inflater = (LayoutInflater) container.getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    for (Review review : reviews) {
        MovieReviewListItemBinding binding = DataBindingUtil.inflate(inflater, R.layout.list_item_movie_review,
                container, false);
        MovieReviewListItemViewModel itemViewModel = new MovieReviewListItemViewModel();
        itemViewModel.setReview(review);
        binding.setViewModel(itemViewModel);
        container.addView(binding.getRoot());
    }
}