List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:br.com.mybaby.contatos.ContactDetailFragment.java
/** * Builds a phone layout//from w w w .j a v a 2 s. co m * * @return A LinearLayout from phones */ private LinearLayout buildPhoneLayout(final Integer id, String number, boolean checked) { // Inflates the address layout final LinearLayout phoneLayout = (LinearLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.contatos_phone_detail_item, mDetailsLayout, false); // Gets handles to the view objects in the layout final TextView headerTextView = (TextView) phoneLayout.findViewById(R.id.contact_phone_detail_header); final TextView phoneTextView = (TextView) phoneLayout.findViewById(R.id.contact_phone_detail_item); final CheckBox phoneCheckBox = (CheckBox) phoneLayout.findViewById(R.id.checkbox_phone); phoneCheckBox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { CheckBox cb = (CheckBox) v; Telefone _tel = new Telefone(); _tel.setId(cb.getId()); if (cb.isChecked()) { if (telefonesBase.size() == 4) { Toast.makeText(getActivity(), "Mximo de telefones selecionados: 4", Toast.LENGTH_LONG) .show(); cb.setChecked(false); } else { int posicao = telefonesContatoAtual.indexOf(_tel); contatoParaSalvar.getTelefones().add(telefonesContatoAtual.get(posicao)); telefonesBase.add(telefonesContatoAtual.get(posicao)); } } else { int posicao = contatoParaSalvar.getTelefones().indexOf(_tel); contatoParaSalvar.getTelefones().remove(posicao); telefonesBase.remove(posicao); } } }); if (phoneTextView == null) { headerTextView.setVisibility(View.GONE); phoneTextView.setText(R.string.no_address); phoneCheckBox.setVisibility(View.GONE); } else { phoneCheckBox.setId(id); phoneCheckBox.setChecked(checked); phoneTextView.setText(number); } return phoneLayout; }
From source file:com.cssweb.android.base.DialogActivity.java
protected void openPopup() { LayoutInflater factory = LayoutInflater.from(DialogActivity.this); final LinearLayout sortDialogView = (LinearLayout) factory.inflate(R.layout.sort_dialog, null); dlg = new AlertDialog.Builder(DialogActivity.this).setTitle("?").setView(sortDialogView) .setPositiveButton(getResources().getString(R.string.alert_dialog_ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { handleClick(true); }/* w w w . j av a 2 s . c om*/ }) .setNegativeButton(getResources().getString(R.string.alert_dialog_cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { } }) .create(); ///dlg.show(); timeSpinner = (Spinner) sortDialogView.getChildAt(1); stateSpinner = (Spinner) sortDialogView.getChildAt(3); timeTextView = (TextView) sortDialogView.getChildAt(0); stateTextView = (TextView) sortDialogView.getChildAt(2); if (activityKind == Global.QUOTE_PAIMING) { timeTextView.setText(""); stateTextView.setText("?"); setAdapter(timeSpinner, zhouqi); setAdapter(stateSpinner, xuanx); } else if (activityKind == Global.QUOTE_FENLEI || activityKind == Global.HK_MAINBOARD || activityKind == Global.HK_CYB) { timeTextView.setText(""); stateTextView.setText("?"); setAdapter(timeSpinner, paiming); setAdapter(stateSpinner, desc); } }
From source file:net.bytten.comicviewer.ComicViewerActivity.java
@Override protected Dialog onCreateDialog(int id) { // Set up variables for a dialog and a dialog builder. Only need one of each. Dialog dialog = null;// w w w . ja va 2s . co m AlertDialog.Builder builder = null; // Determine the type of dialog based on the integer passed. These are defined in constants // at the top of the class. switch (id) { case DIALOG_SHOW_HOVER_TEXT: //Build and show the Hover Text dialog builder = new AlertDialog.Builder(ComicViewerActivity.this); builder.setMessage(comicInfo.getAlt()); builder.setPositiveButton("Open Link...", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { openComicLink(); } }); builder.setNegativeButton("Close", null); dialog = builder.create(); builder = null; break; case DIALOG_SHOW_ABOUT: //Build and show the About dialog builder = new AlertDialog.Builder(this); builder.setTitle(getStringAppName()); builder.setIcon(android.R.drawable.ic_menu_info_details); builder.setNegativeButton(android.R.string.ok, null); builder.setNeutralButton("Donate", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { donate(); } }); builder.setPositiveButton("Developer Website", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { developerWebsite(); } }); View v = LayoutInflater.from(this).inflate(R.layout.about, null); TextView tv = (TextView) v.findViewById(R.id.aboutText); tv.setText(String.format(getStringAboutText(), getVersion())); builder.setView(v); dialog = builder.create(); builder = null; v = null; tv = null; break; case DIALOG_SEARCH_BY_TITLE: //Build and show the Search By Title dialog builder = new AlertDialog.Builder(this); LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.search_dlg, (ViewGroup) findViewById(R.id.search_dlg)); final EditText input = (EditText) layout.findViewById(R.id.search_dlg_edit_box); builder.setTitle("Search by Title"); builder.setIcon(android.R.drawable.ic_menu_search); builder.setView(layout); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String query = input.getText().toString(); Uri uri = comicDef.getArchiveUrl(); Intent i = new Intent(ComicViewerActivity.this, getArchiveActivityClass()); i.setAction(Intent.ACTION_VIEW); i.setData(uri); i.putExtra(getPackageName() + "LoadType", ArchiveActivity.LoadType.SEARCH_TITLE); i.putExtra(getPackageName() + "query", query); startActivityForResult(i, PICK_ARCHIVE_ITEM); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); dialog = builder.create(); builder = null; break; case DIALOG_FAILED: // Probably doesn't need its own builder, but because this is a special case // dialog I gave it one. AlertDialog.Builder adb = new AlertDialog.Builder(this); adb.setTitle("Error"); adb.setIcon(android.R.drawable.ic_dialog_alert); adb.setNeutralButton(android.R.string.ok, null); //Set failedDialog to our dialog so we can dismiss //it manually failedDialog = adb.create(); failedDialog.setMessage(errors); dialog = failedDialog; break; default: dialog = null; } return dialog; }
From source file:net.evecom.androidecssp.activity.event.ContinueAddActivity.java
/** * /*from ww w . j a v a2 s .c o m*/ * * * @author Stark Zhou * @created 2015-12-30 2:45:12 * @param view */ public void initDialog(View view) { if (monitors.size() == 0) { toast("", 0); } else { final View dialogView = LayoutInflater.from(ContinueAddActivity.this) .inflate(R.layout.monitor_add_dialog, null); monitorValue = (EditText) dialogView.findViewById(R.id.monitor_value); monitorSpin = (Spinner) dialogView.findViewById(R.id.monitor_spinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinItems); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); monitorSpin.setAdapter(adapter); monitorSpin.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) { monitorType = (String) monitorSpin.getSelectedItem(); monitorValue.setText(monitors.get(position).get("indivalue").toString()); } @Override public void onNothingSelected(AdapterView<?> arg0) { monitorValue.setText(monitors.get(0).get("indivalue").toString()); } }); Dialog monitorDia = new AlertDialog.Builder(ContinueAddActivity.this) .setIcon(R.drawable.qq_dialog_default_icon).setTitle("").setView(dialogView) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { // map if (monitorValue.getText() != null && monitorValue.getText().toString().equals("") == false) { monitorMap.put(monitorType.toString(), monitorValue.getText().toString()); } else { monitorMap.put(monitorType.toString(), "--"); } mapToStr(); } }).setNegativeButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { arg0.dismiss(); } }).create(); monitorDia.show(); } }
From source file:com.roger.lineselectionwebview.LSWebView.java
/** * ?// w w w . j a v a 2 s.c o m * * @param container webView */ public void openLineMode(ViewGroup container) { this.myLayout = (MyAbsoluteLayout) LayoutInflater.from(mContext).inflate(R.layout.line, null); LayoutParams mLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 0, 0); myLayout.setLayoutParams(mLayoutParams); container.addView(myLayout); lineView = (LineView) myLayout.findViewById(R.id.lineView); isLineMode = true; }
From source file:apps.junkuvo.alertapptowalksafely.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { LayoutInflater inflater = LayoutInflater.from(MainActivity.this); final View layout; MENU_ID menu_id = MENU_ID.getMenuIdEnum(item.getItemId()); assert menu_id != null; switch (menu_id) { case SETTING: FlurryAgent.logEvent("Setting"); // ?/*from w w w. j a va 2 s. c o m*/ layout = inflater.inflate(R.layout.setting, (ViewGroup) findViewById(R.id.layout_root)); mAlertDialog = new AlertDialog.Builder(this); mAlertDialog.setTitle(this.getString(R.string.dialog_title_setting)); mAlertDialog.setIcon(R.drawable.ic_settings_black_48dp); mAlertDialog.setView(layout); mAlertDialog.setNegativeButton(this.getString(R.string.dialog_button_ok), null); setSeekBarInLayout(layout); setSwitchInLayout(layout); setRadioGroupInLayout(layout); setToggleButtonInLayout(layout); mAlertDialog.show(); break; case TWITTER: FlurryAgent.logEvent("Share twitter"); if (!TwitterUtility.hasAccessToken(this)) { startAuthorize(); } else { layout = inflater.inflate(R.layout.sharetotwitter, (ViewGroup) findViewById(R.id.layout_root_twitter)); String timeStamp = new SimpleDateFormat(DateUtil.DATE_FORMAT.YYYYMMDD_HHmmss.getFormat(), Locale.JAPAN).format(Calendar.getInstance().getTime()); mAlertDialog = new AlertDialog.Builder(this); mAlertDialog.setTitle(this.getString(R.string.dialog_title_tweet)); mAlertDialog.setIcon(R.drawable.ic_share_black_48dp); mAlertDialog.setView(layout); mTweetText = (EditText) layout.findViewById(R.id.edtTweet); mTweetText.setText(getString(R.string.twitter_tweetText) + "\n" + String.format(getString(R.string.app_googlePlay_url), getPackageName()) + "\n" + timeStamp); mAlertDialog.setPositiveButton(this.getString(R.string.dialog_button_send), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { tweet(mTweetText.getText().toString()); } }); mAlertDialog.setCancelable(false); mAlertDialog.setNegativeButton(this.getString(R.string.dialog_button_cancel), null); mAlertDialog.show(); } break; case HISTORY: Intent intent = new Intent(MainActivity.this, HistoryActivity.class); startActivity(intent); break; case FACEBOOK: showShareDialog(); break; case LINE: LINEUtil.sendStringMessage(this, getString(R.string.twitter_tweetText) + "\n" + String.format(getString(R.string.app_googlePlay_url), getPackageName())); break; case FEEDBACK: Toast.makeText(this, "??????????", Toast.LENGTH_LONG).show(); new EasyFeedback.Builder(this).withEmail("0825elle@gmail.com").build().start(); break; case LICENSE: new LibsBuilder() //provide a style (optional) (LIGHT, DARK, LIGHT_DARK_TOOLBAR) .withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR).withAboutIconShown(true) .withAboutVersionShown(true) // .withAboutDescription("T") //start the activity .start(this); break; } return true; }
From source file:com.entertailion.android.dial.ServerFinder.java
private AlertDialog buildManualIpDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = LayoutInflater.from(this).inflate(R.layout.manual_ip, null); final EditText ipEditText = (EditText) view.findViewById(R.id.manual_ip_entry); ipEditText.setFilters(new InputFilter[] { new NumberKeyListener() { @Override//from w w w . j a v a2 s.co m protected char[] getAcceptedChars() { return "0123456789.:".toCharArray(); } public int getInputType() { return InputType.TYPE_CLASS_NUMBER; } } }); SharedPreferences settings = getSharedPreferences(MainActivity.PREFS_NAME, Activity.MODE_PRIVATE); String ip = settings.getString(MANUAL_IP_ADDRESS, ""); ipEditText.setText(ip); builder.setPositiveButton(R.string.manual_ip_connect, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { DialServer DialServer = DialServerFromString(ipEditText.getText().toString()); if (DialServer != null) { connectToEntry(DialServer); try { SharedPreferences settings = getSharedPreferences(MainActivity.PREFS_NAME, Activity.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); editor.putString(MANUAL_IP_ADDRESS, ipEditText.getText().toString()); editor.commit(); } catch (Exception e) { } } else { Toast.makeText(ServerFinder.this, getString(R.string.manual_ip_error_address), Toast.LENGTH_LONG).show(); } } }).setNegativeButton(R.string.manual_ip_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }).setCancelable(true).setTitle(R.string.manual_ip_label).setMessage(R.string.manual_ip_entry_label) .setView(view); return builder.create(); }
From source file:com.sawyer.advadapters.widget.JSONAdapter.java
private void init(Context context, JSONArray objects) { mInflater = LayoutInflater.from(context); mContext = context;/* w w w. ja v a2s . c o m*/ mObjects = objects; mFilterMethods = new HashMap<>(); cacheKnownFilteredMethods(); cacheSubclassFilteredMethods(); }
From source file:br.com.mybaby.contatos.ContactDetailFragment.java
/** * Builds an address LinearLayout based on address information from the Contacts Provider. * Each address for the contact gets its own LinearLayout object; for example, if the contact * has three postal addresses, then 3 LinearLayouts are generated. *//from ww w . j av a 2s . co m * @param addressType From * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#TYPE} * @param addressTypeLabel From * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#LABEL} * @param address From * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#FORMATTED_ADDRESS} * @return A LinearLayout to add to the contact details layout, * populated with the provided address details. */ private LinearLayout buildAddressLayout(int addressType, String addressTypeLabel, final String address) { // Inflates the address layout final LinearLayout addressLayout = (LinearLayout) LayoutInflater.from(getActivity()) .inflate(R.layout.contatos_detail_item, mDetailsLayout, false); // Gets handles to the view objects in the layout final TextView headerTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_header); final TextView addressTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_item); final ImageButton viewAddressButton = (ImageButton) addressLayout.findViewById(R.id.button_view_address); // If there's no addresses for the contact, shows the empty view and message, and hides the // header and button. if (addressTypeLabel == null && addressType == 0) { headerTextView.setVisibility(View.GONE); viewAddressButton.setVisibility(View.GONE); addressTextView.setText(R.string.no_address); } else { // Gets postal address label type CharSequence label = StructuredPostal.getTypeLabel(getResources(), addressType, addressTypeLabel); // Sets TextView objects in the layout headerTextView.setText(label); addressTextView.setText(address); // Defines an onClickListener object for the address button viewAddressButton.setOnClickListener(new View.OnClickListener() { // Defines what to do when users click the address button @Override public void onClick(View view) { final Intent viewIntent = new Intent(Intent.ACTION_VIEW, constructGeoUri(address)); // A PackageManager instance is needed to verify that there's a default app // that handles ACTION_VIEW and a geo Uri. final PackageManager packageManager = getActivity().getPackageManager(); // Checks for an activity that can handle this intent. Preferred in this // case over Intent.createChooser() as it will still let the user choose // a default (or use a previously set default) for geo Uris. if (packageManager.resolveActivity(viewIntent, PackageManager.MATCH_DEFAULT_ONLY) != null) { startActivity(viewIntent); } else { // If no default is found, displays a message that no activity can handle // the view button. Toast.makeText(getActivity(), R.string.no_intent_found, Toast.LENGTH_SHORT).show(); } } }); } return addressLayout; }
From source file:com.hybris.mobile.app.commerce.fragment.ProductDetailFragmentBase.java
/** * Update the view pager for the images/*w w w.ja v a2 s .c om*/ */ protected void updateImageViewPagerIndicator(List<Image> images) { mImageAdapter.clear(); mImageAdapter.addAll(images); mViewPager.setAdapter(mImageAdapter); mViewPager.setCurrentItem(mCurrentIndicator); mImageAdapter.notifyDataSetChanged(); // for each image we create a matched indicator button with its listener for (int i = 0; i < mImageAdapter.getCount(); i++) { Button indicatorBtn = (Button) LayoutInflater.from(this.getActivity()) .inflate(R.layout.viewpager_indicator_button, mLayoutIndicator, false); if (mLayoutIndicator.findViewById(i) == null) { indicatorBtn.setId(i); indicatorBtn.setContentDescription("product_detail_image_indicator" + i); mLayoutIndicator.addView(indicatorBtn); mLayoutIndicator.findViewById(i).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { mViewPager.setCurrentItem(v.getId()); v.performClick(); return false; } }); } } if (mLayoutIndicator.findViewById(mViewPager.getCurrentItem()) != null) { mLayoutIndicator.findViewById(mViewPager.getCurrentItem()).setEnabled(false); } }