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:base.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.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:org.youaretheone.website.client.UoneSearchGsonActivity.java

private static View createTabView(final Context context, final String text, int iconResource) {
    View view = LayoutInflater.from(context).inflate(R.layout.tabs_layout, null);
    TextView tv = (TextView) view.findViewById(R.id.tabsText);
    tv.setText(text);//from  w ww.  j  a va2 s.  co  m

    ImageView icon = (ImageView) view.findViewById(R.id.tabsIcon);
    icon.setImageResource(iconResource);

    return view;
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

@Override
public void setContentView(int resId) {
    ensureSubDecor();//w w  w  . j a v  a  2s. co  m
    ViewGroup contentParent = (ViewGroup) mSubDecor.findViewById(android.R.id.content);
    contentParent.removeAllViews();
    LayoutInflater.from(mContext).inflate(resId, contentParent);
    mOriginalWindowCallback.onContentChanged();
}

From source file:com.actionbarsherlock.internal.widget.ActionBarView.java

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

    // Background is always provided by the container.
    setBackgroundResource(0);/*  w w w  . j ava2s . c om*/

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SherlockActionBar, R.attr.actionBarStyle,
            0);

    ApplicationInfo appInfo = context.getApplicationInfo();
    PackageManager pm = context.getPackageManager();
    mNavigationMode = a.getInt(R.styleable.SherlockActionBar_navigationMode,
            ActionBar.NAVIGATION_MODE_STANDARD);
    mTitle = a.getText(R.styleable.SherlockActionBar_title);
    mSubtitle = a.getText(R.styleable.SherlockActionBar_subtitle);

    mLogo = a.getDrawable(R.styleable.SherlockActionBar_logo);
    if (mLogo == null) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            if (context instanceof Activity) {
                //Even though native methods existed in API 9 and 10 they don't work
                //so just parse the manifest to look for the logo pre-Honeycomb
                final int resId = loadLogoFromManifest((Activity) context);
                if (resId != 0) {
                    mLogo = context.getResources().getDrawable(resId);
                }
            }
        } else {
            if (context instanceof Activity) {
                try {
                    mLogo = pm.getActivityLogo(((Activity) context).getComponentName());
                } catch (NameNotFoundException e) {
                    Log.e(TAG, "Activity component name not found!", e);
                }
            }
            if (mLogo == null) {
                mLogo = appInfo.loadLogo(pm);
            }
        }
    }

    mIcon = a.getDrawable(R.styleable.SherlockActionBar_icon);
    if (mIcon == null) {
        if (context instanceof Activity) {
            try {
                mIcon = pm.getActivityIcon(((Activity) context).getComponentName());
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Activity component name not found!", e);
            }
        }
        if (mIcon == null) {
            mIcon = appInfo.loadIcon(pm);
        }
    }

    final LayoutInflater inflater = LayoutInflater.from(context);

    final int homeResId = a.getResourceId(R.styleable.SherlockActionBar_homeLayout,
            R.layout.abs__action_bar_home);

    mHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);

    mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);
    mExpandedHomeLayout.setUp(true);
    mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
    mExpandedHomeLayout.setContentDescription(getResources().getText(R.string.abs__action_bar_up_description));

    mTitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_titleTextStyle, 0);
    mSubtitleStyleRes = a.getResourceId(R.styleable.SherlockActionBar_subtitleTextStyle, 0);
    mProgressStyle = a.getResourceId(R.styleable.SherlockActionBar_progressBarStyle, 0);
    mIndeterminateProgressStyle = a.getResourceId(R.styleable.SherlockActionBar_indeterminateProgressStyle, 0);

    mProgressBarPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_progressBarPadding, 0);
    mItemPadding = a.getDimensionPixelOffset(R.styleable.SherlockActionBar_itemPadding, 0);

    setDisplayOptions(a.getInt(R.styleable.SherlockActionBar_displayOptions, DISPLAY_DEFAULT));

    final int customNavId = a.getResourceId(R.styleable.SherlockActionBar_customNavigationLayout, 0);
    if (customNavId != 0) {
        mCustomNavView = inflater.inflate(customNavId, this, false);
        mNavigationMode = ActionBar.NAVIGATION_MODE_STANDARD;
        setDisplayOptions(mDisplayOptions | ActionBar.DISPLAY_SHOW_CUSTOM);
    }

    mContentHeight = a.getLayoutDimension(R.styleable.SherlockActionBar_height, 0);

    a.recycle();

    mLogoNavItem = new ActionMenuItem(context, 0, android.R.id.home, 0, 0, mTitle);
    mHomeLayout.setOnClickListener(mUpClickListener);
    mHomeLayout.setClickable(true);
    mHomeLayout.setFocusable(true);
}

From source file:net.evecom.android.PublicOpinionlistActivity.java

/**
 * ListView""/* ww  w .  jav  a 2s. c o m*/
 */
private void addPageMore() {
    View view = LayoutInflater.from(this).inflate(R.layout.list_page_load, null);
    moreTextView = (TextView) view.findViewById(R.id.more_id);
    loadProgressBar = (LinearLayout) view.findViewById(R.id.load_id);
    listView.addFooterView(view);
    moreTextView.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            // ""
            moreTextView.setVisibility(View.GONE);
            // 
            loadProgressBar.setVisibility(View.VISIBLE);

            new Thread(new Runnable() {
                @Override
                public void run() {
                    // //3
                    // try {
                    // Thread.sleep(3000);
                    // } catch (InterruptedException e) {
                    // e.printStackTrace();
                    // }
                    //  
                    if (null != opinionPerson && opinionPerson.size() >= pageSize && search == false) {
                        chageListView(opinionPerson.size() + 1, pageSize + opinionPerson.size());

                    }
                    Message mes = handler.obtainMessage(pageType);
                    handler2.sendMessage(mes);
                }
            }).start();
        }
    });
}

From source file:net.internetTelephone.program.project.init.create.ProjectCreateFragment.java

private void showWarningDialog() {
    LayoutInflater factory = LayoutInflater.from(getActivity());
    final View textEntryView = factory.inflate(R.layout.init_dialog_text_entry2, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    AlertDialog dialog = builder.setTitle("??").setView(textEntryView)
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override//from  www .ja v a  2  s.  c  om
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).show();
}

From source file:au.org.ala.fielddata.mobile.CollectSurveyData.java

private void buildCustomActionBar() {
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayShowHomeEnabled(false);

    View customNav = LayoutInflater.from(this).inflate(R.layout.cancel_done, null);

    customNav.findViewById(R.id.action_done).setOnClickListener(customActionBarListener);
    customNav.findViewById(R.id.action_cancel).setOnClickListener(customActionBarListener);

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
            Gravity.FILL_HORIZONTAL);//from   w  ww  . j av  a2s.c  o m
    getSupportActionBar().setCustomView(customNav, params);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
}

From source file:cm.aptoide.pt.ApkInfo.java

@SuppressLint("NewApi")
private void loadElements(long id) {
    viewComments = (ViewGroup) findViewById(R.id.commentContainer);
    viewComments.removeAllViews();//from  w  w w. j  a v a2  s. co m
    viewLikes = (ViewGroup) findViewById(R.id.likesLayout);
    loading = LayoutInflater.from(context).inflate(R.layout.loadingfootercomments, null);
    viewComments.addView(loading, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    installString = getString(R.string.install);
    viewLikesButton = (ViewGroup) findViewById(R.id.ratings);
    ((TextView) viewLikes.findViewById(R.id.likes)).setText(context.getString(R.string.loading_likes));
    ((TextView) viewLikes.findViewById(R.id.dislikes)).setText("");

    findViewById(R.id.downloading_icon).setVisibility(View.GONE);
    findViewById(R.id.downloading_name).setVisibility(View.GONE);
    findViewById(R.id.download_progress).setVisibility(View.GONE);
    ProgressBar progress = (ProgressBar) findViewById(R.id.downloading_progress);
    progress.setIndeterminate(true);
    Bundle b = new Bundle();
    b.putLong("_id", id);

    //      findViewById(R.id.inst_version).setVisibility(View.VISIBLE);
    getSupportLoaderManager().restartLoader(20, b, new LoaderCallbacks<ViewApk>() {

        @Override
        public Loader<ViewApk> onCreateLoader(int arg0, final Bundle arg1) {
            pd.show();
            pd.setMessage(getString(R.string.please_wait));
            pd.setCancelable(false);
            return new ViewApkLoader(ApkInfo.this) {

                @Override
                public ViewApk loadInBackground() {
                    return db.getApk(arg1.getLong("_id"), category);
                }
            };

        }

        @Override
        public void onLoadFinished(Loader<ViewApk> arg0, ViewApk arg1) {
            //                AdView adView = (AdView)findViewById(R.id.adView);
            //                adView.loadAd(new AdRequest());

            mAdView = (MoPubView) findViewById(R.id.adview);
            mAdView.setAdUnitId(ApplicationAptoide.ADUNITID); // Enter your Ad Unit ID from www.mopub.com
            mAdView.loadAd();
            pd.dismiss();
            viewApk = arg1;
            new Thread(new Runnable() {
                @Override
                public void run() {
                    loadDescription();
                }
            }).start();

            mainObbUrl = viewApk.getMainObbUrl();
            mainObbMd5 = viewApk.getMainObbMd5();
            mainObbName = viewApk.getMainObbFileName();
            mainObbSize = viewApk.getMainObbFileSize();

            patchObbUrl = viewApk.getPatchObbUrl();
            patchObbMd5 = viewApk.getPatchObbMd5();
            patchObbName = viewApk.getPatchObbFileName();
            patchObbSize = viewApk.getPatchObbFileSize();

            if (viewApk.getLikes() != -1) {
                setLikes(viewApk.getLikes() + "", viewApk.getDislikes() + "");
            }

            if (viewApk.getComments().size() > 0) {
                setComments(viewApk.getComments());
                loading.setVisibility(View.GONE);
            }

            loadScreenshots();

            //viewApk.getWebservicePath

            int installedVercode = db.getInstalledAppVercode(viewApk.getApkid());

            if (installedVercode <= viewApk.getVercode() && installedVercode != 0) {
                findViewById(R.id.inst_version).setVisibility(View.VISIBLE);
                ((TextView) findViewById(R.id.inst_version)).setText(getString(R.string.installed_version)
                        + ": " + db.getInstalledAppVername(viewApk.getApkid()));
                if (installedVercode < viewApk.getVercode() && !getIntent().hasExtra("installed")) {
                    installString = getString(R.string.update);
                } else if (getIntent().hasExtra("installed")) {
                    installString = getString(R.string.open);
                }
                ((Button) findViewById(R.id.btinstall)).setText(installString);

            } else if (installedVercode > viewApk.getVercode()) {
                if (getIntent().hasExtra("installed")) {
                    installString = getString(R.string.open);
                } else {
                    installString = getString(R.string.install);

                }
                ((Button) findViewById(R.id.btinstall)).setText(installString);

                findViewById(R.id.inst_version).setVisibility(View.GONE);
            }

            if (installedVercode == viewApk.getVercode()) {
                if (getIntent().hasExtra("installed")) {
                    installString = getString(R.string.open);
                } else {
                    installString = getString(R.string.install);
                }
                ((Button) findViewById(R.id.btinstall)).setText(installString);
                findViewById(R.id.inst_version).setVisibility(View.GONE);
            }

            repo_string = viewApk.getRepoName();
            checkDownloadStatus();
            webservicespath = viewApk.getWebservicesPath();

            try {
                ((RatingBar) findViewById(R.id.ratingbar)).setRating(Float.parseFloat(viewApk.getRating()));
                ((RatingBar) findViewById(R.id.ratingbar)).setIsIndicator(true);
            } catch (Exception e) {
                ((RatingBar) findViewById(R.id.ratingbar)).setRating(0);
                ((RatingBar) findViewById(R.id.ratingbar)).setIsIndicator(true);
            }
            ((TextView) findViewById(R.id.app_store)).setText(getString(R.string.store) + ": " + repo_string);
            ((TextView) findViewById(R.id.versionInfo)).setText(getString(R.string.clear_dwn_title) + ": "
                    + viewApk.getDownloads() + " " + getString(R.string.size) + ": "
                    + withSuffix((Long.parseLong(viewApk.getSize()) * 1024 + mainObbSize + patchObbSize)));
            ((TextView) findViewById(R.id.version_label))
                    .setText(getString(R.string.version) + " " + viewApk.getVername());
            ((TextView) findViewById(R.id.app_name)).setText(viewApk.getName());
            //            ImageLoader imageLoader = ImageLoader.getInstance(context);
            //            imageLoader.DisplayImage(viewApk.getIcon(),(ImageView) findViewById(R.id.app_icon), context, (viewApk.getApkid()+"|"+viewApk.getVercode()));
            DisplayImageOptions options = new DisplayImageOptions.Builder()
                    .displayer(new FadeInBitmapDisplayer(1000))
                    .showStubImage(android.R.drawable.sym_def_app_icon).resetViewBeforeLoading().cacheInMemory()
                    .cacheOnDisc().build();
            ImageLoader.getInstance().displayImage(viewApk.getIcon(), (ImageView) findViewById(R.id.app_icon),
                    options, null, (viewApk.getApkid() + "|" + viewApk.getVercode()));

            new GetApkInfo().execute();

            /*Comments comments = new Comments(context,webservicespath);
            comments.getComments(repo_string, viewApk.getApkid(),viewApk.getVername(),(LinearLayout) findViewById(R.id.commentContainer), false);*/
            likes = new Likes(context, webservicespath);
            /*likes.getLikes(repo_string, viewApk.getApkid(), viewApk.getVername(),(ViewGroup) findViewById(R.id.likesLayout),(ViewGroup) findViewById(R.id.ratings));*/

            ItemBasedApks items = new ItemBasedApks(context, viewApk);
            items.getItems((LinearLayout) findViewById(R.id.itembasedapks_container),
                    (LinearLayout) findViewById(R.id.itembasedapks_maincontainer),
                    (TextView) findViewById(R.id.itembasedapks_label));

            if (!spinnerInstanciated) {
                loadApkVersions();
            }
            setClickListeners();

            //Malware badges
            loadMalwareBadges();
            if (Build.VERSION.SDK_INT >= 11) {
                invalidateOptionsMenu();
            }

            //                if(!getIntent().hasExtra("installed")){
            //                    new checkPaymentTask().execute();
            //                }

        }

        private void loadMalwareBadges() {
            new Thread(new Runnable() {

                @Override
                public void run() {
                    try {
                        loadMalware(viewApk.getMalwareStatus());
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }).start();

        }

        @Override
        public void onLoaderReset(Loader<ViewApk> arg0) {

        }
    });

    //

    //

    //      Button serch_mrkt = (Button)findViewById(R.id.btmarket);
    //      serch_mrkt.setOnClickListener(new OnClickListener() {
    //
    //         public void onClick(View v) {

    //         }
    //
    //      });

    //

    //
    //

}

From source file:net.coding.program.project.init.create.ProjectCreateFragment.java

private void showWarningDialog() {
    LayoutInflater factory = LayoutInflater.from(getActivity());
    final View textEntryView = factory.inflate(R.layout.init_dialog_text_entry2, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    AlertDialog dialog = builder.setTitle("??").setView(textEntryView)
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                @Override/*from w w w . ja v  a 2s  .c  o  m*/
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).show();
    CustomDialog.dialogTitleLineColor(getActivity(), dialog);
}

From source file:com.code.android.vibevault.SearchScreen.java

/** Handle user's long-click selection.
*
*///from   w  w w  .j  a  v a2  s. c om
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    if (menuInfo != null) {
        ArchiveShowObj selShow = (ArchiveShowObj) searchList.getAdapter().getItem(menuInfo.position);
        switch (item.getItemId()) {
        case VibeVault.EMAIL_LINK:
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("plain/text");
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                    "Great show on archive.org: " + selShow.getArtistAndTitle());
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                    "Hey,\n\nYou should listen to " + selShow.getArtistAndTitle() + ".  You can find it here: "
                            + selShow.getShowURL() + "\n\nSent using VibeVault for Android.");
            startActivity(Intent.createChooser(emailIntent, "Send mail..."));
            return true;
        case VibeVault.SHOW_INFO:
            AlertDialog.Builder ad = new AlertDialog.Builder(this);
            ad.setTitle("Show Info");
            View v = LayoutInflater.from(this).inflate(R.layout.scrollable_dialog, null);
            ((TextView) v.findViewById(R.id.DialogText)).setText(selShow.getSource());
            ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int arg1) {
                }
            });
            ad.setView(v);
            ad.show();
            return true;
        case (VibeVault.ADD_TO_FAVORITE_LIST):
            VibeVault.db.insertFavoriteShow(selShow);
            return true;
        default:
            return false;
        }
    }
    return false;
}