List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE
String LAYOUT_INFLATER_SERVICE
To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.
Click Source Link
From source file:com.example.lowviscam.GalleryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); isLight = getIntent().getExtras().getBoolean("isLight"); if (isLight == false) { this.setTheme(R.style.AppBaseThemeDark); } else {/*from www .j a v a 2s .co m*/ this.setTheme(R.style.AppBaseTheme); } setContentView(R.layout.activity_gallery); // Retrieve APHont font and apply it mFace = Typeface.createFromAsset(getAssets(), "fonts/APHont-Regular_q15c.otf"); SpannableString s = new SpannableString("Image Gallery"); s.setSpan(new TypefaceSpan(this, "APHont-Bold_q15c.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // Update the action bar title with the TypefaceSpan instance ActionBar actionBar = getActionBar(); actionBar.setTitle(s); actionBar.setDisplayHomeAsUpEnabled(true); // Fetch the {@link LayoutInflater} service so that new views can be created LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Find the {@link GridView} that was already defined in the XML layout GridView gridView = (GridView) findViewById(R.id.grid); // Initialize the adapter with all the coupons. Set the adapter on the {@link GridView}. try { gridView.setAdapter(new CouponAdapter(inflater, createAllCoupons())); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Set a click listener for each picture in the grid gridView.setOnItemClickListener(this); gridView.setOnTouchListener(new OnSwipeTouchListener() { public void onSwipeTop() { //Toast.makeText(GalleryActivity.this, "top", Toast.LENGTH_SHORT).show(); } public void onSwipeRight() { //Toast.makeText(GalleryActivity.this, "right", Toast.LENGTH_SHORT).show(); } public void onSwipeLeft() { //Toast.makeText(GalleryActivity.this, "left", Toast.LENGTH_SHORT).show(); } public void onSwipeBottom() { //Toast.makeText(GalleryActivity.this, "bottom", Toast.LENGTH_SHORT).show(); } }); gridView.setOnItemLongClickListener(new OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { // Find coupon that was clicked based off of position in adapter Coupon coupon = (Coupon) parent.getItemAtPosition(position); //Get absolutepath of image for adding. File list[] = mediaStorageDir.listFiles(); File tmpFile = list[list.length - position - 1]; String photoUri = coupon.mImageUri.toString(); try { photoUri = MediaStore.Images.Media.insertImage(getContentResolver(), tmpFile.getAbsolutePath(), null, null); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } // Create share intent Intent shareIntent = ShareCompat.IntentBuilder.from(GalleryActivity.this).setText(coupon.mTitle) .setType("image/jpeg").setStream(Uri.parse(photoUri)) .setChooserTitle(getString(R.string.share_using)).createChooserIntent(); startActivity(shareIntent); return true; } }); }
From source file:com.chalmers.feedlr.adapter.FeedAdapter.java
@Override public View newView(Context context, Cursor cursor, ViewGroup parent) { super.newView(context, cursor, parent); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View tempView = inflater.inflate(R.layout.feed_item, null); // Find views ViewHolder viewHolder = new ViewHolder(); viewHolder.text = (TextView) tempView.findViewById(R.id.feed_item_text); viewHolder.author = (TextView) tempView.findViewById(R.id.feed_item_author); viewHolder.timestamp = (TextView) tempView.findViewById(R.id.feed_item_timestamp); viewHolder.profilePicture = (ImageView) tempView.findViewById(R.id.feed_item_author_image); viewHolder.source = (ImageView) tempView.findViewById(R.id.feed_item_source_image); // Set fonts//from w w w . j av a2 s . c om Typeface robotoThinItalic = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-ThinItalic.ttf"); Typeface robotoMedium = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Medium.ttf"); Typeface robotoLight = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Light.ttf"); viewHolder.text.setTypeface(robotoLight); viewHolder.timestamp.setTypeface(robotoThinItalic); viewHolder.author.setTypeface(robotoMedium); tempView.setTag(viewHolder); return tempView; }
From source file:com.android.contacts.interactions.ImportDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final LayoutInflater dialogInflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); // Adapter that shows a list of string resources final ArrayAdapter<AdapterEntry> adapter = new ArrayAdapter<AdapterEntry>(getActivity(), R.layout.select_dialog_item) { @Override/*from ww w . ja v a 2 s . c o m*/ public View getView(int position, View convertView, ViewGroup parent) { final View result = convertView != null ? convertView : dialogInflater.inflate(R.layout.select_dialog_item, parent, false); final TextView primaryText = (TextView) result.findViewById(R.id.primary_text); final TextView secondaryText = (TextView) result.findViewById(R.id.secondary_text); final AdapterEntry entry = getItem(position); secondaryText.setVisibility(View.GONE); if (entry.mChoiceResourceId == R.string.import_from_sim) { final CharSequence secondary = getSimSecondaryText(entry.mSim); if (TextUtils.isEmpty(secondary)) { secondaryText.setVisibility(View.GONE); } else { secondaryText.setText(secondary); secondaryText.setVisibility(View.VISIBLE); } } primaryText.setText(entry.mLabel); return result; } CharSequence getSimSecondaryText(SimCard sim) { int count = getSimContactCount(sim); CharSequence phone = sim.getFormattedPhone(); if (phone == null) { phone = sim.getPhone(); } if (phone != null) { phone = sBidiFormatter.unicodeWrap(PhoneNumberUtilsCompat.createTtsSpannable(phone), TextDirectionHeuristicsCompat.LTR); } if (count != -1 && phone != null) { // We use a template instead of format string so that the TTS span is preserved final CharSequence template = getResources() .getQuantityString(R.plurals.import_from_sim_secondary_template, count); return TextUtils.expandTemplate(template, String.valueOf(count), phone); } else if (phone != null) { return phone; } else if (count != -1) { // count != -1 return getResources().getQuantityString(R.plurals.import_from_sim_secondary_contact_count_fmt, count, count); } else { return null; } } }; addItems(adapter); final DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final int resId = adapter.getItem(which).mChoiceResourceId; if (resId == R.string.import_from_sim) { handleSimImportRequest(adapter.getItem(which).mSim); } else if (resId == R.string.import_from_vcf_file) { handleImportRequest(resId, SimCard.NO_SUBSCRIPTION_ID); } else { Log.e(TAG, "Unexpected resource: " + getActivity().getResources().getResourceEntryName(resId)); } dialog.dismiss(); } }; final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), getTheme()) .setTitle(R.string.dialog_import).setNegativeButton(android.R.string.cancel, null); if (adapter.isEmpty()) { // Handle edge case; e.g. SIM card was removed. builder.setMessage(R.string.nothing_to_import_message); } else { builder.setSingleChoiceItems(adapter, -1, clickListener); } return builder.create(); }
From source file:com.audiokernel.euphonyrmt.library.SimpleLibraryActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.library_tabs); final LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); mTitleView = (TextView) inflater.inflate(R.layout.actionbar_title, null); mTitleView.setFocusable(true);//from www . java 2s . c o m mTitleView.setFocusableInTouchMode(true); mTitleView.setSelected(true); mTitleView.requestFocus(); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setCustomView(mTitleView); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowCustomEnabled(true); } if (savedInstanceState == null) { final Fragment rootFragment = getRootFragment(); if (rootFragment == null) { throw new RuntimeException("Error : SimpleLibraryActivity root fragment is null"); } if (rootFragment instanceof BrowseFragment) { setTitle(((BrowseFragment) rootFragment).getTitle()); } final FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); ft.replace(R.id.root_frame, rootFragment); ft.commit(); } else { refreshTitleFromCurrentFragment(); } getSupportFragmentManager().addOnBackStackChangedListener(this); }
From source file:com.cliff.comichelper.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); preferences = PreferenceManager.getDefaultSharedPreferences(this); SettingsActivity.initSettings(preferences); mTitle = mDrawerTitle = getTitle();//from ww w .j a v a2 s . co m setTitle(mTitle.toString() + " " + getAppVersionName(this)); mDrawerTitle = mTitle; // mTitle += getAppVersionName(this).toString(); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer // opens mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mWebsiteNames) { @Override public View getView(int position, View convertView, ViewGroup parent) { if (null == convertView) { LayoutInflater vi = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = vi.inflate(R.layout.drawer_list_item, null); } // ImageView imageBanner = ((ImageView) convertView // .findViewById(R.id.imageBanner)); // imageBanner.setImageResource(mBannerIds[position]); TextView text1 = (TextView) convertView.findViewById(android.R.id.text1); TextView text2 = (TextView) convertView.findViewById(android.R.id.text2); text1.setText(mWebsiteNames[position]); text2.setText(mWebsites[position]); return convertView; } }); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to // onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(0, true); } eventBus.register(this); startService(new Intent(this, ComicService.class)); mDrawerLayout.openDrawer(mDrawerList); }
From source file:com.mobeta.android.dslv.ResourceDragSortCursorAdapter.java
/** * Standard constructor.//from www .j a v a 2 s. c o m * * @param context * The context where the ListView associated with this adapter is * running * @param layout * Resource identifier of a layout file that defines the views * for this list item. Unless you override them later, this will * define both the item views and the drop down views. * @param c * The cursor from which to get the data. * @param flags * Flags used to determine the behavior of the adapter, as per * {@link CursorAdapter#CursorAdapter(Context, Cursor, int)}. */ public ResourceDragSortCursorAdapter(final Context context, final int layout, final Cursor c, final int flags) { super(context, c, flags); this.mLayout = this.mDropDownLayout = layout; this.mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); }
From source file:com.android.packageinstaller.GrantActivity.java
private View getPermissionList(AppSecurityPermissions perms) { LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View root = inflater.inflate(R.layout.permissions_list, null); View personalPermissions = perms.getPermissionsView(AppSecurityPermissions.WHICH_PERSONAL); View devicePermissions = perms.getPermissionsView(AppSecurityPermissions.WHICH_DEVICE); ((ViewGroup) root.findViewById(R.id.privacylist)).addView(personalPermissions); ((ViewGroup) root.findViewById(R.id.devicelist)).addView(devicePermissions); return root;/* w w w. j a v a 2 s . com*/ }
From source file:com.hackeruproj.android.havatzfit.general_utilities.GenUtils.java
public static void menuAlerts(Context context, int header, int theme, int img) { AlertDialog.Builder menuBuilder = new AlertDialog.Builder(context); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View menuView = inflater.inflate(R.layout.inflater_alertdialog, null); menuBuilder.setView(menuView);/*from w w w .j a v a2 s. c om*/ TextView headerText = (TextView) menuView.findViewById(R.id.alertTxtHeader); TextView bodyText = (TextView) menuView.findViewById(R.id.alertTxtBody); ImageView imgView = (ImageView) menuView.findViewById(R.id.alertImgBody); headerText.setText(header); bodyText.setText(theme); imgView.setImageResource(img); menuBuilder.setNeutralButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); menuBuilder.show(); }