Search in sources :

Example 26 with LayoutInflater

use of android.view.LayoutInflater in project GreenDroid by cyrilmottier.

the class QuickActionBar method populateQuickActions.

@Override
protected void populateQuickActions(List<QuickAction> quickActions) {
    mQuickActions = quickActions;
    final LayoutInflater inflater = LayoutInflater.from(getContext());
    for (QuickAction action : quickActions) {
        TextView view = (TextView) inflater.inflate(R.layout.gd_quick_action_bar_item, mQuickActionItems, false);
        view.setText(action.mTitle);
        view.setCompoundDrawablesWithIntrinsicBounds(null, action.mDrawable, null, null);
        view.setOnClickListener(mClickHandlerInternal);
        mQuickActionItems.addView(view);
        action.mView = new WeakReference<View>(view);
    }
}
Also used : LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) HorizontalScrollView(android.widget.HorizontalScrollView) TextView(android.widget.TextView) View(android.view.View)

Example 27 with LayoutInflater

use of android.view.LayoutInflater in project GreenDroid by cyrilmottier.

the class QuickActionGrid method populateQuickActions.

@Override
protected void populateQuickActions(final List<QuickAction> quickActions) {
    mGridView.setAdapter(new BaseAdapter() {

        public View getView(int position, View view, ViewGroup parent) {
            TextView textView = (TextView) view;
            if (view == null) {
                final LayoutInflater inflater = LayoutInflater.from(getContext());
                textView = (TextView) inflater.inflate(R.layout.gd_quick_action_grid_item, mGridView, false);
            }
            QuickAction quickAction = quickActions.get(position);
            textView.setText(quickAction.mTitle);
            textView.setCompoundDrawablesWithIntrinsicBounds(null, quickAction.mDrawable, null, null);
            return textView;
        }

        public long getItemId(int position) {
            return position;
        }

        public Object getItem(int position) {
            return null;
        }

        public int getCount() {
            return quickActions.size();
        }
    });
    mGridView.setOnItemClickListener(mInternalItemClickListener);
}
Also used : ViewGroup(android.view.ViewGroup) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) BaseAdapter(android.widget.BaseAdapter) GridView(android.widget.GridView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 28 with LayoutInflater

use of android.view.LayoutInflater in project GreenDroid by cyrilmottier.

the class SegmentedBar method addSegment.

/**
     * Adds a segment to the SegmentBar. This method automatically adds a
     * divider if needed.
     * 
     * @param title The title of the segment to add.
     */
public void addSegment(String title) {
    final Context context = getContext();
    final LayoutInflater inflater = LayoutInflater.from(context);
    /*
         * First of all, we have to check whether or not we need to add a
         * divider. A divider is added when there is at least one segment
         */
    if (mDividerDrawable != null && getSegmentCount() > 0) {
        ImageView divider = new ImageView(context);
        final int width = (mDividerWidth > 0) ? mDividerWidth : mDividerDrawable.getIntrinsicWidth();
        final LinearLayout.LayoutParams lp = new LayoutParams(width, LayoutParams.FILL_PARENT);
        lp.setMargins(0, 0, 0, 0);
        divider.setLayoutParams(lp);
        divider.setBackgroundDrawable(mDividerDrawable);
        addView(divider);
    }
    CheckBox segment = (CheckBox) inflater.inflate(R.layout.gd_segment, this, false);
    segment.setText(title);
    segment.setClickable(true);
    segment.setFocusable(true);
    segment.setOnFocusChangeListener(this);
    segment.setOnCheckedChangeListener(new SegmentCheckedListener(getSegmentCount()));
    segment.setOnClickListener(new SegmentClickedListener(getSegmentCount()));
    addView(segment);
}
Also used : Context(android.content.Context) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Example 29 with LayoutInflater

use of android.view.LayoutInflater in project FlexibleAdapter by davideas.

the class FastScroller method setViewsToUse.

/**
	 * Layout customization.<br/>
	 * Color for Selected State is the color defined inside the Drawables.
	 *
	 * @param layoutResId Main layout of Fast Scroller
	 * @param bubbleResId Drawable resource for Bubble containing the Text
	 * @param handleResId Drawable resource for the Handle
	 */
public void setViewsToUse(@LayoutRes int layoutResId, @IdRes int bubbleResId, @IdRes int handleResId) {
    //Already inflated
    if (bubble != null)
        return;
    LayoutInflater inflater = LayoutInflater.from(getContext());
    inflater.inflate(layoutResId, this, true);
    bubble = (TextView) findViewById(bubbleResId);
    if (bubble != null)
        bubble.setVisibility(INVISIBLE);
    handle = (ImageView) findViewById(handleResId);
}
Also used : LayoutInflater(android.view.LayoutInflater)

Example 30 with LayoutInflater

use of android.view.LayoutInflater in project Libraries-for-Android-Developers by eoecn.

the class ActionBarContextView method initTitle.

private void initTitle() {
    if (mTitleLayout == null) {
        LayoutInflater inflater = LayoutInflater.from(getContext());
        inflater.inflate(R.layout.abs__action_bar_title_item, this);
        mTitleLayout = (LinearLayout) getChildAt(getChildCount() - 1);
        mTitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_title);
        mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.abs__action_bar_subtitle);
        if (mTitleStyleRes != 0) {
            mTitleView.setTextAppearance(mContext, mTitleStyleRes);
        }
        if (mSubtitleStyleRes != 0) {
            mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes);
        }
    }
    mTitleView.setText(mTitle);
    mSubtitleView.setText(mSubtitle);
    final boolean hasTitle = !TextUtils.isEmpty(mTitle);
    final boolean hasSubtitle = !TextUtils.isEmpty(mSubtitle);
    mSubtitleView.setVisibility(hasSubtitle ? VISIBLE : GONE);
    mTitleLayout.setVisibility(hasTitle || hasSubtitle ? VISIBLE : GONE);
    if (mTitleLayout.getParent() == null) {
        addView(mTitleLayout);
    }
}
Also used : LayoutInflater(android.view.LayoutInflater)

Aggregations

LayoutInflater (android.view.LayoutInflater)1227 View (android.view.View)743 TextView (android.widget.TextView)570 ImageView (android.widget.ImageView)242 ViewGroup (android.view.ViewGroup)127 Context (android.content.Context)123 ListView (android.widget.ListView)115 LinearLayout (android.widget.LinearLayout)102 AdapterView (android.widget.AdapterView)94 RecyclerView (android.support.v7.widget.RecyclerView)87 Intent (android.content.Intent)81 DialogInterface (android.content.DialogInterface)74 AlertDialog (android.app.AlertDialog)71 FrameLayout (android.widget.FrameLayout)48 TypedArray (android.content.res.TypedArray)43 OnClickListener (android.view.View.OnClickListener)40 Button (android.widget.Button)40 Bundle (android.os.Bundle)39 Activity (android.app.Activity)38 AlertDialog (android.support.v7.app.AlertDialog)37