Example usage for android.view LayoutInflater from

List of usage examples for android.view LayoutInflater from

Introduction

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

Prototype

public static LayoutInflater from(Context context) 

Source Link

Document

Obtains the LayoutInflater from the given context.

Usage

From source file:it.scoppelletti.mobilepower.widget.DateControl.java

/**
 * Inizializzazione.//w ww  .  j a  v a 2  s  .com
 * 
 * @param ctx Contesto.
 */
private void init(Context ctx) {
    View view;
    ImageButton cmd;
    LayoutInflater inflater;

    inflater = LayoutInflater.from(ctx);
    view = inflater.inflate(R.layout.datecontrol, this, false);
    addView(view);

    myValueControl = (EditText) findViewById(R.id.txt_value);
    myValueControl.setKeyListener(null);

    cmd = (ImageButton) findViewById(R.id.cmd_set);
    cmd.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            onSetClick();
        }
    });

    setValue(SimpleDate.NIL);

    cmd = (ImageButton) findViewById(R.id.cmd_reset);
    if (myIsResetEnabled) {
        cmd.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                setValue(SimpleDate.NIL);
            }
        });
    } else {
        cmd.setVisibility(View.GONE);
    }
}

From source file:ayushi.view.adapter.ShoppingListAdapter.java

@Override
public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_product_list, parent, false);
    ItemViewHolder itemViewHolder = new ItemViewHolder(view);
    return itemViewHolder;
}

From source file:android_network.hetnet.vpn_service.AdapterAccess.java

@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
    return LayoutInflater.from(context).inflate(R.layout.access, parent, false);
}

From source file:android.support.design.internal.BottomNavigationItemView.java

public BottomNavigationItemView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    final Resources res = getResources();
    int inactiveLabelSize = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_text_size);
    int activeLabelSize = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_active_text_size);
    mDefaultMargin = res.getDimensionPixelSize(R.dimen.design_bottom_navigation_margin);
    mShiftAmount = inactiveLabelSize - activeLabelSize;
    mScaleUpFactor = 1f * activeLabelSize / inactiveLabelSize;
    mScaleDownFactor = 1f * inactiveLabelSize / activeLabelSize;

    LayoutInflater.from(context).inflate(R.layout.design_bottom_navigation_item, this, true);
    setBackgroundResource(R.drawable.design_bottom_navigation_item_background);
    mIcon = (ImageView) findViewById(R.id.icon);
    mSmallLabel = (TextView) findViewById(R.id.smallLabel);
    mLargeLabel = (TextView) findViewById(R.id.largeLabel);
}

From source file:arun.com.chromer.shared.views.TabView.java

private void init(@NonNull Context context, @TabType int tabType) {
    mTabType = tabType;//from   ww  w .  j  av a 2  s. c o m
    addView(LayoutInflater.from(context).inflate(R.layout.widget_tab_view_layout, this, false));
    ButterKnife.bind(this);
    switch (mTabType) {
    case TAB_TYPE_OPTIONS:
        tabIcon.setImageDrawable(new IconicsDrawable(getContext()).icon(CommunityMaterial.Icon.cmd_settings)
                .color(SELECTED_COLOR).sizeDp(23));
        text.setText(R.string.options);
        text.setTextColor(SELECTED_COLOR);
        break;
    case TAB_TYPE_WEB_HEADS:
        tabIcon.setImageDrawable(new IconicsDrawable(getContext()).icon(CommunityMaterial.Icon.cmd_chart_bubble)
                .color(UN_SELECTED_COLOR).sizeDp(23));
        text.setText(R.string.web_heads);
        text.setTextColor(UN_SELECTED_COLOR);
        break;
    case TAB_TYPE_CUSTOMIZE:
        tabIcon.setImageDrawable(new IconicsDrawable(getContext()).icon(CommunityMaterial.Icon.cmd_format_paint)
                .color(UN_SELECTED_COLOR).sizeDp(23));
        text.setText(R.string.customize);
        text.setTextColor(UN_SELECTED_COLOR);
        break;
    }
    getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            int totalWidth = tabIcon.getWidth() + Utils.dpToPx(5) + text.getWidth();
            int layoutWidth = getWidth();
            initialIconX = (layoutWidth / 2) - (totalWidth / 2);
            tabIcon.setX(initialIconX);
            initialTextX = initialIconX + tabIcon.getWidth() + Utils.dpToPx(10);
            text.setX(initialTextX);

            text.setPivotX(0);
            text.setPivotY(text.getHeight() / 2);
            // Refresh animations
            setSelected(selected);
            getViewTreeObserver().removeOnGlobalLayoutListener(this);
        }
    });
}

From source file:aws.apps.usbDeviceEnumerator.ui.usbinfo.LinuxUsbInfoFragment.java

@Override
public void onViewCreated(View view, Bundle bundle) {
    super.onViewCreated(view, bundle);

    if (validData) {
        viewHolder = new InfoViewHolder(view);
        populateDataTable(LayoutInflater.from(getContext()));
    } else {// w  ww  .  j  a v  a2 s .c  om
        final TextView textView = (TextView) view.findViewById(R.id.errorText);
        textView.setText(R.string.error_loading_device_info_unknown);
    }
}

From source file:android.support.design.internal.NavigationMenuItemView.java

public NavigationMenuItemView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setOrientation(HORIZONTAL);//from   www  .  j  av  a  2s .  co m
    LayoutInflater.from(context).inflate(R.layout.design_navigation_menu_item, this, true);
    mIconSize = context.getResources().getDimensionPixelSize(R.dimen.design_navigation_icon_size);
    mTextView = (CheckedTextView) findViewById(R.id.design_menu_item_text);
    mTextView.setDuplicateParentStateEnabled(true);
    ViewCompat.setAccessibilityDelegate(mTextView, mAccessibilityDelegate);
}

From source file:com.actionbarsherlock.internal.view.menu.BaseMenuPresenter.java

/**
 * Construct a new BaseMenuPresenter./*from w ww . j  a  va2s . com*/
 *
 * @param context Context for generating system-supplied views
 * @param menuLayoutRes Layout resource ID for the menu container view
 * @param itemLayoutRes Layout resource ID for a single item view
 */
public BaseMenuPresenter(Context context, int menuLayoutRes, int itemLayoutRes) {
    mSystemContext = context;
    mSystemInflater = LayoutInflater.from(context);
    mMenuLayoutRes = menuLayoutRes;
    mItemLayoutRes = itemLayoutRes;
}

From source file:com.redhorse.quickstart.AppConfig.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    dbStart = new dbStartConfigAdapter(this);
    dbStart.open();// ww w  .  ja va2  s.c om

    loadApps(); // do this in onresume?

    setContentView(R.layout.applist);
    TabHost mTabHost = (TabHost) findViewById(R.id.tabhost);
    mTabHost.setup();
    LayoutInflater inflater_tab1 = LayoutInflater.from(this);
    inflater_tab1.inflate(R.layout.grid1, mTabHost.getTabContentView());
    inflater_tab1.inflate(R.layout.grid2, mTabHost.getTabContentView());
    mTabHost.addTab(mTabHost.newTabSpec("tab_test1")
            .setIndicator("", getResources().getDrawable(R.drawable.btn_add)).setContent(R.id.list1));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test2")
            .setIndicator("", getResources().getDrawable(R.drawable.btn_remove)).setContent(R.id.list2));
    mList = (GridView) findViewById(R.id.list1);
    mList.setAdapter(new AppsAdapter());
    mList.setOnItemClickListener(Grid1ItemClickListener);
    mList2 = (GridView) findViewById(R.id.list2);
    mList2.setAdapter(new AppsAdapter2());
    mList2.setOnItemClickListener(Grid2ItemClickListener);
    Button button = (Button) findViewById(R.id.Button01);
    button.setOnClickListener(Button01Listener);
    button = (Button) findViewById(R.id.Button02);
    button.setOnClickListener(Button02Listener);
    button = (Button) findViewById(R.id.weibolist);
    button.setOnClickListener(weibolistListener);
}

From source file:at.jclehner.rxdroid.DoseView.java

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

    LayoutInflater.from(context).inflate(R.layout.dose_view, this, true);

    mIntakeStatus = (ImageView) findViewById(R.id.icon_intake_status);
    mDoseText = (TextView) findViewById(R.id.text_dose);
    mDoseTimeIcon = (ImageView) findViewById(R.id.icon_dose_time);

    switch (getId()) {
    case R.id.morning:
        setDoseTime(Drug.TIME_MORNING);//w ww. j  a v  a2 s.c  om
        break;

    case R.id.noon:
        setDoseTime(Drug.TIME_NOON);
        break;

    case R.id.evening:
        setDoseTime(Drug.TIME_EVENING);
        break;

    case R.id.night:
        setDoseTime(Drug.TIME_NIGHT);
        break;

    // XXX
    /*case R.id.bed:
    mDoseTimeIcon.setImageResource(R.drawable.ic_night_test);
    mDoseText.setText("-");
    break;*/
    // XXX
    }
}