List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:com.insthub.O2OMobile.Activity.D1_OrderActivity.java
private void showOrderPriceDialog() { LayoutInflater inflater = LayoutInflater.from(D1_OrderActivity.this); View view = inflater.inflate(R.layout.d1_order_price_dialog, null); mPriceDialog = new Dialog(D1_OrderActivity.this, R.style.dialog); mPriceDialog.setContentView(view);//from www . j a v a 2 s.co m mPriceDialog.setCanceledOnTouchOutside(false); mPriceDialog.show(); mOrderPriceDialogPrice = (TextView) view.findViewById(R.id.order_price_dialog_price); mOrderPriceDialogChangePrice = (EditText) view.findViewById(R.id.order_price_dialog_change_price); mOrderPriceDialogOk = (Button) view.findViewById(R.id.order_price_dialog_ok); mOrderPriceDialogCancel = (Button) view.findViewById(R.id.order_price_dialog_cancel); if (mOrderInfoModel.publicOrder.offer_price != null) { mOrderPriceDialogPrice.setText(Utils.formatBalance(mOrderInfoModel.publicOrder.offer_price) + ""); } mOrderPriceDialogChangePrice.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub if (s.toString().length() > 0) { if (s.toString().substring(0, 1).equals(".")) { s = s.toString().substring(1, s.length()); mOrderPriceDialogChangePrice.setText(s); } } if (s.toString().length() > 1) { if (s.toString().substring(0, 1).equals("0")) { if (!s.toString().substring(1, 2).equals(".")) { s = s.toString().substring(1, s.length()); mOrderPriceDialogChangePrice.setText(s); CharSequence charSequencePirce = mOrderPriceDialogChangePrice.getText(); if (charSequencePirce instanceof Spannable) { Spannable spanText = (Spannable) charSequencePirce; Selection.setSelection(spanText, charSequencePirce.length()); } } } } boolean flag = false; for (int i = 0; i < s.toString().length() - 1; i++) { String getstr = s.toString().substring(i, i + 1); if (getstr.equals(".")) { flag = true; break; } } if (flag) { int i = s.toString().indexOf("."); if (s.toString().length() - 3 > i) { String getstr = s.toString().substring(0, i + 3); mOrderPriceDialogChangePrice.setText(getstr); CharSequence charSequencePirce = mOrderPriceDialogChangePrice.getText(); if (charSequencePirce instanceof Spannable) { Spannable spanText = (Spannable) charSequencePirce; Selection.setSelection(spanText, charSequencePirce.length()); } } } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub } }); mOrderPriceDialogCancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub mPriceDialog.dismiss(); } }); mOrderPriceDialogOk.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub mOrderInfoModel.done(mOrderId, mOrderPriceDialogChangePrice.getText().toString()); mPriceDialog.dismiss(); } }); }
From source file:reportsas.com.formulapp.Formulario.java
public LinearLayout obtenerLayout(LayoutInflater infla, Pregunta preg) { int id;/*w w w . j a v a 2 s. c o m*/ int tipo_pregunta = preg.getTipoPregunta(); LinearLayout pregunta; TextView textView; TextView textAyuda; switch (tipo_pregunta) { case 1: id = R.layout.pregunta_texto; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloPregunta); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; case 2: id = R.layout.pregunta_multitexto; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.mtxtTritulo); textAyuda = (TextView) pregunta.findViewById(R.id.mtxtAyuda); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; case 3: id = R.layout.pregunta_seleccion; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloSeleccion); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_seleccion); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); RadioGroup rg = (RadioGroup) pregunta.findViewById(R.id.opcionesUnica); ArrayList<OpcionForm> opciones = preg.getOpciones(); final ArrayList<RadioButton> rb = new ArrayList<RadioButton>(); for (int i = 0; i < opciones.size(); i++) { OpcionForm opcion = opciones.get(i); rb.add(new RadioButton(this)); rg.addView(rb.get(i)); rb.get(i).setText(opcion.getEtInicial()); } final TextView respt = (TextView) pregunta.findViewById(R.id.respuestaGruop); rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { int radioButtonID = group.getCheckedRadioButtonId(); RadioButton radioButton = (RadioButton) group.findViewById(radioButtonID); respt.setText(radioButton.getText()); } }); break; case 4: id = R.layout.pregunta_multiple; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloMultiple); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); ArrayList<OpcionForm> opciones2 = preg.getOpciones(); final EditText ediOtros = new EditText(this); ArrayList<CheckBox> cb = new ArrayList<CheckBox>(); for (int i = 0; i < opciones2.size(); i++) { OpcionForm opcion = opciones2.get(i); cb.add(new CheckBox(this)); pregunta.addView(cb.get(i)); cb.get(i).setText(opcion.getEtInicial()); if (opcion.getEditble().equals("S")) { ediOtros.setEnabled(false); ediOtros.setId(R.id.edtTexto); pregunta.addView(ediOtros); cb.get(i).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { ediOtros.setEnabled(true); } else { ediOtros.setText(""); ediOtros.setEnabled(false); } } }); } } TextView spacio = new TextView(this); spacio.setText(" "); spacio.setVisibility(View.INVISIBLE); pregunta.addView(spacio); break; case 5: id = R.layout.pregunta_escala; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloEscala); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_escala); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); TextView etInicial = (TextView) pregunta.findViewById(R.id.etInicial); TextView etFinal = (TextView) pregunta.findViewById(R.id.etFinal); OpcionForm opci = preg.getOpciones().get(0); etInicial.setText(opci.getEtInicial()); etFinal.setText(opci.getEtFinal()); final TextView respEscala = (TextView) pregunta.findViewById(R.id.seleEscala); RatingBar rtBar = (RatingBar) pregunta.findViewById(R.id.escala); rtBar.setNumStars(Integer.parseInt(opci.getValores().get(0).getDescripcion())); rtBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { respEscala.setText("" + Math.round(rating)); } }); break; case 6: id = R.layout.pregunta_lista; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloLista); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_lista); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); ArrayList<OpcionForm> opciones3 = preg.getOpciones(); //Creamos la lista LinkedList<ObjetoSpinner> opcn = new LinkedList<ObjetoSpinner>(); //La poblamos con los ejemplos for (int i = 0; i < opciones3.size(); i++) { opcn.add(new ObjetoSpinner(opciones3.get(i).getIdOpcion(), opciones3.get(i).getEtInicial())); } //Creamos el adaptador*/ Spinner listad = (Spinner) pregunta.findViewById(R.id.opcionesListado); ArrayAdapter<ObjetoSpinner> spinner_adapter = new ArrayAdapter<ObjetoSpinner>(this, android.R.layout.simple_spinner_item, opcn); //Aadimos el layout para el men y se lo damos al spinner spinner_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); listad.setAdapter(spinner_adapter); break; case 7: id = R.layout.pregunta_tabla; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloTabla); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_tabla); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); TableLayout tba = (TableLayout) pregunta.findViewById(R.id.tablaOpciones); ArrayList<OpcionForm> opciones4 = preg.getOpciones(); ArrayList<RadioButton> radiosbotonoes = new ArrayList<RadioButton>(); for (int i = 0; i < opciones4.size(); i++) { TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.row_pregunta_tabla, null); RadioGroup tg_valores = (RadioGroup) row.findViewById(R.id.valoresRow); final ArrayList<RadioButton> valoOpc = new ArrayList<RadioButton>(); ArrayList<Valor> valoresT = opciones4.get(i).getValores(); for (int k = 0; k < valoresT.size(); k++) { RadioButton rb_nuevo = new RadioButton(this); rb_nuevo.setText(valoresT.get(k).getDescripcion()); tg_valores.addView(rb_nuevo); valoOpc.add(rb_nuevo); } ((TextView) row.findViewById(R.id.textoRow)).setText(opciones4.get(i).getEtInicial()); tba.addView(row); } TextView espacio = new TextView(this); espacio.setText(" "); pregunta.addView(espacio); break; case 8: id = R.layout.pregunta_fecha; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloFecha); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_fecha); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; case 9: id = R.layout.pregunta_hora; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloHora); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_hora); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; default: id = R.layout.pregunta_multiple; pregunta = (LinearLayout) infla.inflate(id, null, false); textView = (TextView) pregunta.findViewById(R.id.TituloMultiple); textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple); textView.setText(preg.getOrden() + ". " + preg.getTitulo()); textAyuda.setText(preg.getTxtAyuda()); break; } return pregunta; }
From source file:com.abc.driver.MainActivity.java
public void initHorders() { for (int i = 0; i < 3; i++) { mHorderTypes[i] = new HorderType(i); }//from w ww .jav a2 s . co m mPartyMore = (ViewGroup) LayoutInflater.from(MainActivity.this).inflate(R.layout.more_list, null); mPartyMore.setVisibility(View.GONE); mMoreTv = (TextView) mPartyMore.getChildAt(0); // mHorderLv.addFooterView(mPartyMore); mHorderLv.setOnItemClickListener(mHorderDetailListener); mHorderLv.setAdapter(mHorderTypes[mCurrRadioIdx].nHorderAdapter); // Set a listener to be invoked when the list should be refreshed. mHorderLv.setOnRefreshListener(new OnRefreshListener2<ListView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) { isForceRefresh = true; String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);// // mHorderTypes[mCurrRadioIdx] = new HorderType(mCurrRadioIdx); mHorderDownLoadTask = new HorderDownLoadTask(); mHorderDownLoadTask.execute(CellSiteConstants.NORMAL_OPERATION); } @Override public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) { isForceRefresh = true; // mHorderTypes[mCurrRadioIdx] = new HorderType(mCurrRadioIdx); String label = DateUtils.formatDateTime(getApplicationContext(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);// mHorderDownLoadTask = new HorderDownLoadTask(); mHorderDownLoadTask.execute(CellSiteConstants.NORMAL_OPERATION); } }); }
From source file:abanoubm.dayra.main.Main.java
private void register() { LayoutInflater li = LayoutInflater.from(getApplicationContext()); final View view = li.inflate(R.layout.dialogue_create, null, false); final AlertDialog ad = new AlertDialog.Builder(Main.this).setCancelable(true).create(); ad.setView(view, 0, 0, 0, 0);/* w ww . j a v a 2 s. c o m*/ ad.show(); view.findViewById(R.id.yesBtn).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String str = ((EditText) view.findViewById(R.id.input)).getText().toString().trim(); if (Utility.isInvlaidDBName(str)) { Toast.makeText(getApplicationContext(), R.string.err_msg_dayra_name, Toast.LENGTH_SHORT).show(); } else { if (DB.isDBExists(getApplicationContext(), str)) { Toast.makeText(getApplicationContext(), R.string.err_msg_duplicate_dayra, Toast.LENGTH_SHORT).show(); } else { new RegisterTask().execute(str); ad.dismiss(); } } } }); }
From source file:com.nbos.phonebook.sync.authenticator.AuthenticatorActivity.java
void createAccountWithFbId() { mPrefs = getPreferences(MODE_PRIVATE); SharedPreferences.Editor editor = mPrefs.edit(); editor.putString("access_token", facebook.getAccessToken()); editor.putLong("access_expires", facebook.getAccessExpires()); editor.commit();/*w w w . jav a 2 s . c o m*/ String access_token = mPrefs.getString("access_token", null); long expires = mPrefs.getLong("access_expires", 0); if (access_token != null) { facebook.setAccessToken(access_token); } if (expires != 0) { facebook.setAccessExpires(expires); } /* * Only call authorize if the access_token has expired. */ if (facebook.isSessionValid()) { Log.i(tag, "Session is valid"); JSONObject json; try { json = Util.parseJson(facebook.request("me", new Bundle())); Log.i(tag, "json: " + json); fbId = json.getString("id"); String username = json.getString("id"); JSONArray existingUser = new Cloud(getApplicationContext(), fbId, null).findExistingFbUser(fbId, countryCode + mPhone); Log.i(tag, "existingUser: " + existingUser.getString(0)); LayoutInflater factory = LayoutInflater.from(this); textEntryView = factory.inflate(R.layout.facebook_email_layout, null); TextView fbUsername = (TextView) textEntryView.findViewById(R.id.facebookLogin_email); TextView fbPassword = (TextView) textEntryView.findViewById(R.id.facebookLogin_password); Button fbAccountButton = (Button) textEntryView.findViewById(R.id.facebookLogin); if (existingUser.getString(0).trim().length() == 0) { Log.i(tag, "email: " + Text.isEmail(username)); if (!(Text.isEmail(username))) { AlertDialog.Builder newBuilder = new AlertDialog.Builder(this); newBuilder.setTitle("FbLogin to Phonebook"); newBuilder.setView(textEntryView); Button existingFbAccount = (Button) textEntryView .findViewById(R.id.existingAccountfacebookLogin); existingFbAccount.setVisibility(View.GONE); AlertDialog newAlert = newBuilder.create(); newAlert.show(); } } else { fbAccountButton.setVisibility(View.GONE); fbUsername.setText(existingUser.getString(0)); fbUsername.setEnabled(false); fbPassword.requestFocus(); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("FbLogin to Phonebook"); builder.setView(textEntryView); AlertDialog alert = builder.create(); alert.show(); } //mPhone = mPhoneEdit.getText().toString(); //new Cloud(getApplicationContext(), userId, userId).loginWithFacebook(countryCode + mPhone); /*mUsername = userName; mPassword = userId;*/ //finishLogin(); // mUsernameEdit.setText(userName); // mPasswordEdit.setText(userId); Log.i(tag, "userName: " + username + " userId: " + fbId); Log.i(tag, "response:" + json); } catch (Exception e1) { Log.e(tag, "Exception logging on with Facebook: " + e1); e1.printStackTrace(); } catch (FacebookError e) { Log.e(tag, "Facebook error logging on with Facebook: " + e); e.printStackTrace(); } } }
From source file:com.mappn.gfan.common.util.Utils.java
/** * Tab??TextViewView//from w w w . ja v a 2 s . co m */ public static View createTabView(Context context, String text) { TextView view = (TextView) LayoutInflater.from(context).inflate(R.layout.common_tab_view, null); view.setText(text); return view; }
From source file:com.mappn.gfan.common.util.Utils.java
/** * Search Tab??TextViewView//from www . j av a 2 s .c o m */ public static View createSearchTabView(Context context, String text) { TextView view = (TextView) LayoutInflater.from(context).inflate(R.layout.common_tab_view, null); view.setBackgroundResource(R.drawable.search_tab_selector); view.setTextAppearance(context, R.style.search_tab_text); view.setText(text); return view; }
From source file:at.alladin.rmbt.android.about.RMBTAboutFragment.java
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); LayoutInflater inflater = LayoutInflater.from(getActivity()); populateViewForOrientation(inflater, (ViewGroup) getView()); }
From source file:com.wellsandwhistles.android.redditsp.fragments.PostListingFragment.java
private void onLoadMoreItemsCheck() { General.checkThisIsUIThread();// w ww . j ava 2 s . com if (mReadyToDownloadMore && mAfter != null && !mAfter.equals(mLastAfter)) { final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView.getLayoutManager(); if (mPostListingManager.getPostCount() > 0 && (layoutManager.getItemCount() - layoutManager.findLastVisibleItemPosition() < 20 && (mPostCountLimit <= 0 || mPostRefreshCount.get() > 0) || (mPreviousFirstVisibleItemPosition != null && layoutManager.getItemCount() <= mPreviousFirstVisibleItemPosition))) { mLastAfter = mAfter; mReadyToDownloadMore = false; final Uri newUri = mPostListingURL.after(mAfter).generateJsonUri(); // TODO customise (currently 3 hrs) final DownloadStrategy strategy = (SRTime.since(mTimestamp) < 3 * 60 * 60 * 1000) ? DownloadStrategyIfNotCached.INSTANCE : DownloadStrategyNever.INSTANCE; mRequest = new PostListingRequest(newUri, RedditAccountManager.getInstance(getActivity()).getDefaultAccount(), mSession, strategy, false); mPostListingManager.setLoadingVisible(true); CacheManager.getInstance(getActivity()).makeRequest(mRequest); } else if (mPostCountLimit > 0 && mPostRefreshCount.get() <= 0) { if (mLoadMoreView == null) { mLoadMoreView = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.load_more_posts, null); mLoadMoreView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mPostListingManager.removeLoadMoreButton(); mLoadMoreView = null; restackRefreshCount(); onLoadMoreItemsCheck(); } }); mPostListingManager.addLoadMoreButton(mLoadMoreView); } } } }
From source file:android.support.v17.leanback.app.OnboardingSupportFragment.java
private void initializeViews(View container) { mLogoView.setVisibility(View.GONE); // Create custom views. LayoutInflater inflater = getThemeInflater(LayoutInflater.from(getActivity())); ViewGroup backgroundContainer = (ViewGroup) container.findViewById(R.id.background_container); View background = onCreateBackgroundView(inflater, backgroundContainer); if (background != null) { backgroundContainer.setVisibility(View.VISIBLE); backgroundContainer.addView(background); }//www . j ava 2s . co m ViewGroup contentContainer = (ViewGroup) container.findViewById(R.id.content_container); View content = onCreateContentView(inflater, contentContainer); if (content != null) { contentContainer.setVisibility(View.VISIBLE); contentContainer.addView(content); } ViewGroup foregroundContainer = (ViewGroup) container.findViewById(R.id.foreground_container); View foreground = onCreateForegroundView(inflater, foregroundContainer); if (foreground != null) { foregroundContainer.setVisibility(View.VISIBLE); foregroundContainer.addView(foreground); } // Make views visible which were invisible while logo animation is running. container.findViewById(R.id.page_container).setVisibility(View.VISIBLE); container.findViewById(R.id.content_container).setVisibility(View.VISIBLE); if (getPageCount() > 1) { mPageIndicator.setPageCount(getPageCount()); mPageIndicator.onPageSelected(mCurrentPageIndex, false); } if (mCurrentPageIndex == getPageCount() - 1) { mStartButton.setVisibility(View.VISIBLE); } else { mPageIndicator.setVisibility(View.VISIBLE); } // Header views. mTitleView.setText(getPageTitle(mCurrentPageIndex)); mDescriptionView.setText(getPageDescription(mCurrentPageIndex)); }