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.fastbootmobile.encore.app.adapters.PlaylistGridAdapter.java

/**
 * {@inheritDoc}/*from  w  w w.j a  va2s .  co  m*/
 */
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Context ctx = parent.getContext();
    assert ctx != null;

    View root = convertView;
    if (convertView == null) {
        // Create a new view (nothing to recycle)
        LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        root = inflater.inflate(R.layout.medium_card_two_lines, parent, false);
        assert root != null;

        ViewHolder holder = new ViewHolder();
        holder.vRoot = (ViewGroup) root;
        holder.ivCover = (AlbumArtImageView) root.findViewById(R.id.ivCover);
        holder.tvTitle = (TextView) root.findViewById(R.id.tvTitle);
        holder.tvSubTitle = (TextView) root.findViewById(R.id.tvSubTitle);
        holder.ivOfflineStatus = (ImageView) root.findViewById(R.id.ivOfflineStatus);

        root.setTag(holder);
    }

    // Fill in the fields
    final Playlist playlist = getItem(position);
    final ViewHolder tag = (ViewHolder) root.getTag();

    tag.playlist = playlist;

    if (playlist.isLoaded() || playlist.getName() != null) {
        tag.tvTitle.setText(playlist.getName());
        tag.tvSubTitle.setText(ctx.getResources().getQuantityString(R.plurals.songs_count,
                playlist.getSongsCount(), playlist.getSongsCount()));
        tag.ivCover.loadArtForPlaylist(playlist);

        tag.ivOfflineStatus.setVisibility(View.VISIBLE);
        switch (playlist.getOfflineStatus()) {
        case BoundEntity.OFFLINE_STATUS_NO:
            tag.ivOfflineStatus.setVisibility(View.GONE);
            break;

        case BoundEntity.OFFLINE_STATUS_DOWNLOADING:
            tag.ivOfflineStatus.setImageResource(R.drawable.ic_sync_in_progress);
            break;

        case BoundEntity.OFFLINE_STATUS_ERROR:
            tag.ivOfflineStatus.setImageResource(R.drawable.ic_sync_problem);
            break;

        case BoundEntity.OFFLINE_STATUS_PENDING:
            tag.ivOfflineStatus.setImageResource(R.drawable.ic_track_download_pending);
            break;

        case BoundEntity.OFFLINE_STATUS_READY:
            tag.ivOfflineStatus.setImageResource(R.drawable.ic_track_downloaded);
            break;
        }
    } else {
        tag.tvTitle.setText(R.string.loading);
        tag.tvSubTitle.setText(R.string.loading);
        tag.ivCover.setDefaultArt();
        tag.ivOfflineStatus.setVisibility(View.GONE);
    }

    return root;
}

From source file:com.massivekinetics.ow.ui.views.timepicker.TimePicker.java

public TimePicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    // initialization based on locale
    setCurrentLocale(Locale.getDefault());

    // process style attributes
    //TypedArray attributesArray = context.obtainStyledAttributes(
    //        attrs, R.styleable.TimePicker, defStyle, 0);
    //int layoutResourceId = attributesArray.getResourceId(
    //        R.styleable.TimePicker_internalLayout, R.layout.time_picker);
    //attributesArray.recycle();
    int layoutResourceId = R.layout.time_picker_holo;

    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(layoutResourceId, this, true);

    // hour// ww  w  .  j  a v a2s  . c o  m
    mHourSpinner = (NumberPicker) findViewById(R.id.hour);
    mHourSpinner.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        public void onValueChange(NumberPicker spinner, int oldVal, int newVal) {
            updateInputState();
            if (!is24HourView()) {
                if ((oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY)
                        || (oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1)) {
                    mIsAm = !mIsAm;
                    updateAmPmControl();
                }
            }
            onTimeChanged();
        }
    });
    mHourSpinnerInput = (EditText) mHourSpinner.findViewById(R.id.np__numberpicker_input);
    mHourSpinnerInput.setImeOptions(EditorInfo.IME_ACTION_NEXT);

    // divider (only for the new widget style)
    mDivider = (TextView) findViewById(R.id.divider);
    if (mDivider != null) {
        mDivider.setText(R.string.time_picker_separator);
    }

    // minute
    mMinuteSpinner = (NumberPicker) findViewById(R.id.minute);
    mMinuteSpinner.setMinValue(0);
    mMinuteSpinner.setMaxValue(59);
    mMinuteSpinner.setOnLongPressUpdateInterval(100);
    mMinuteSpinner.setFormatter(NumberPicker.getTwoDigitFormatter());
    mMinuteSpinner.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        public void onValueChange(NumberPicker spinner, int oldVal, int newVal) {
            updateInputState();
            int minValue = mMinuteSpinner.getMinValue();
            int maxValue = mMinuteSpinner.getMaxValue();
            if (oldVal == maxValue && newVal == minValue) {
                int newHour = mHourSpinner.getValue() + 1;
                if (!is24HourView() && newHour == HOURS_IN_HALF_DAY) {
                    mIsAm = !mIsAm;
                    updateAmPmControl();
                }
                mHourSpinner.setValue(newHour);
            } else if (oldVal == minValue && newVal == maxValue) {
                int newHour = mHourSpinner.getValue() - 1;
                if (!is24HourView() && newHour == HOURS_IN_HALF_DAY - 1) {
                    mIsAm = !mIsAm;
                    updateAmPmControl();
                }
                mHourSpinner.setValue(newHour);
            }
            onTimeChanged();
        }
    });
    mMinuteSpinnerInput = (EditText) mMinuteSpinner.findViewById(R.id.np__numberpicker_input);
    mMinuteSpinnerInput.setImeOptions(EditorInfo.IME_ACTION_NEXT);

    /* Get the localized am/pm strings and use them in the spinner */
    mAmPmStrings = new DateFormatSymbols().getAmPmStrings();

    // am/pm
    View amPmView = findViewById(R.id.amPm);
    if (amPmView instanceof Button) {
        mAmPmSpinner = null;
        mAmPmSpinnerInput = null;
        mAmPmButton = (Button) amPmView;
        mAmPmButton.setOnClickListener(new OnClickListener() {
            public void onClick(View button) {
                button.requestFocus();
                mIsAm = !mIsAm;
                updateAmPmControl();
                onTimeChanged();
            }
        });
    } else {
        mAmPmButton = null;
        mAmPmSpinner = (NumberPicker) amPmView;
        mAmPmSpinner.setMinValue(0);
        mAmPmSpinner.setMaxValue(1);
        mAmPmSpinner.setDisplayedValues(mAmPmStrings);
        mAmPmSpinner.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
            public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
                updateInputState();
                picker.requestFocus();
                mIsAm = !mIsAm;
                updateAmPmControl();
                onTimeChanged();
            }
        });
        mAmPmSpinnerInput = (EditText) mAmPmSpinner.findViewById(R.id.np__numberpicker_input);
        mAmPmSpinnerInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
    }

    // update controls to initial state
    updateHourControl();
    updateAmPmControl();

    setOnTimeChangedListener(NO_OP_CHANGE_LISTENER);

    // set to current time
    setCurrentHour(mTempCalendar.get(Calendar.HOUR_OF_DAY));
    setCurrentMinute(mTempCalendar.get(Calendar.MINUTE));

    if (!isEnabled()) {
        setEnabled(false);
    }

    // set the content descriptions
    setContentDescriptions();

    // If not explicitly specified this view is important for accessibility.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN
            && getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
}

From source file:com.cmput301.recipebot.ui.AbstractRecipeActivity.java

/**
 * A method that fills a {@link LinearLayout} with data from a List of data.
 * We don't use {@link android.widget.ListView} since we don't need scrolling, our {@link android.widget.ScrollView} handles
 * that for us.// w ww . j ava 2s .co m
 *
 * @param listDirections the layout to fill
 * @param dataset        the data that should be displayed.
 */
protected void fillListLayout(LinearLayout listDirections, List dataset, int type) {
    LayoutInflater layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //Sanitize the view
    listDirections.removeAllViews();

    for (int i = 0; i < dataset.size(); i++) {
        Object data = dataset.get(i);
        CheckBox checkBox = (CheckBox) layoutInflater.inflate(R.layout.checkbox_view, null);
        checkBox.setText(data.toString());
        TaggedItem item = new TaggedItem();
        item.type = type;
        item.data = data;
        checkBox.setTag(item);
        checkBox.setOnCheckedChangeListener(this);
        listDirections.addView(checkBox, i);
    }
}

From source file:com.example.testtab.fragment.TwitEyesPageFragment.java

/**
 * Factory method for this fragment class. Constructs a new fragment for the given page number.
 *//*from  w w  w  .  j a  v a2s . co m*/
public static TwitEyesPageFragment create(int pageNumber, Context context) {
    // Gallery ------------------------------------ //
    mContext = context;

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

    TwitEyesPageFragment fragment = new TwitEyesPageFragment();
    Bundle args = new Bundle();
    args.putInt(ARG_PAGE, pageNumber);
    fragment.setArguments(args);
    return fragment;
}

From source file:com.directionalviewpager.DirectionalPagerAdapter.java

public DirectionalPagerAdapter(Context context, OnClickListener onClickListener) {
    mContext = context;/*from w  w  w .ja  va2  s .  co m*/
    mOnClickListener = onClickListener;
    mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

From source file:it.crs4.most.ehrlib.widgets.InnerArchetypeWidget.java

private void buildInnerArchetypeView() {
    LayoutInflater inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.inner_archetype, null);

    _root_view = view;/*from   ww  w.  j a v  a2  s. co m*/

    _archetype_layout = (LinearLayout) _root_view.findViewById(R.id.archetype_container);

    _title = (TextView) _root_view.findViewById(R.id.txt_archetype_title);

    addRemWidgets = (ImageView) _root_view.findViewById(R.id.image_toggle_widgets);
    addRemWidgets.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (areWidgetsVisible)
                removeWidgets();
            else
                addWidgets();

        }
    });

}

From source file:com.hoteltrip.android.util.NumberPicker.java

@SuppressWarnings({ "UnusedDeclaration" })
public NumberPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    setOrientation(VERTICAL);/*  ww  w. j a  v a2  s .c  om*/
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.number_picker, this, true);
    mHandler = new Handler();
    InputFilter inputFilter = new NumberPickerInputFilter();
    mNumberInputFilter = new NumberRangeKeyListener();
    mIncrementButton = (NumberPickerButton) findViewById(R.id.increment);
    mIncrementButton.setOnClickListener(this);
    mIncrementButton.setOnLongClickListener(this);
    mIncrementButton.setNumberPicker(this);
    mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement);
    mDecrementButton.setOnClickListener(this);
    mDecrementButton.setOnLongClickListener(this);
    mDecrementButton.setNumberPicker(this);

    mText = (EditText) findViewById(R.id.timepicker_input);
    mText.setTypeface(Utils.getHelveticaNeue(context));
    mText.setOnFocusChangeListener(this);
    mText.setOnEditorActionListener(this);
    mText.setFilters(new InputFilter[] { inputFilter });
    mText.setRawInputType(InputType.TYPE_CLASS_NUMBER);

    if (!isEnabled()) {
        setEnabled(false);
    }

    mText.setFocusable(false);
    mText.setFocusableInTouchMode(false);

    // TypedArray a = context.obtainStyledAttributes( attrs,
    // R.styleable.numberpicker );
    // mStart = a.getInt( R.styleable.numberpicker_startRange, DEFAULT_MIN
    // );
    // mEnd = a.getInt( R.styleable.numberpicker_endRange, DEFAULT_MAX );
    // mWrap = a.getBoolean( R.styleable.numberpicker_wrap, DEFAULT_WRAP );
    // mCurrent = a.getInt( R.styleable.numberpicker_defaultValue,
    // DEFAULT_VALUE );
    mCurrent = Math.max(mStart, Math.min(mCurrent, mEnd));
    mText.setText("" + mCurrent);
}

From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    experimentProviderUtil = new ExperimentProviderUtil(this);
    experiment = getExperimentFromIntent();
    if (experiment == null) {
        displayNoExperimentMessage();/*  w  w w .j  a  v a  2s  .  com*/
    } else {
        getSignallingData();

        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        optionsMenu = new OptionsMenu(this, getIntent().getData(),
                scheduledTime != null && scheduledTime != 0L);

        mainLayout = (LinearLayout) inflater.inflate(R.layout.experiment_executor_custom_rendering, null);
        setContentView(mainLayout);

        // webRecommended layout pieces
        ((LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE))
                .inflate(R.layout.experiment_web_recommended_buttons, mainLayout, true);
        buttonView = findViewById(R.id.ExecutorButtonLayout);
        buttonView.setVisibility(View.GONE);

        warningText = (TextView) findViewById(R.id.webRecommendedWarningText);
        warningText.setText(warningText.getText() + getString(R.string.use_browser) + "http://"
                + getString(R.string.about_weburl));

        doOnWebButton = (Button) findViewById(R.id.DoOnWebButtonButton);
        doOnWebButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                deleteNotification();
                finish();
            }
        });

        //render
        if (experiment.isWebRecommended()) {
            renderWebRecommendedMessage();
        } else {
            showForm(savedInstanceState);
        }
    }

}

From source file:com.meetingninja.csse.agenda.ReviewAgendaActivity.java

/**
 * Set up the {@link android.app.ActionBar}.
 *//*from   w  w w.  jav  a  2  s .  com*/
private void setupActionBar() {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    // Make an Ok/Cancel ActionBar
    View actionBarButtons = inflater.inflate(R.layout.actionbar_comment_accept, new LinearLayout(this), false);

    View cancelActionView = actionBarButtons.findViewById(R.id.action_comment);
    cancelActionView.setOnClickListener(mActionBarListener);

    View doneActionView = actionBarButtons.findViewById(R.id.action_done);
    doneActionView.setOnClickListener(mActionBarListener);

    getActionBar().setHomeButtonEnabled(false);
    getActionBar().setDisplayShowHomeEnabled(false);
    getActionBar().setDisplayHomeAsUpEnabled(false);
    getActionBar().setDisplayShowTitleEnabled(false);

    getActionBar().setDisplayShowCustomEnabled(true);
    getActionBar().setCustomView(actionBarButtons);
    // end Ok-Cancel ActionBar
}

From source file:com.google.samples.apps.abelana.LoginActivity.java

private void displayDialog() {
    // Build the about body view and append the link to see OSS licenses
    SpannableStringBuilder aboutBody = new SpannableStringBuilder();
    aboutBody.append(Html.fromHtml(getString(R.string.splash_dialog_body)));

    LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    TextView aboutBodyView = (TextView) layoutInflater.inflate(R.layout.dialog_about, null);
    aboutBodyView.setText(aboutBody);// ww  w.jav a2s.com
    aboutBodyView.setMovementMethod(new LinkMovementMethod());
    new AlertDialog.Builder(this).setTitle(getString(R.string.splash_dialog_title)).setView(aboutBodyView)
            .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    dialog.dismiss();
                }
            }).show();
}