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:com.actionbarsherlock.internal.view.menu.ListMenuItemView.java

private LayoutInflater getInflater() {
    if (mInflater == null) {
        mInflater = LayoutInflater.from(mContext);
    }
    return mInflater;
}

From source file:com.meetingninja.csse.MainActivity.java

private void setupRightDrawer(Schedule sched) {
    rightDrawerList.setPinnedHeaderView(
            LayoutInflater.from(this).inflate(R.layout.list_item_schedule_header, rightDrawerList, false));
    rightDrawerAdapter = new ScheduleAdapter(MainActivity.this, sched);
    rightDrawerList.setAdapter(rightDrawerAdapter);
    rightDrawerAdapter.notifyDataSetChanged();
}

From source file:com.trailbehind.android.iburn.map.MapActivity.java

protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_ABOUT:
        final ScrollView dialogView = (ScrollView) LayoutInflater.from(getBaseContext())
                .inflate(R.layout.about_dialog, null);
        final TextView aboutText = (TextView) dialogView.findViewById(R.id.message);
        aboutText.setText(Utils.getAboutText(getBaseContext()));

        final String title = getString(R.string.title_dialog_about) + " " + getString(R.string.app_name);
        return new AlertDialog.Builder(this).setView(dialogView).setIcon(R.drawable.icon).setTitle(title)
                .setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                    }/*from  w w  w  .j  a  v  a2  s . c  o m*/
                }).create();
    case DIALOG_NO_INTERNET_DOWNLOAD:
        return new AlertDialog.Builder(MapActivity.this).setTitle(R.string.title_dialog_error)
                .setMessage(R.string.error_no_internet_download)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        removeDialog(DIALOG_NO_INTERNET_DOWNLOAD);
                    }
                }).create();
    case DIALOG_SDCARD_NOT_AVAILABLE:
        return new AlertDialog.Builder(this).setIcon(R.drawable.ic_dialog_menu_generic)
                .setTitle(R.string.title_dialog_error).setMessage(R.string.error_sd_not_available)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        removeDialog(DIALOG_SDCARD_NOT_AVAILABLE);
                    }
                }).create();
    case DIALOG_DOWNLOAD_PROGRESS:
        mProgressDialog = new ProgressDialog(MapActivity.this);
        mProgressDialog.setTitle(R.string.title_dialog_download);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setButton(getText(android.R.string.cancel), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                removeDialog(DIALOG_DOWNLOAD_PROGRESS);
                for (int i = 0, len = mMapDownloadThreads.length; i < len; i++) {
                    MapDownloadThread t = mMapDownloadThreads[i];
                    if (t != null) {
                        t.cancel();
                    }
                    mMapDownloadThreads[i] = null;
                }

                mFileCacheWriter.stopRunning();
                mFileCacheWriter = null;
            }
        });
        return mProgressDialog;
    case DIALOG_DOWNLOAD_ERROR:
        return new AlertDialog.Builder(MapActivity.this).setIcon(R.drawable.ic_dialog_menu_generic)
                .setTitle(R.string.title_dialog_error).setMessage(mErrorMsgId)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        removeDialog(DIALOG_SDCARD_NOT_AVAILABLE);
                    }
                }).create();
    default:
        return null;
    }
}

From source file:com.bonsai.wallet32.SweepKeyActivity.java

private void addAccountRow(TableLayout table, int acctId, String acctName, long btc, double fiat) {
    TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.receive_to_row, table, false);

    RadioButton tv0 = (RadioButton) row.findViewById(R.id.to_account);
    tv0.setId(acctId); // Change id to the acctId.
    tv0.setText(acctName);//from ww w. j a  v a  2s  .c  o  m
    tv0.setOnCheckedChangeListener(mReceiveToListener);
    if (acctId == mAccountId)
        tv0.setChecked(true);

    TextView tv1 = (TextView) row.findViewById(R.id.row_btc);
    tv1.setText(String.format("%s", mBTCFmt.formatCol(btc, 0, true, true)));

    TextView tv2 = (TextView) row.findViewById(R.id.row_fiat);
    tv2.setText(String.format("%.02f", fiat));

    table.addView(row);
}

From source file:com.insthub.O2OMobile.Activity.F9_SettingActivity.java

private void showDialog() {
    LayoutInflater inflater = LayoutInflater.from(this);
    View view = inflater.inflate(R.layout.photo_dialog, null);
    mDialog = new Dialog(this, R.style.dialog);
    mDialog.setContentView(view);//from www  .  j a v  a 2 s  .c om

    mDialog.setCanceledOnTouchOutside(true);
    mDialog.show();
    LinearLayout requsetCameraLayout = (LinearLayout) view.findViewById(R.id.register_camera);
    LinearLayout requestPhotoLayout = (LinearLayout) view.findViewById(R.id.register_photo);

    requsetCameraLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mDialog.dismiss();
            if (mFileDir == null) {
                mFileDir = new File(O2OMobileAppConst.FILEPATH + "img/");
                if (!mFileDir.exists()) {
                    mFileDir.mkdirs();
                }
            }
            mFileName = O2OMobileAppConst.FILEPATH + "img/" + "temp.jpg";
            mFile = new File(mFileName);
            Uri imageuri = Uri.fromFile(mFile);
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, imageuri);
            intent.putExtra("return-data", false);
            startActivityForResult(intent, REQUEST_CAMERA);
        }
    });

    requestPhotoLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            mDialog.dismiss();
            Intent picture = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(picture, REQUEST_PHOTO);

        }
    });
}

From source file:goo.TeaTimer.TimerActivity.java

/** { @inheritDoc} */
@Override/*from  www  .  ja va2  s.  c om*/
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case PREF:
        startActivity(new Intent(this, TimerPrefActivity.class));
        break;

    case ABOUT:
        //new TimerAboutDialog(this).show();
        //break;
        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.about, null);

        Builder p = new AlertDialog.Builder(this).setView(view);
        final AlertDialog alrt = p.create();
        alrt.setIcon(R.drawable.icon);
        alrt.setTitle(mImgUrl);
        alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.close),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                    }
                });
        alrt.show();
        return true;

    default:
        return false;
    }
    return true;
}

From source file:android.support.v7.preference.PreferenceGroupAdapter.java

@Override
public PreferenceViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    final PreferenceLayout pl = mPreferenceLayouts.get(viewType);
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    TypedArray a = parent.getContext().obtainStyledAttributes(null, R.styleable.BackgroundStyle);
    Drawable background = a.getDrawable(R.styleable.BackgroundStyle_android_selectableItemBackground);
    if (background == null) {
        background = parent.getContext().getResources()
                .getDrawable(android.R.drawable.list_selector_background);
    }//  w  ww  .  j a v  a 2  s  .c om
    a.recycle();

    final View view = inflater.inflate(pl.resId, parent, false);
    if (view.getBackground() == null) {
        ViewCompat.setBackground(view, background);
    }

    final ViewGroup widgetFrame = (ViewGroup) view.findViewById(android.R.id.widget_frame);
    if (widgetFrame != null) {
        if (pl.widgetResId != 0) {
            inflater.inflate(pl.widgetResId, widgetFrame);
        } else {
            widgetFrame.setVisibility(View.GONE);
        }
    }

    return new PreferenceViewHolder(view);
}

From source file:com.allwinner.theatreplayer.launcher.activity.LaunchActivity.java

@SuppressLint("InflateParams")
private void initViewPager() {
    // mCellInfoList = new ArrayList<CellInfo>();
    inflater = LayoutInflater.from(this);
    mCellViews = new ArrayList<CellViews>();
    mPageViews = new ArrayList<View>();
    mLayoutTraverserUtil = new LayoutTraverserUtil();
    mMatchLayoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    Category category = null;/*from   ww w .j a  v  a 2 s  .c om*/
    int categoryCount = mCategoryList.size();
    //      Log.i("jim", "categoryCount size = "+categoryCount);

    for (int i = 0; i < categoryCount; i++) {
        category = mCategoryList.get(i);
        if (category != null) {
            addTopTextView(category.headline, categoryCount, i);
            addScreenLayout(category.type, category.cellInfoList.size());

            //            Log.i("jim", "category.headline = "+category.headline);
            //            Log.i("jim", "category.type = "+category.type);
            //            Log.i("jim", "category.cellInfoList.size() = "+category.cellInfoList.size());
            // mCellInfoList.addAll(category.cellInfoList);
        }
    }
    mCellViews = mLayoutTraverserUtil.getCellViewsList();
    mPageCount = mPageViews.size();
    mViewPager = (ViewPager) findViewById(R.id.viewpager);
    mViewPager.setAdapter(mPagerAdapter);
    mViewPager.setOffscreenPageLimit(mPageCount);
    mViewPager.setOnPageChangeListener(this);
}

From source file:be.blinkt.openvpn.views.PagerSlidingTabStrip.java

public void notifyDataSetChanged() {
    tabsContainer.removeAllViews();/*from ww w .j a  v  a  2 s  .  com*/
    tabCount = pager.getAdapter().getCount();
    View tabView;
    for (int i = 0; i < tabCount; i++) {

        if (pager.getAdapter() instanceof CustomTabProvider) {
            tabView = ((CustomTabProvider) pager.getAdapter()).getCustomTabView(this, i);
        } else {
            tabView = LayoutInflater.from(getContext()).inflate(R.layout.padersliding_tab, this, false);
        }

        CharSequence title = pager.getAdapter().getPageTitle(i);

        addTab(i, title, tabView);
    }

    updateTabStyles();
    getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @SuppressWarnings("deprecation")
        @SuppressLint("NewApi")
        @Override
        public void onGlobalLayout() {

            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                getViewTreeObserver().removeGlobalOnLayoutListener(this);
            } else {
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }

            currentPosition = pager.getCurrentItem();
            currentPositionOffset = 0f;
            scrollToChild(currentPosition, 0);
            updateSelection(currentPosition);
        }
    });
}

From source file:com.CloudRecognition.CloudReco.java

private void startLoadingAnimation() {
    // Inflates the Overlay Layout to be displayed above the Camera View
    LayoutInflater inflater = LayoutInflater.from(this);
    mUILayout = (RelativeLayout) inflater.inflate(R.layout.camera_overlay, null, false);

    mUILayout.setVisibility(View.VISIBLE);
    mUILayout.setBackgroundColor(Color.BLACK);

    // By default
    loadingDialogHandler.setContenido(mUILayout);

    loadingDialogHandler.mLoadingDialogContainer.setVisibility(View.VISIBLE);

    addContentView(mUILayout, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

}