List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:android.support.design.widget.TextInputLayout.java
private void updatePasswordToggleView() { if (mEditText == null) { // If there is no EditText, there is nothing to update return;/*from w w w . ja va 2 s . co m*/ } if (shouldShowPasswordIcon()) { if (mPasswordToggleView == null) { mPasswordToggleView = (CheckableImageButton) LayoutInflater.from(getContext()) .inflate(R.layout.design_text_input_password_icon, mInputFrame, false); mPasswordToggleView.setImageDrawable(mPasswordToggleDrawable); mPasswordToggleView.setContentDescription(mPasswordToggleContentDesc); mInputFrame.addView(mPasswordToggleView); mPasswordToggleView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { passwordVisibilityToggleRequested(); } }); } if (mEditText != null && ViewCompat.getMinimumHeight(mEditText) <= 0) { // We should make sure that the EditText has the same min-height as the password // toggle view. This ensure focus works properly, and there is no visual jump // if the password toggle is enabled/disabled. mEditText.setMinimumHeight(ViewCompat.getMinimumHeight(mPasswordToggleView)); } mPasswordToggleView.setVisibility(VISIBLE); mPasswordToggleView.setChecked(mPasswordToggledVisible); // We need to add a dummy drawable as the end compound drawable so that the text is // indented and doesn't display below the toggle view if (mPasswordToggleDummyDrawable == null) { mPasswordToggleDummyDrawable = new ColorDrawable(); } mPasswordToggleDummyDrawable.setBounds(0, 0, mPasswordToggleView.getMeasuredWidth(), 1); final Drawable[] compounds = TextViewCompat.getCompoundDrawablesRelative(mEditText); // Store the user defined end compound drawable so that we can restore it later if (compounds[2] != mPasswordToggleDummyDrawable) { mOriginalEditTextEndDrawable = compounds[2]; } TextViewCompat.setCompoundDrawablesRelative(mEditText, compounds[0], compounds[1], mPasswordToggleDummyDrawable, compounds[3]); // Copy over the EditText's padding so that we match mPasswordToggleView.setPadding(mEditText.getPaddingLeft(), mEditText.getPaddingTop(), mEditText.getPaddingRight(), mEditText.getPaddingBottom()); } else { if (mPasswordToggleView != null && mPasswordToggleView.getVisibility() == VISIBLE) { mPasswordToggleView.setVisibility(View.GONE); } if (mPasswordToggleDummyDrawable != null) { // Make sure that we remove the dummy end compound drawable if it exists, and then // clear it final Drawable[] compounds = TextViewCompat.getCompoundDrawablesRelative(mEditText); if (compounds[2] == mPasswordToggleDummyDrawable) { TextViewCompat.setCompoundDrawablesRelative(mEditText, compounds[0], compounds[1], mOriginalEditTextEndDrawable, compounds[3]); mPasswordToggleDummyDrawable = null; } } } }
From source file:it.feio.android.omninotes.ListFragment.java
public void onEvent(NotesLoadedEvent notesLoadedEvent) { int layoutSelected = prefs.getBoolean(Constants.PREF_EXPANDED_VIEW, true) ? R.layout.note_layout_expanded : R.layout.note_layout;//from w ww.j a v a2 s . c om listAdapter = new NoteAdapter(mainActivity, layoutSelected, notesLoadedEvent.notes); View noteLayout = LayoutInflater.from(mainActivity).inflate(layoutSelected, null, false); noteViewHolder = new NoteViewHolder(noteLayout); if (Navigation.getNavigation() != Navigation.UNCATEGORIZED && prefs.getBoolean(Constants.PREF_ENABLE_SWIPE, true)) { list.enableSwipeToDismiss((viewGroup, reverseSortedPositions) -> { // Avoids conflicts with action mode finishActionMode(); for (int position : reverseSortedPositions) { Note note; try { note = listAdapter.getItem(position); } catch (IndexOutOfBoundsException e) { Log.d(Constants.TAG, "Please stop swiping in the zone beneath the last card"); continue; } getSelectedNotes().add(note); // Depending on settings and note status this action will... // ...restore if (Navigation.checkNavigation(Navigation.TRASH)) { trashNotes(false); } // ...removes category else if (Navigation.checkNavigation(Navigation.CATEGORY)) { categorizeNotesExecute(null); } else { // ...trash if (prefs.getBoolean("settings_swipe_to_trash", false) || Navigation.checkNavigation(Navigation.ARCHIVE)) { trashNotes(true); // ...archive } else { archiveNotes(true); } } } }); } else { list.disableSwipeToDismiss(); } list.setAdapter(listAdapter); // Replace listview with Mr. Jingles if it is empty if (notesLoadedEvent.notes.size() == 0) list.setEmptyView(empyListItem); // Restores listview position when turning back to list or when navigating reminders if (list != null && notesLoadedEvent.notes.size() > 0) { if (Navigation.checkNavigation(Navigation.REMINDERS)) { listViewPosition = listAdapter.getClosestNotePosition(); } restoreListScrollPosition(); } // Fade in the list view animate(progress_wheel).setDuration(getResources().getInteger(R.integer.list_view_fade_anim)).alpha(0); animate(list).setDuration(getResources().getInteger(R.integer.list_view_fade_anim)).alpha(1); closeFab(); }
From source file:eu.faircode.netguard.AdapterRule.java
@Override public AdapterRule.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.rule, parent, false)); }
From source file:com.quwu.xinwo.release.Release_Activity.java
/** * /* w w w. j a v a 2 s. co m*/ * PopupWindow * * */ private void showPopupWindow(View view, final int i) { // View contentView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.release_pop, null); final PopupWindow popupWindow = new PopupWindow(contentView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true); popupWindow.setOnDismissListener(new OnDismissListener() { public void onDismiss() { releaseLin.setAlpha(1f); } }); popupWindow.setTouchable(true); popupWindow.setTouchInterceptor(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return false; // true?touch // ? PopupWindowonTouchEvent?dismiss } }); // ?PopupWindowBackdismiss // APIbug popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_launcher)); // ???show int[] location = new int[2]; view.getLocationOnScreen(location); popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, location[0] + view.getWidth(), location[1] - 150); // TextView year = (TextView) contentView.findViewById(R.id.release_pop_yearText); year.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { handler.sendMessage(handler.obtainMessage(i, "/")); popupWindow.dismiss(); } }); TextView month = (TextView) contentView.findViewById(R.id.release_pop_monthText); month.setOnClickListener(new OnClickListener() { public void onClick(View v) { handler.sendMessage(handler.obtainMessage(i, "/")); popupWindow.dismiss(); } }); TextView day = (TextView) contentView.findViewById(R.id.release_pop_dayText); day.setOnClickListener(new OnClickListener() { public void onClick(View v) { handler.sendMessage(handler.obtainMessage(i, "/")); popupWindow.dismiss(); } }); }
From source file:com.dycody.android.idealnote.ListFragment.java
public void onEvent(NotesLoadedEvent notesLoadedEvent) { int layoutSelected = prefs.getBoolean(Constants.PREF_EXPANDED_VIEW, true) ? R.layout.note_layout_expanded : R.layout.note_layout;//from www . j a v a 2 s.c o m listAdapter = new NoteAdapter(mainActivity, layoutSelected, notesLoadedEvent.notes); View noteLayout = LayoutInflater.from(mainActivity).inflate(layoutSelected, null, false); noteViewHolder = new NoteViewHolder(noteLayout); if (Navigation.getNavigation() != Navigation.UNCATEGORIZED && prefs.getBoolean(Constants.PREF_ENABLE_SWIPE, true)) { list.enableSwipeToDismiss((viewGroup, reverseSortedPositions) -> { // Avoids conflicts with action mode finishActionMode(); for (int position : reverseSortedPositions) { Note note; try { note = listAdapter.getItem(position); } catch (IndexOutOfBoundsException e) { Log.d(Constants.TAG, "Please stop swiping in the zone beneath the last card"); continue; } getSelectedNotes().add(note); // Depending on settings and note status this action will... // ...restore if (Navigation.checkNavigation(Navigation.TRASH)) { trashNotes(false); } // ...removes category else if (Navigation.checkNavigation(Navigation.CATEGORY)) { categorizeNotesExecute(null); } else { // ...trash if (prefs.getBoolean("settings_swipe_to_trash", false) || Navigation.checkNavigation(Navigation.ARCHIVE)) { trashNotes(true); // ...archive } else { archiveNotes(true); } } } }); } else { list.disableSwipeToDismiss(); } list.setAdapter(listAdapter); // Replace listview with Mr. Jingles if it is empty if (notesLoadedEvent.notes.size() == 0) list.setEmptyView(empyListItem); // Restores listview position when turning back to list or when navigating reminders if (list != null && notesLoadedEvent.notes.size() > 0) { if (Navigation.checkNavigation(Navigation.REMINDERS)) { listViewPosition = listAdapter.getClosestNotePosition(); } restoreListScrollPosition(); } animateListView(); closeFab(); }
From source file:github.popeen.dsub.fragments.SelectDirectoryFragment.java
private View createHeader() { View header = LayoutInflater.from(context).inflate(R.layout.select_album_header, null, false); setupCoverArt(header);//from w ww . ja v a 2 s . co m setupTextDisplay(header); setupButtonEvents(header); return header; }
From source file:org.ednovo.goorusearchwidget.SearchResults_resource.java
public LinearLayout createResourceEmptyView() { LinearLayout scrollChild = new LinearLayout(this); scrollChild.setPadding(10, 0, 10, 0); resourcelayout = LayoutInflater.from(this).inflate(R.layout.resource_view, null); TextView title = (TextView) resourcelayout.findViewById(R.id.textViewTitle); title.setText("Sorry! No Results Found"); title.setTextColor(getResources().getColor(R.color.Grey)); title.setPadding(50, 50, 0, 10);/*from www.j a v a2s .co m*/ title.setTextSize(25); scrollChild.addView(resourcelayout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT)); scrollChild.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); return scrollChild; }
From source file:cm.aptoide.pt.MainActivity.java
public void showAbout() { View aboutView = LayoutInflater.from(this).inflate(R.layout.dialog_about, null); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this).setView(aboutView); final AlertDialog aboutDialog = dialogBuilder.create(); aboutDialog.setIcon(android.R.drawable.ic_menu_help); aboutDialog.setTitle(getString(R.string.about)); aboutDialog.setCancelable(true);// w w w. j a v a 2s .c o m WindowManager.LayoutParams params = aboutDialog.getWindow().getAttributes(); params.width = WindowManager.LayoutParams.MATCH_PARENT; aboutDialog.getWindow().setAttributes(params); aboutDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.btn_chlog), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Uri uri = Uri.parse(getString(R.string.change_log_url)); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); aboutDialog.show(); }
From source file:cm.aptoide.pt.MainActivity.java
private void displayOptionsDialog() { final SharedPreferences sPref = PreferenceManager.getDefaultSharedPreferences(this); final Editor editor = sPref.edit(); View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_order_popup, null); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(view); final AlertDialog orderDialog = dialogBuilder.create(); orderDialog.setIcon(android.R.drawable.ic_menu_sort_by_size); orderDialog.setTitle(getString(R.string.menu_display_options)); orderDialog.setCancelable(true);//from w w w. j a v a2 s . c o m final RadioButton ord_rct = (RadioButton) view.findViewById(R.id.org_rct); final RadioButton ord_abc = (RadioButton) view.findViewById(R.id.org_abc); final RadioButton ord_rat = (RadioButton) view.findViewById(R.id.org_rat); final RadioButton ord_dwn = (RadioButton) view.findViewById(R.id.org_dwn); final RadioButton ord_price = (RadioButton) view.findViewById(R.id.org_price); final RadioButton btn1 = (RadioButton) view.findViewById(R.id.shw_ct); final RadioButton btn2 = (RadioButton) view.findViewById(R.id.shw_all); final ToggleButton adult = (ToggleButton) view.findViewById(R.id.adultcontent_toggle); orderDialog.setButton(Dialog.BUTTON_NEUTRAL, "Ok", new Dialog.OnClickListener() { boolean pop_change = false; private boolean pop_change_category = false; public void onClick(DialogInterface dialog, int which) { if (ord_rct.isChecked()) { pop_change = true; order = Order.DATE; } else if (ord_abc.isChecked()) { pop_change = true; order = Order.NAME; } else if (ord_rat.isChecked()) { pop_change = true; order = Order.RATING; } else if (ord_dwn.isChecked()) { pop_change = true; order = Order.DOWNLOADS; } else if (ord_price.isChecked()) { pop_change = true; order = Order.PRICE; } if (btn1.isChecked()) { pop_change = true; pop_change_category = true; editor.putBoolean("orderByCategory", true); } else if (btn2.isChecked()) { pop_change = true; pop_change_category = true; editor.putBoolean("orderByCategory", false); } if (adult.isChecked()) { pop_change = true; editor.putBoolean("matureChkBox", false); } else { editor.putBoolean("matureChkBox", true); } if (pop_change) { editor.putInt("order_list", order.ordinal()); editor.commit(); if (pop_change_category) { if (!depth.equals(ListDepth.CATEGORY1) && !depth.equals(ListDepth.STORES)) { if (depth.equals(ListDepth.APPLICATIONS)) { removeLastBreadCrumb(); } removeLastBreadCrumb(); depth = ListDepth.CATEGORY1; } } redrawAll(); refreshAvailableList(true); } } }); if (sPref.getBoolean("orderByCategory", false)) { btn1.setChecked(true); } else { btn2.setChecked(true); } if (!ApplicationAptoide.MATURECONTENTSWITCH) { adult.setVisibility(View.GONE); view.findViewById(R.id.dialog_adult_content_label).setVisibility(View.GONE); } adult.setChecked(!sPref.getBoolean("matureChkBox", false)); // adult.setOnCheckedChangeListener(adultCheckedListener); switch (order) { case DATE: ord_rct.setChecked(true); break; case DOWNLOADS: ord_dwn.setChecked(true); break; case NAME: ord_abc.setChecked(true); break; case RATING: ord_rat.setChecked(true); break; case PRICE: ord_price.setChecked(true); break; default: break; } orderDialog.show(); }
From source file:dentex.youtube.downloader.DashboardActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); String previousJson = Json.readJsonDashboardFile(sDashboard); boolean smtInProgressOrPaused = (previousJson.contains(YTD.JSON_DATA_STATUS_IN_PROGRESS) || previousJson.contains(YTD.JSON_DATA_STATUS_PAUSED)); switch (item.getItemId()) { case R.id.menu_search: BugSenseHandler.leaveBreadcrumb("ShareActivity_menu_search"); if (!isSearchBarVisible) { spawnSearchBar();/*from ww w . j a v a 2 s. c om*/ } else { hideSearchBar(); } return true; case R.id.menu_backup: BugSenseHandler.leaveBreadcrumb("ShareActivity_menu_backup"); if (YTD.JSON_FILE.exists() && !previousJson.equals("{}\n") && !smtInProgressOrPaused) { boolean backupCheckboxEnabled = YTD.settings.getBoolean("dashboard_backup_info", true); if (backupCheckboxEnabled == true) { AlertDialog.Builder adb = new AlertDialog.Builder(boxThemeContextWrapper); LayoutInflater adbInflater = LayoutInflater.from(DashboardActivity.this); View showAgainView = adbInflater.inflate(R.layout.dialog_show_again_checkbox, null); final CheckBox showAgain = (CheckBox) showAgainView.findViewById(R.id.showAgain2); showAgain.setChecked(true); adb.setView(showAgainView); adb.setTitle(getString(R.string.information)); adb.setMessage(getString(R.string.menu_backup_info)); adb.setIcon(android.R.drawable.ic_dialog_info); adb.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (!showAgain.isChecked()) { YTD.settings.edit().putBoolean("dashboard_backup_info", false).apply(); Utils.logger("d", "dashboard backup info checkbox disabled", DEBUG_TAG); } launchFcForBackup(); } }); adb.setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // cancel } }); secureShowDialog(adb); } else { launchFcForBackup(); } } else { toastOpsNotExecuted(); } return true; case R.id.menu_restore: BugSenseHandler.leaveBreadcrumb("ShareActivity_menu_restore"); if (!smtInProgressOrPaused) { boolean restoreCheckboxEnabled = YTD.settings.getBoolean("dashboard_restore_info", true); if (restoreCheckboxEnabled == true) { AlertDialog.Builder adb = new AlertDialog.Builder(boxThemeContextWrapper); LayoutInflater adbInflater = LayoutInflater.from(DashboardActivity.this); View showAgainView = adbInflater.inflate(R.layout.dialog_show_again_checkbox, null); final CheckBox showAgain = (CheckBox) showAgainView.findViewById(R.id.showAgain2); showAgain.setChecked(true); adb.setView(showAgainView); adb.setTitle(getString(R.string.information)); adb.setMessage(getString(R.string.menu_restore_info) + ".\n" + getString(R.string.menu_restore_info_msg)); adb.setIcon(android.R.drawable.ic_dialog_info); adb.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (!showAgain.isChecked()) { YTD.settings.edit().putBoolean("dashboard_restore_info", false).apply(); Utils.logger("d", "dashboard restore info checkbox disabled", DEBUG_TAG); } launchFcForRestore(); } }); adb.setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // cancel } }); secureShowDialog(adb); } else { launchFcForRestore(); } } else { toastOpsNotExecuted(); } return true; case R.id.menu_import: BugSenseHandler.leaveBreadcrumb("ShareActivity_menu_import"); boolean importCheckboxEnabled1 = YTD.settings.getBoolean("dashboard_import_info", true); if (importCheckboxEnabled1 == true) { AlertDialog.Builder adb = new AlertDialog.Builder(boxThemeContextWrapper); LayoutInflater adbInflater = LayoutInflater.from(DashboardActivity.this); View showAgainView = adbInflater.inflate(R.layout.dialog_show_again_checkbox, null); final CheckBox showAgain = (CheckBox) showAgainView.findViewById(R.id.showAgain2); showAgain.setChecked(true); adb.setView(showAgainView); adb.setTitle(getString(R.string.information)); adb.setMessage(getString(R.string.menu_import_info)); adb.setIcon(android.R.drawable.ic_dialog_info); adb.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (!showAgain.isChecked()) { YTD.settings.edit().putBoolean("dashboard_import_info", false).apply(); Utils.logger("d", "dashboard import info checkbox disabled", DEBUG_TAG); } launchFcForImport(); } }); adb.setNegativeButton(R.string.dialogs_negative, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // cancel } }); secureShowDialog(adb); } else { launchFcForImport(); } return true; default: return super.onOptionsItemSelected(item); } }