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.eutectoid.dosomething.picker.GraphObjectAdapter.java

public GraphObjectAdapter(Context context) {
    this.context = context;
    this.inflater = LayoutInflater.from(context);
}

From source file:com.hackensack.umc.activity.ProfileSelfieManualCropActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /*  if(savedInstanceState!=null){
    imageUri=Uri.parse(savedInstanceState.getString(Constant.CAPTURE_IMAGE_URI));
      }*///from w  ww.j av  a  2 s .  c  o m
    //setContentView(R.layout.activity_profile_selfie);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    frameLayout = new FrameLayout(this);
    // creating LayoutParams
    FrameLayout.LayoutParams frameLayoutParam = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    // set LinearLayout as a root element of the screen
    setContentView(frameLayout, frameLayoutParam);
    layoutInflater = LayoutInflater.from(this);
    View mainView = layoutInflater.inflate(R.layout.activity_profile_selfie, null, false);

    infalteXml(mainView);
    frameLayout.addView(mainView);

    //setContentView(R.layout.activity_list);
    //setContentView(R.layout.activity_list);

}

From source file:com.flavik.barcode.recognizer.client.android.book.SearchBookContentsActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();//from   w w w  . j  av  a 2  s.c  o m
    if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
        finish();
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(R.string.sbc_name));
    } else {
        setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
    }

    setContentView(R.layout.search_book_contents);
    queryTextView = (EditText) findViewById(R.id.query_text_view);

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && !initialQuery.isEmpty()) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = (Button) findViewById(R.id.query_button);
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(R.id.result_list_view);
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(R.layout.search_book_contents_header, resultListView, false);
    resultListView.addHeaderView(headerView);
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.f0_profile);
    mUserId = getIntent().getIntExtra(USER_ID, 0);
    mServiceType = (SERVICE_TYPE) getIntent().getSerializableExtra(O2OMobileAppConst.SERVICE_TYPE);
    mListview = (ListView) findViewById(R.id.profile_listview);
    mHelp = (Button) findViewById(R.id.btn_help);
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    mHeaderView = layoutInflater.inflate(R.layout.f0_profile_header, null);
    mBack = (ImageView) mHeaderView.findViewById(R.id.top_view_back);
    mSetting = (ImageView) mHeaderView.findViewById(R.id.top_view_setting);
    mAvatar = (RoundedWebImageView) mHeaderView.findViewById(R.id.iv_avarta);
    mName = (TextView) mHeaderView.findViewById(R.id.tv_name);
    mBalance = (TextView) mHeaderView.findViewById(R.id.tv_balance);
    mSignature = (TextView) mHeaderView.findViewById(R.id.tv_signature);
    mBrief = (TextView) mHeaderView.findViewById(R.id.tv_brief);
    mBrief_detail = (TextView) mHeaderView.findViewById(R.id.brief_detail);
    //        mMyCash = (RelativeLayout) mHeaderView.findViewById(R.id.my_cash);
    mComment = (RelativeLayout) mHeaderView.findViewById(R.id.comment);
    mCommentCount = (TextView) mHeaderView.findViewById(R.id.tv_comment_count);
    mCommentGoodrate = (TextView) mHeaderView.findViewById(R.id.tv_comment_goodrate);
    mComplain = (TextView) mHeaderView.findViewById(R.id.complain);
    mGridviewServiceList = (MyGridView) mHeaderView.findViewById(R.id.grid_view_service_list);
    mGridview = (LinearLayout) mHeaderView.findViewById(R.id.gridview);
    mBirefLayout = (LinearLayout) mHeaderView.findViewById(R.id.ll_brief);
    mRefresh = (ImageView) mHeaderView.findViewById(R.id.refresh);
    mGridviewServiceList.setSelector(new ColorDrawable(Color.TRANSPARENT));
    mListview.addHeaderView(mHeaderView);
    mListview.setAdapter(null);//from  w  w w  .  j  ava  2s.c  o m
    mUserBalance = new UserBalanceModel(this);
    mUserBalance.addResponseListener(this);
    mUserBalance.getProfile(mUserId);
    mBack.setOnClickListener(this);
    mSetting.setOnClickListener(this);
    mBrief_detail.setOnClickListener(this);
    mHelp.setOnClickListener(this);
    mComment.setOnClickListener(this);
    mComplain.setOnClickListener(this);
    mAvatar.setOnClickListener(this);
    mRefresh.setOnClickListener(this);
    if (mUserId != SESSION.getInstance().uid) {
        mSetting.setVisibility(View.GONE);
        mComplain.setVisibility(View.VISIBLE);
    } else {
        mUserBalance.get();
    }
    EventBus.getDefault().register(this);
}

From source file:com.svo.library.widget.RLWebBrowser.java

private void init(Context context) {
    this.context = context;
    View rootView = LayoutInflater.from(context).inflate(R.layout.web_browser, null);
    this.addView(rootView);
    layout_loading = (LinearLayout) rootView.findViewById(R.id.layout_loading);
    layout_loading.setVisibility(View.GONE);
    iv_refresh = (ImageView) rootView.findViewById(R.id.iv_refresh);
    iv_refresh.setOnClickListener(myClickListener);
    iv_stop = (ImageView) rootView.findViewById(R.id.iv_stop);
    iv_stop.setOnClickListener(myClickListener);
    iv_goback = (ImageView) rootView.findViewById(R.id.iv_goback);
    iv_goback.setOnClickListener(myClickListener);
    iv_more = (ImageView) rootView.findViewById(R.id.iv_more);
    iv_more.setOnClickListener(myClickListener);
    iv_goback.setEnabled(false);//from  w  ww  .j ava2  s .  com
    iv_goforward = (ImageView) rootView.findViewById(R.id.iv_goforward);
    iv_goforward.setOnClickListener(myClickListener);
    iv_goforward.setEnabled(false);
    webView = (WebView) rootView.findViewById(R.id.webView);
    webView.getSettings().setSupportZoom(true);
    webView.getSettings().setSaveFormData(false);
    webView.getSettings().setSavePassword(false);
    webView.getSettings().setPluginState(PluginState.ON);
    webView.getSettings().setUseWideViewPort(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setBlockNetworkLoads(false);
    webView.getSettings().setLoadWithOverviewMode(true);
    webView.getSettings().setRenderPriority(RenderPriority.HIGH);
    webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    webView.setWebChromeClient(myWebChromeClient);
    webView.setWebViewClient(myWebViewClient);
    webView.setOnTouchListener(myTouchListener);
    webView.setDownloadListener(myDownLoadListener);
    webView.removeJavascriptInterface("searchBoxJavaBredge_");
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

private Dialog AdminPinSetDialog(Context context) {
    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.pin_input, null);
    TextView pinText = (TextView) textEntryView.findViewById(R.id.pin_text);
    pinText.setText(R.string.admin_set_msg);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);//from w w  w . j  a v  a  2  s. c  o m
    builder.setTitle(R.string.admin_set_title);
    builder.setView(textEntryView);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            EditText pinEdite = (EditText) textEntryView.findViewById(R.id.pin_edit);
            String pinStr = pinEdite.getText().toString();
            Utilities.Log("Pin Dialog", "pin String is " + pinStr);

            String data = null;
            try {
                data = Utilities.encryption("0000" + "," + "1" + "," + pinStr);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            /*            check network*/

            /*            prepare params for server*/
            HttpPost request = new HttpPost(Utilities.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //               //file_name
            //               params.add(new BasicNameValuePair("userID","0000"));
            //               //function
            //               params.add(new BasicNameValuePair("pre","1"));
            //               //data
            //               params.add(new BasicNameValuePair("password",pinStr));

            /*            check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result", result);

                    if (result.equals("AdminIsChecked")) {
                        //do nothing

                    } else if (result.equals("AdminPinIsInvalid")) {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_failed, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    } else {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_error, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    }
                } else {
                    Toast.makeText(getApplicationContext(), R.string.input_apin_return, Toast.LENGTH_SHORT)
                            .show();
                    finish();
                }

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Toast.makeText(getApplicationContext(), R.string.input_apin_net_error, Toast.LENGTH_SHORT)
                        .show();
                ;
                finish();
            }

        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

            finish();
        }
    });

    return builder.create();
}

From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java

private Dialog AdminPinSetDialog(final Context context) {
    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.pin_input, null);
    TextView pinText = (TextView) textEntryView.findViewById(R.id.pin_text);
    pinText.setText(R.string.admin_set_msg);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);/*ww  w  .j av a  2 s.  c om*/
    builder.setTitle(R.string.admin_set_title);
    builder.setView(textEntryView);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            EditText pinEdite = (EditText) textEntryView.findViewById(R.id.pin_edit);
            String pinStr = pinEdite.getText().toString();
            Util.Log_debug("Pin Dialog", "pin String is " + pinStr);

            String data = null;
            try {
                data = Util.encryption(context, Util.ADMIN_UID + "," + "1" + "," + pinStr);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            /*              check network*/

            /*              prepare params for server*/
            HttpPost request = new HttpPost(Util.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //              //file_name
            //              params.add(new BasicNameValuePair("userID","0000"));
            //              //function
            //              params.add(new BasicNameValuePair("pre","1"));
            //              //data
            //              params.add(new BasicNameValuePair("password",pinStr));

            /*              check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result", result);

                    if (result.equals("AdminIsChecked")) {
                        //do nothing

                    } else if (result.equals("AdminPinIsInvalid")) {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_failed, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    } else {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_error, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    }
                } else {
                    Toast.makeText(getApplicationContext(), R.string.input_apin_return, Toast.LENGTH_SHORT)
                            .show();
                    finish();
                }

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Toast.makeText(getApplicationContext(), R.string.input_apin_net_error, Toast.LENGTH_SHORT)
                        .show();
                ;
                finish();
            }

        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

            finish();
        }
    });

    return builder.create();
}

From source file:com.df.app.carCheck.VehicleInfoLayout.java

/**
 * // w  ww. ja va 2  s . c o  m
 */
private void selectCarManually() {
    View view = LayoutInflater.from(rootView.getContext()).inflate(R.layout.vehicle_model_select, null);

    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(R.string.select_model);

    initModelSelectEdits(view);

    AlertDialog dialog = new AlertDialog.Builder(rootView.getContext()).setView(view)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    // ?Spinner?
                    if (lastCountryIndex == 0 || lastBrandIndex == 0 || lastManufacturerIndex == 0
                            || lastSeriesIndex == 0 || lastModelIndex == 0) {
                        Toast.makeText(rootView.getContext(), "", Toast.LENGTH_SHORT)
                                .show();

                        return;
                    }

                    Country country = vehicleModel.countries.get(lastCountryIndex - 1);
                    Brand brand = country.brands.get(lastBrandIndex - 1);
                    Manufacturer manufacturer = brand.manufacturers.get(lastManufacturerIndex - 1);
                    Series series = manufacturer.serieses.get(lastSeriesIndex - 1);
                    Model model = series.models.get(lastModelIndex - 1);

                    mCarSettings.setCountry(country);
                    mCarSettings.setBrand(brand);
                    mCarSettings.setManufacturer(manufacturer);
                    mCarSettings.setSeries(series);
                    mCarSettings.setModel(model);

                    // ?seriesIdmodelId????  config:powerWindows,powerSeats...
                    getCarSettingsFromServer(series.id + "," + model.id);
                }
            }).setNegativeButton(R.string.cancel, null).create();

    dialog.show();
}

From source file:com.google.zxing.client.android.book.SearchBookContentsActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    fakeR = new FakeR(this);

    // Make sure that expired cookies are removed on launch.
    CookieSyncManager.createInstance(this);
    CookieManager.getInstance().removeExpiredCookie();

    Intent intent = getIntent();//w ww  . j  a  v a 2s.c  o  m
    if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
        finish();
        return;
    }

    isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
    if (LocaleManager.isBookSearchUrl(isbn)) {
        setTitle(getString(fakeR.getId("string", "sbc_name")));
    } else {
        setTitle(getString(fakeR.getId("string", "sbc_name")) + ": ISBN " + isbn);
    }

    setContentView(fakeR.getId("layout", "search_book_contents"));
    queryTextView = (EditText) findViewById(fakeR.getId("id", "query_text_view"));

    String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
    if (initialQuery != null && initialQuery.length() > 0) {
        // Populate the search box but don't trigger the search
        queryTextView.setText(initialQuery);
    }
    queryTextView.setOnKeyListener(keyListener);

    queryButton = (Button) findViewById(fakeR.getId("id", "query_button"));
    queryButton.setOnClickListener(buttonListener);

    resultListView = (ListView) findViewById(fakeR.getId("id", "result_list_view"));
    LayoutInflater factory = LayoutInflater.from(this);
    headerView = (TextView) factory.inflate(fakeR.getId("layout", "search_book_contents_header"),
            resultListView, false);
    resultListView.addHeaderView(headerView);
}

From source file:com.zzisoo.toylibrary.adapter.ToyListAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    // Create a new view.
    View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.toy_item_view, viewGroup, false);

    //setItemSize(v);
    TextView tvLoading = (TextView) (v.findViewById(R.id.tvLoading));
    tvLoading.setTypeface(Typefaces.get(v.getContext(), "Satisfy-Regular.ttf"));

    return new ViewHolder(v);
}