List of usage examples for android.view View inflate
public static View inflate(Context context, @LayoutRes int resource, ViewGroup root)
From source file:org.mythtv.client.ui.dvr.VideoActivity.java
private void startVideo(boolean raw) { Log.v(TAG, "startVideo : enter"); Log.v(TAG, "startVideo : program=" + program.toString()); String temp = mLocationProfile.getUrl(); temp = temp.replaceAll("/$", ""); String url = ""; if (raw) {/*from w ww .j a v a 2 s.com*/ url = temp + "/Content/GetFile?StorageGroup=" + program.getRecording().getStorageGroup() + "&FileName=" + program.getFilename(); } else { url = temp + liveStreamInfo.getRelativeUrl(); } Log.v(TAG, "URL: " + url); if (null != progressDialog) { progressDialog.dismiss(); progressDialog = null; } final Intent tostart = new Intent(Intent.ACTION_VIEW); // tostart.setFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); // tostart.setDataAndType( Uri.parse(url), "application/x-mpegurl" ); // tostart.setDataAndType( Uri.parse(url), "application/vnd.apple.mpegurl" ); tostart.setDataAndType(Uri.parse(url), "video/*"); if (!preferences.getBoolean(DISMISS, false)) { Log.v(TAG, "startVideo : displaying warning"); View dismissView = View.inflate(this, R.layout.dismiss_checkbox, null); CheckBox dismiss = (CheckBox) dismissView.findViewById(R.id.dismiss); dismiss.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { setDismissPreferences(isChecked); } }); dismiss.setText(getString(R.string.video_playback_doNotDisplay)); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.video_playback_title).setMessage(R.string.video_playback_message) .setView(dismissView) .setPositiveButton(R.string.video_playback_button_play, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivity(tostart); } }).setNegativeButton(R.string.video_playback_button_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }) .show(); } else { Log.v(TAG, "startVideo : not displaying warning"); startActivity(tostart); } Log.v(TAG, "startVideo : exit"); }
From source file:chinanurse.cn.nurse.Fragment_Nurse.EmployFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mView = View.inflate(getActivity(), R.layout.nurse_employ_secondpage, null); user = new UserBean(getActivity()); return mView; }
From source file:com.nextgis.ngm_clink_monitoring.dialogs.YesNoDialog.java
protected void setMessageView() { LinearLayout layout = (LinearLayout) View.inflate(getActivity(), R.layout.dialog_yes_no_message, null); mMessage = (TextView) layout.findViewById(R.id.dialog_message_yn); mDialogBodyScroll.setVisibility(View.VISIBLE); mDialogBodyLayoutScrolled.addView(layout); }
From source file:com.app.blockydemo.content.bricks.SetVariableBrick.java
@Override public View getPrototypeView(Context context) { View prototypeView = View.inflate(context, R.layout.brick_set_variable, null); Spinner variableSpinner = (Spinner) prototypeView.findViewById(R.id.set_variable_spinner); variableSpinner.setFocusableInTouchMode(false); variableSpinner.setFocusable(false); UserVariableAdapter userVariableAdapter = ProjectManager.getInstance().getCurrentProject() .getUserVariables().createUserVariableAdapter(context, sprite); UserVariableAdapterWrapper userVariableAdapterWrapper = new UserVariableAdapterWrapper(context, userVariableAdapter);// w w w. j a v a2 s .co m userVariableAdapterWrapper.setItemLayout(android.R.layout.simple_spinner_item, android.R.id.text1); variableSpinner.setAdapter(userVariableAdapterWrapper); setSpinnerSelection(variableSpinner, null); TextView textSetVariable = (TextView) prototypeView.findViewById(R.id.brick_set_variable_prototype_view); textSetVariable.setText(String.valueOf(variableFormula.interpretDouble(sprite))); return prototypeView; }
From source file:com.app.blockydemo.content.bricks.ChangeVariableBrick.java
@Override public View getPrototypeView(Context context) { View prototypeView = View.inflate(context, R.layout.brick_change_variable_by, null); Spinner variableSpinner = (Spinner) prototypeView.findViewById(R.id.change_variable_spinner); variableSpinner.setFocusableInTouchMode(false); variableSpinner.setFocusable(false); UserVariableAdapter changeVariableSpinnerAdapter = ProjectManager.getInstance().getCurrentProject() .getUserVariables().createUserVariableAdapter(context, sprite); UserVariableAdapterWrapper userVariableAdapterWrapper = new UserVariableAdapterWrapper(context, changeVariableSpinnerAdapter); userVariableAdapterWrapper.setItemLayout(android.R.layout.simple_spinner_item, android.R.id.text1); variableSpinner.setAdapter(userVariableAdapterWrapper); setSpinnerSelection(variableSpinner, null); TextView textChangeVariable = (TextView) prototypeView .findViewById(R.id.brick_change_variable_prototype_view); textChangeVariable.setText(String.valueOf(variableFormula.interpretDouble(sprite))); return prototypeView; }
From source file:de.baumann.browser.popups.Popup_pass.java
private void setFilesList() { //display data final int layoutstyle = R.layout.list_item; int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes }; String[] column = new String[] { "pass_title", "pass_content", "pass_creation" }; final Cursor row = db.fetchAllData(this); SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0); listView.setAdapter(adapter);/*from w w w.java 2s. c o m*/ //onClick function listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String pass_content = row2.getString(row2.getColumnIndexOrThrow("pass_content")); final String pass_icon = row2.getString(row2.getColumnIndexOrThrow("pass_icon")); final String pass_attachment = row2.getString(row2.getColumnIndexOrThrow("pass_attachment")); try { String decrypted_userName = mahEncryptor.decode(pass_icon); String decrypted_userPW = mahEncryptor.decode(pass_attachment); sharedPref.edit().putString("copyPW", decrypted_userPW).apply(); sharedPref.edit().putString("copyUN", decrypted_userName).apply(); sharedPref.edit().putString("openURL", "openLogin" + pass_content).apply(); finishAffinity(); } catch (Exception e) { e.printStackTrace(); Snackbar.make(listView, R.string.toast_error, Snackbar.LENGTH_SHORT).show(); } } }); listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { Cursor row2 = (Cursor) listView.getItemAtPosition(position); final String _id = row2.getString(row2.getColumnIndexOrThrow("_id")); final String pass_title = row2.getString(row2.getColumnIndexOrThrow("pass_title")); final String pass_content = row2.getString(row2.getColumnIndexOrThrow("pass_content")); final String pass_icon = row2.getString(row2.getColumnIndexOrThrow("pass_icon")); final String pass_attachment = row2.getString(row2.getColumnIndexOrThrow("pass_attachment")); final CharSequence[] options = { getString(R.string.pass_copy), getString(R.string.pass_edit), getString(R.string.bookmark_remove_bookmark) }; new AlertDialog.Builder(Popup_pass.this) .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }).setItems(options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int item) { if (options[item].equals(getString(R.string.pass_edit))) { try { AlertDialog.Builder builder = new AlertDialog.Builder(Popup_pass.this); View dialogView = View.inflate(Popup_pass.this, R.layout.dialog_login, null); final EditText pass_titleET = (EditText) dialogView .findViewById(R.id.pass_title); final EditText pass_userNameET = (EditText) dialogView .findViewById(R.id.pass_userName); final EditText pass_userPWET = (EditText) dialogView .findViewById(R.id.pass_userPW); final String decrypted_userName = mahEncryptor.decode(pass_icon); final String decrypted_userPW = mahEncryptor.decode(pass_attachment); pass_titleET.setText(pass_title); pass_userNameET.setText(decrypted_userName); pass_userPWET.setText(decrypted_userPW); builder.setView(dialogView); builder.setTitle(R.string.pass_edit); builder.setPositiveButton(R.string.toast_yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { try { String input_pass_title = pass_titleET.getText() .toString().trim(); String encrypted_userName = mahEncryptor.encode( pass_userNameET.getText().toString().trim()); String encrypted_userPW = mahEncryptor.encode( pass_userPWET.getText().toString().trim()); db.update(Integer.parseInt(_id), input_pass_title, pass_content, encrypted_userName, encrypted_userPW, helper_main.createDate()); setFilesList(); Snackbar.make(listView, R.string.pass_success, Snackbar.LENGTH_SHORT).show(); } catch (Exception e) { e.printStackTrace(); Snackbar.make(listView, R.string.toast_error, Snackbar.LENGTH_SHORT).show(); } } }); builder.setNegativeButton(R.string.toast_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { dialog.cancel(); } }); final AlertDialog dialog2 = builder.create(); // Display the custom alert dialog on interface dialog2.show(); helper_editText.showKeyboard(Popup_pass.this, pass_titleET, 0, pass_title, getString(R.string.app_search_hint_bookmark)); } catch (Exception e) { e.printStackTrace(); Snackbar.make(listView, R.string.toast_error, Snackbar.LENGTH_SHORT).show(); } } if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) { Snackbar snackbar = Snackbar .make(listView, R.string.bookmark_remove_confirmation, Snackbar.LENGTH_LONG) .setAction(R.string.toast_yes, new View.OnClickListener() { @Override public void onClick(View view) { db.delete(Integer.parseInt(_id)); setFilesList(); } }); snackbar.show(); } if (options[item].equals(getString(R.string.pass_copy))) { try { String decrypted_userName = mahEncryptor.decode(pass_icon); String decrypted_userPW = mahEncryptor.decode(pass_attachment); sharedPref.edit().putString("copyPW", decrypted_userPW).apply(); sharedPref.edit().putString("copyUN", decrypted_userName).apply(); sharedPref.edit().putString("openURL", "copyLogin").apply(); finishAffinity(); } catch (Exception e) { e.printStackTrace(); Snackbar.make(listView, R.string.toast_error, Snackbar.LENGTH_SHORT).show(); } } } }).show(); return true; } }); }
From source file:app.hanks.com.conquer.activity.MainActivity.java
/** * ?popupWindow/*from www. j a v a2 s .co m*/ */ private void showSelectSort() { View v = View.inflate(context, R.layout.pop_sort, null); // v.findViewById(R.id.refresh).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { popWin.dismiss(); } }); //? v.findViewById(R.id.change).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (currentFragment == myTaskFragment) { currentFragment = otherTaskFragment; } else { currentFragment = myTaskFragment; } changeFramgnt(R.id.layout_content, currentFragment); popWin.dismiss(); } }); popWin = new PopupWindow(v, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT); popWin.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.card_bg)); // popWin.setFocusable(true); popWin.setOutsideTouchable(true); // popWin // // popWin.showAtLocation(iv_sort, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0); // ?? popWin.showAsDropDown(iv_sort, 0, -iv_sort.getHeight() + 10); }
From source file:id.ridon.keude.Keude.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_update_repo: updateRepos();// w w w .j a v a 2 s . com return true; case R.id.action_manage_repos: Intent i = new Intent(this, ManageReposActivity.class); startActivityForResult(i, REQUEST_MANAGEREPOS); return true; case R.id.action_settings: Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class); startActivityForResult(prefs, REQUEST_PREFS); return true; case R.id.action_swap: startActivity(new Intent(this, SwapActivity.class)); return true; case R.id.action_search: onSearchRequested(); return true; case R.id.action_bluetooth_apk: /* * If Bluetooth has not been enabled/turned on, then enabling * device discoverability will automatically enable Bluetooth */ Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121); startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH); // if this is successful, the Bluetooth transfer is started return true; case R.id.action_about: View view = null; if (Build.VERSION.SDK_INT >= 11) { LayoutInflater li = LayoutInflater.from(this); view = li.inflate(R.layout.about, null); } else { view = View.inflate(new ContextThemeWrapper(this, R.style.AboutDialogLight), R.layout.about, null); } // Fill in the version... try { PackageInfo pi = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0); ((TextView) view.findViewById(R.id.version)).setText(pi.versionName); } catch (Exception e) { } Builder p = null; if (Build.VERSION.SDK_INT >= 11) { p = new AlertDialog.Builder(this).setView(view); } else { p = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AboutDialogLight)).setView(view); } final AlertDialog alrt = p.create(); alrt.setIcon(R.drawable.ic_launcher); alrt.setTitle(getString(R.string.about_title)); alrt.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.about_website), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { Uri uri = Uri.parse("https://f-droid.org"); startActivity(new Intent(Intent.ACTION_VIEW, uri)); } }); alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { } }); alrt.show(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.frostwire.android.gui.adapters.FileListAdapter.java
private View getGridItemView(final int position, View view) { final FileDescriptorItem item = getItem(position); Context ctx = getContext();//from w w w. j a v a 2s. com if (view == null && ctx != null) { // every list view item is wrapped in a generic container which has a hidden checkbox on the left hand side. view = View.inflate(ctx, R.layout.view_my_files_thumbnail_grid_item, null); } try { initCheckableGridImageView((RelativeLayout) view, item); // toggles checkbox mode. initTouchFeedback(view, item, v -> { // background image listener if (selectAllMode) { onItemClicked(v); } else { if (item.fd.fileType == Constants.FILE_TYPE_VIDEOS) { LOG.info("getGridItemView() Background ImageView.onClick(), show the menu"); MenuAdapter menuAdapter = getMenuAdapter(v); if (menuAdapter != null) { new MenuBuilder(menuAdapter).show(); } } else { localPlay(item.fd, v, position); } } }, this::onItemLongClicked, null); initPlaybackStatusOverlayTouchFeedback(view, item); } catch (Throwable e) { LOG.error("Fatal error getting view: " + e.getMessage(), e); } return view; }
From source file:com.xxxifan.devbox.core.base.BaseFragment.java
/** * attach a toolbar in fragment//from ww w .j av a 2s.c o m * * @param rootView root view that toolbar attach to * @param darkTheme dark theme used in colorful toolbar with white title, light theme in light background with dark title. * @return true if success */ protected boolean attachToolbar(View rootView, String title, @ColorInt int toolbarColor, boolean darkTheme) { if (isAdded() && getView() != null) { View toolbarView = View.inflate(getContext(), darkTheme ? R.layout._internal_view_toolbar_dark : R.layout._internal_view_toolbar_light, null); toolbarView.setBackgroundColor(toolbarColor); ((Toolbar) toolbarView).setTitle(title); ((ViewGroup) rootView).addView(toolbarView, 0); return true; } return false; }