List of usage examples for android.view LayoutInflater from
public static LayoutInflater from(Context context)
From source file:edu.missouri.bas.activities.AdminManageActivity.java
private Dialog AdminPinDialog(Context context) { LayoutInflater inflater = LayoutInflater.from(this); final View textEntryView = inflater.inflate(R.layout.pin_login, null); alert_text = (TextView) textEntryView.findViewById(R.id.pin_text); alert_text.setText("Please input PIN for administrator"); AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false);// w w w . ja va 2 s. c o m builder.setTitle("Verify Admin PIN"); builder.setView(textEntryView); //builder.setMessage("Please input PIN for administrator"); builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //check networking adminPin = (EditText) textEntryView.findViewById(R.id.pin_edit); String AdPin = adminPin.getText().toString(); Log.d(TAG, "get from edittext is " + AdPin); HttpPost request = new HttpPost( "http://dslsrv8.cs.missouri.edu/~rs79c/Server/Crt/validateUser.php"); List<NameValuePair> params = new ArrayList<NameValuePair>(); //file_name params.add(new BasicNameValuePair("userID", "0000")); //function params.add(new BasicNameValuePair("pre", "1")); //data params.add(new BasicNameValuePair("password", AdPin)); 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 //setResult(8); } else if (result.equals("AdminPinIsInvalid")) { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast toast = Toast.makeText(getApplicationContext(), "Admin PIN is wrong, exit! Please try again.", Toast.LENGTH_SHORT); toast.show(); //set return code /* if(shp.getString(ASID, "").equals("")){ setResult(9); }else{ setResult(Activity.RESULT_CANCELED); }*/ //setResult(9); finish(); } else { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast toast = Toast.makeText(getApplicationContext(), "Verify failed. Please try again.", Toast.LENGTH_SHORT); toast.show(); //set return code /* if(shp.getString(ASID, "").equals("")){ setResult(9); }else{ setResult(Activity.RESULT_CANCELED); }*/ finish(); } } } catch (Exception e) { // TODO Auto-generated catch block imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); Toast toast = Toast.makeText(getApplicationContext(), "Failed. Please try again, with network connection.", Toast.LENGTH_SHORT); toast.show(); //set return code /* if(shp.getString(ASID, "").equals("")){ setResult(9); }else{ setResult(Activity.RESULT_CANCELED); }*/ finish(); e.printStackTrace(); } } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN); imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); //set return code /* if(shp.getString(ASID, "").equals("")){ setResult(9); }else{ setResult(Activity.RESULT_CANCELED); }*/ setResult(9); finish(); } }); return builder.create(); }
From source file:com.hackensack.umc.activity.ProfileSelfieActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { imageUri = Uri.parse(savedInstanceState.getString(Constant.CAPTURE_IMAGE_URI)); }// w w w .j a v a 2 s.co 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); }
From source file:com.brewcrewfoo.performance.activities.PCSettings.java
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { String key = preference.getKey(); if (key.equals("use_light_theme")) { mPreferences.edit().putBoolean("theme_changed", true).commit(); finish();/*from ww w. j a v a 2s . c o m*/ return true; } else if (key.equals("visible_tabs")) { startActivity(new Intent(this, HideTabs.class)); return true; } else if (key.equals("boot_mode")) { if (mInitd.isChecked()) { LayoutInflater factory = LayoutInflater.from(this); final View editDialog = factory.inflate(R.layout.prop_edit_dialog, null); final EditText tv = (EditText) editDialog.findViewById(R.id.vprop); final TextView tn = (TextView) editDialog.findViewById(R.id.nprop); tv.setText(mPreferences.getString("script_name", "99PC")); tn.setText(""); tn.setVisibility(TextView.GONE); new AlertDialog.Builder(this).setTitle(getString(R.string.pt_script_name)).setView(editDialog) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String s = tv.getText().toString(); if ((s != null) && (s.length() > 0)) { mPreferences.edit().putString("script_name", s).apply(); } mInitd.setSummary(INIT_D + mPreferences.getString("script_name", "99PC")); new BootClass(c, mPreferences).writeScript(); } }).create().show(); } else { final StringBuilder sb = new StringBuilder(); sb.append("mount -o rw,remount /system;\n"); sb.append("busybox rm ").append(INIT_D).append(mPreferences.getString("script_name", "99PC")) .append(";\n"); sb.append("mount -o ro,remount /system;\n"); Helpers.shExec(sb, c, true); } return true; } else if (key.equals("int_sd")) { LayoutInflater factory = LayoutInflater.from(this); final View editDialog = factory.inflate(R.layout.prop_edit_dialog, null); final EditText tv = (EditText) editDialog.findViewById(R.id.vprop); final TextView tn = (TextView) editDialog.findViewById(R.id.nprop); tv.setText(""); tn.setText(getString(R.string.info_auto_sd)); new AlertDialog.Builder(this).setTitle(getString(R.string.pt_int_sd)).setView(editDialog) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String s = tv.getText().toString(); if ((s != null) && (s.length() > 0)) { if (s.endsWith("/")) { s = s.substring(0, s.length() - 1); } if (!s.startsWith("/")) { s = "/" + s; } final File dir = new File(s); if (dir.exists() && dir.isDirectory() && dir.canRead() && dir.canWrite()) mPreferences.edit().putString("int_sd_path", s).apply(); } else { mPreferences.edit().remove("int_sd_path").apply(); } mIntSD.setSummary(mPreferences.getString("int_sd_path", Environment.getExternalStorageDirectory().getAbsolutePath())); } }).create().show(); } else if (key.equals("ext_sd")) { LayoutInflater factory = LayoutInflater.from(this); final View editDialog = factory.inflate(R.layout.prop_edit_dialog, null); final EditText tv = (EditText) editDialog.findViewById(R.id.vprop); final TextView tn = (TextView) editDialog.findViewById(R.id.nprop); tv.setText(""); tn.setText(getString(R.string.info_auto_sd)); new AlertDialog.Builder(this).setTitle(getString(R.string.pt_ext_sd)).setView(editDialog) .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String s = tv.getText().toString(); if ((s != null) && (s.length() > 0)) { if (s.endsWith("/")) { s = s.substring(0, s.length() - 1); } if (!s.startsWith("/")) { s = "/" + s; } final File dir = new File(s); if (dir.exists() && dir.isDirectory() && dir.canRead() && dir.canWrite()) mPreferences.edit().putString("ext_sd_path", s).apply(); } else { mPreferences.edit().remove("ext_sd_path").apply(); } mExtSD.setSummary(mPreferences.getString("ext_sd_path", Helpers.extSD())); } }).create().show(); } else if (key.equals("br_op")) { startActivity(new Intent(this, BackupRestore.class)); } else if (key.equals("version_info")) { if (isupdate && !NO_UPDATE) { LayoutInflater factory = LayoutInflater.from(this); final View editDialog = factory.inflate(R.layout.ver_dialog, null); final TextView msg = (TextView) editDialog.findViewById(R.id.msg); msg.setText(det); new AlertDialog.Builder(c).setView(editDialog).setTitle(getString(R.string.pt_update)) .setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }) .setPositiveButton(getString(R.string.btn_download), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (isDownloadManagerAvailable(c)) { String url = URL + TAG + ".apk"; DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); //request.setDescription(""); request.setTitle(TAG + " " + ver); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { request.allowScanningByMediaScanner(); request.setNotificationVisibility( DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); } request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, TAG + "-" + ver + ".apk"); DownloadManager manager = (DownloadManager) getSystemService( Context.DOWNLOAD_SERVICE); manager.enqueue(request); } else { Toast.makeText(c, getString(R.string.no_download_manager), Toast.LENGTH_LONG) .show(); } } }).create().show(); } return true; } else if (key.equals("pref_donate")) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(PAYPAL + PAYPAL_BTN))); } return false; }
From source file:com.manning.androidhacks.hack041.ArticleActivity.java
private void addCommentPrompt() { View body = LayoutInflater.from(this).inflate(R.layout.comment_dialog, null); final EditText nameEditText = (EditText) body.findViewById(R.id.name); final EditText commentEditText = (EditText) body.findViewById(R.id.comment); new AlertDialog.Builder(this).setTitle("Add Comment").setView(body) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override/*from ww w . j a v a 2s .c o m*/ public void onClick(DialogInterface dialogInterface, int i) { String name = nameEditText.getText().toString().trim(); String comments = commentEditText.getText().toString().trim(); if (!name.equals("") && !comments.equals("")) { insertComment(name, comments); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { // do nothing } }).show(); }
From source file:com.hackensack.umc.activity.ProfileSelfiewithCropActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //setContentView(R.layout.activity_profile_selfie); getSupportActionBar().setDisplayHomeAsUpEnabled(true); if (savedInstanceState != null) { try {//from w w w .j ava 2 s .co m imageUri = Uri.parse(savedInstanceState.getString("image-path")); } catch (Exception e) { } } 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); }
From source file:com.test.hwautotest.emmagee.service.EmmageeService.java
@Override public void onStart(Intent intent, int startId) { Log.i(LOG_TAG, "onStart"); setForeground(true);/*w w w. j a v a2 s. c o m*/ super.onStart(intent, startId); pid = intent.getExtras().getInt("pid"); uid = intent.getExtras().getInt("uid"); processName = intent.getExtras().getString("processName"); packageName = intent.getExtras().getString("packageName"); settingTempFile = intent.getExtras().getString("settingTempFile"); cpuInfo = new CpuInfo(getBaseContext(), pid, Integer.toString(uid)); readSettingInfo(intent); delaytime = Integer.parseInt(time) * 1000; if (isFloating) { viFloatingWindow = LayoutInflater.from(this).inflate(R.layout.emmagee_floating, null); txtUnusedMem = (TextView) viFloatingWindow.findViewById(R.id.memunused); txtTotalMem = (TextView) viFloatingWindow.findViewById(R.id.memtotal); txtTraffic = (TextView) viFloatingWindow.findViewById(R.id.traffic); btnWifi = (Button) viFloatingWindow.findViewById(R.id.wifi); wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); if (wifiManager.isWifiEnabled()) { btnWifi.setText(R.string.closewifi); } else { btnWifi.setText(R.string.openwifi); } txtUnusedMem.setText(",??..."); txtUnusedMem.setTextColor(android.graphics.Color.RED); txtTotalMem.setTextColor(android.graphics.Color.RED); txtTraffic.setTextColor(android.graphics.Color.RED); imgClose = (ImageView) viFloatingWindow.findViewById(R.id.emmagee_close); linLayout = (LinearLayout) viFloatingWindow.findViewById(R.id.Lin); imgMeminfo = (ImageView) viFloatingWindow.findViewById(R.id.emmagee_meminfo); createFloatingWindow(); } createResultCsv(); handler.postDelayed(task, 1000); }
From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java
public ToolbarWidgetWrapper(Toolbar toolbar, boolean style, int defaultNavigationContentDescription, int defaultNavigationIcon) { mToolbar = toolbar;//from ww w . j a v a2s . co m mTitle = toolbar.getTitle(); mSubtitle = toolbar.getSubtitle(); mTitleSet = mTitle != null; mNavIcon = toolbar.getNavigationIcon(); if (style) { final TintTypedArray a = TintTypedArray.obtainStyledAttributes(toolbar.getContext(), null, R.styleable.ActionBar, R.attr.actionBarStyle, 0); final CharSequence title = a.getText(R.styleable.ActionBar_title); if (!TextUtils.isEmpty(title)) { setTitle(title); } final CharSequence subtitle = a.getText(R.styleable.ActionBar_subtitle); if (!TextUtils.isEmpty(subtitle)) { setSubtitle(subtitle); } final Drawable logo = a.getDrawable(R.styleable.ActionBar_logo); if (logo != null) { setLogo(logo); } final Drawable icon = a.getDrawable(R.styleable.ActionBar_icon); if (mNavIcon == null && icon != null) { setIcon(icon); } final Drawable navIcon = a.getDrawable(R.styleable.ActionBar_homeAsUpIndicator); if (navIcon != null) { setNavigationIcon(navIcon); } setDisplayOptions(a.getInt(R.styleable.ActionBar_displayOptions, 0)); final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0); if (customNavId != 0) { setCustomView(LayoutInflater.from(mToolbar.getContext()).inflate(customNavId, mToolbar, false)); setDisplayOptions(mDisplayOpts | ActionBar.DISPLAY_SHOW_CUSTOM); } final int height = a.getLayoutDimension(R.styleable.ActionBar_height, 0); if (height > 0) { final ViewGroup.LayoutParams lp = mToolbar.getLayoutParams(); lp.height = height; mToolbar.setLayoutParams(lp); } final int contentInsetStart = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetStart, -1); final int contentInsetEnd = a.getDimensionPixelOffset(R.styleable.ActionBar_contentInsetEnd, -1); if (contentInsetStart >= 0 || contentInsetEnd >= 0) { mToolbar.setContentInsetsRelative(Math.max(contentInsetStart, 0), Math.max(contentInsetEnd, 0)); } final int titleTextStyle = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0); if (titleTextStyle != 0) { mToolbar.setTitleTextAppearance(mToolbar.getContext(), titleTextStyle); } final int subtitleTextStyle = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0); if (subtitleTextStyle != 0) { mToolbar.setSubtitleTextAppearance(mToolbar.getContext(), subtitleTextStyle); } final int popupTheme = a.getResourceId(R.styleable.ActionBar_popupTheme, 0); if (popupTheme != 0) { mToolbar.setPopupTheme(popupTheme); } a.recycle(); // Keep the TintManager in case we need it later mTintManager = a.getTintManager(); } else { mDisplayOpts = detectDisplayOptions(); // Create a TintManager in case we need it later mTintManager = new TintManager(toolbar.getContext()); } setDefaultNavigationContentDescription(defaultNavigationContentDescription); mHomeDescription = mToolbar.getNavigationContentDescription(); setDefaultNavigationIcon(mTintManager.getDrawable(defaultNavigationIcon)); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { final ActionMenuItem mNavItem = new ActionMenuItem(mToolbar.getContext(), 0, android.R.id.home, 0, 0, mTitle); @Override public void onClick(View v) { if (mWindowCallback != null && mMenuPrepared) { mWindowCallback.onMenuItemSelected(Window.FEATURE_OPTIONS_PANEL, mNavItem); } } }); }
From source file:com.frostwire.android.gui.adapters.TransferListAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int i) { LinearLayout convertView = (LinearLayout) LayoutInflater.from(parent.getContext()) .inflate(R.layout.view_transfer_list_item, parent, false); return new ViewHolder(this, contextRef.get(), convertView, viewOnClickListener, viewOnLongClickListener, openOnClickListener, transferDetailsClickListener); }
From source file:android.support.v7.widget.ActionBarContextView.java
public void initForMode(final ActionMode mode) { if (mClose == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); mClose = inflater.inflate(mCloseItemLayout, this, false); addView(mClose);/* w w w. j av a 2 s.co m*/ } else if (mClose.getParent() == null) { addView(mClose); } View closeButton = mClose.findViewById(R.id.action_mode_close_button); closeButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mode.finish(); } }); final MenuBuilder menu = (MenuBuilder) mode.getMenu(); if (mActionMenuPresenter != null) { mActionMenuPresenter.dismissPopupMenus(); } mActionMenuPresenter = new ActionMenuPresenter(getContext()); mActionMenuPresenter.setReserveOverflow(true); final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); menu.addMenuPresenter(mActionMenuPresenter, mPopupContext); mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); ViewCompat.setBackground(mMenuView, null); addView(mMenuView, layoutParams); }
From source file:com.offbye.bookmaster.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 ww w . j a v a2 s . co m*/ if (intent == null || (!intent.getAction().equals(Intents.SearchBookContents.ACTION))) { finish(); return; } isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN); if (isbn.startsWith("http://google.com/books?id=")) { 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.length() > 0) { // 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); }