To specify the options menu for an activity, override onCreateOptionsMenu() (fragments provide their own onCreateOptionsMenu() callback).
Recently while reading google docs I found this but there is no article for how to add menus in a fragment.
I just want to ask is there a way for this and if yes how should it be done. Please tell in kotlin
There is a link to documentation
You have to override the same method as for Activity, but parameters differ a little comparing with Activity analogue:
override fun onCreateOptionsMenu(menu: Menu, menuInflater: MenuInflater) {
menuInflater.inflate(R.menu.name_of_your_menu, menu)
}
Related
I was just browsing this stylesheet when I noticed a CSS function I have never encountered before: -webkit-named-image()
I did some digging and found links on SO here and a developer page here. The only apparently-valid arguments for this function that I can find are apple-pay-logo-black and apple-pay-logo-white, e.g.:
div { background-image: -webkit-named-image(apple-pay-logo-black) ;}
I have lots of questions, for example:
Is this function deprecated or still currently valid? (based on the recency of this link and this one I assume it is not deprecated). Are there other acceptable arguments for this function (besides the ones I mentioned above)? Is this function similar to the url() function insofar as the passed function argument can be quoted or unquoted? Is it Safari specific?
In brief, how can I find out more about this function and what are the realistic use cases?
This CSS function is vendor specific, so there is no specification. It's used to display some named images embedded in WebKit.
To discover the valid argument of this function, one solution is to look in the source code of WebKit. The C++ function associated to this CSS function is drawNamedImage from the Theme class.
virtual void drawNamedImage(const String&, GraphicsContext&, const FloatRect&) const;
There is a comment in the implementation of drawNamedImage:
void Theme::drawNamedImage(const String& name, GraphicsContext& context, const FloatRect& rect) const
{
// We only handle one icon at the moment.
if (name != "wireless-playback")
return;
But each theme can override this function and define its own named images. The Cocoa theme define the values wireless-playback, apple-pay-logo-black and apple-pay-logo-white.
There is yet, no other theme in the source code of WebKit, that define named images.
-webkit-named-image() CSS generator allows a site to request artwork by name and get the platform variant and recently being added to webkit.
Check this bug which got resolved some time back
https://bugs.webkit.org/show_bug.cgi?id=164235
Currently what I know Safari now ships with built-in images which we can use with -webkit-named-image().
As per stripe documentation:
Step 2: Add an Apple Pay button to your site
Start by adding a button to the HTML on your product page. Safari now >ships with built-in Apple Pay images; you can use them with Safari's ->webkit-named-image feature. This button should be hidden by default.
I think this is being done to create uniform style across internet.
When using a custom front-end theme, the preview button for my content stops working. It just redirects to the content overview page.
Am I missing something in my theme that allows me to use the 'preview' function?
You most likely have the ?destination=admin/content in your URL. This is a core bug. The current discussion can be read at:
https://www.drupal.org/node/2325463
Jason Ruyle's answer is correct, I had the same problem and solved it by adding this code to my module:
use Drupal\Core\Entity\EntityInterface;
function my_module_entity_operation_alter(array &$operations, EntityInterface $entity) {
if (isset($operations['edit']['query'])) {
unset($operations['edit']['query']['destination']);
}
return $operations;
}
The code could also be improved to target the right entities, if needed.
I'd like to overwrite the buildSkeleton method used in the fullCalendar plugin.
I'm trying to remove the table,tr,td and replace them with regular divs.
Thanks
If we take a look at https://github.com/arshaw/fullcalendar/blob/master/src/basic/BasicView.js you'll see the buildSkeleton is a private function. However, renderBasic is public and makes use of buildSkeleton.
If you can successfully override the renderBasic you should be all good to go. However, your optimal path might be to actually fork the project (it obviously is open source) and add in the option of using a div skeleton over a table skeleton.
We are looking into providing users of our application the ability override the default site CSS.
Currently they can choose a site theme but it would be nice to allow them to change properties such as background color, font color, font face etc.
I'm torn between giving each site a "user defined" stylesheet that can be edited from the administration area or providing some kind of CSS builder.
The first option provides the most flexibility but could also be the most problematic and requires the user to have some basic understanding of CSS.
So aside from the obvious, (which is the best solution?) I have a few additional questions:
User Defined Css:
Is there a web based CSS editor available?
Is there a server side (.net) CSS validator available (for verifying the css the user enters)
Css Builder:
Is there a web based CSS builder already available?
What is the best way of generating the CSS based on the rules provided by the user (I thought about using some kind of templating engine to do this (NVelocity, Razor etc.)?
Thanks
Solution
I've added an answer below with the solution we went for.
however never used, recently I looked at Brosho Design in the Browser jQuery Plugin
With this Plugin you can style your
markup right in your browser with a
build-in element selector and CSS
editor. Generate the CSS code of
altered elements with one click and
use it in your own stylesheet.
demo here
I'd recommend to build a custom css editor since it's the easiest way to limit which elements and attributes the user will be able to edit / customize, and how. Just keep it simple and you will do just fine.
To validate CSS you could use the API of the W3 CSS Validator, http://jigsaw.w3.org/css-validator/api.html
I've built an application that does exactly this. It's a little more involved as there are multiple master pages and themes, and the user can attach custom urls to load themes - example: /someclienturl would load a specific theme.
Anyway, here's the schema I used. One thing I wish I added is the ability for power users to add custom styles to the stylesheet that's eventually written. Basically, a theme section would apply to a selector #header, for example. And ThemeSectionCssStyle holds user added customizations for that selector. If you have any more questions let me know. It ended up being a fairly involved sub-project. I'm curious to see what anyone else came up with.
I think the key factor here is whether you want your users to 'play with the codez'
If you do then something like this (posted by #Caspar) can be helpful in generating the css. If you do allow direct access to the css then the W3 CSS Validator (posted by #Trikks) is definitely necessary.
In my case I didn't want to provide direct access to the Css. Looking around at various sites that allow you to change simple style properties (background-color, font-face, color etc.) it seems that they have just created their own interfaces for this. There are plenty of javascript plugins around for making this process quite slick (color pickers etc.).
Once you have the styles stored somewhere you need some way of rendering them out.
I couldn't find any .net Css writers. I think it may be possible in Less but the solution was quite simple just using what's built into asp.net mvc.
I created a Css action result (courtesy of #Darin Dimitrov):
public class CssResult : PartialViewResult {
public override void ExecuteResult(ControllerContext context) {
context.HttpContext.Response.ContentType = "text/css";
base.ExecuteResult(context);
}
}
Then in my controller (a simple example):
[HttpGet]
public ActionResult Index()
{
var styles = new Dictionary<string, string>()
{
{ "color", "red" },
{ "font-family", "Consolas, Courier, Serif" },
{ "font-size" , "12px" }
};
return this.Css(styles);
}
Then my view (views/css/index.cshtml):
body {#foreach (var item in Model) {
#string.Format("{0}: {1};", item.Key, item.Value)
}
}
This will essentially render out the styles in the passed in dictionary. Of course you may want to create a specific class for holding these styles so that you could also specify the dom element name/class/id.
Finally to render out the stylesheet on our page we can call Url.Action("index", "css").
Is it possible to add a TaskItem (or TaskList) to the website page (Web Objects Home Page)?
I'd like to provide some contextual access to my addin and I can't seem to find a good integration point.
Many thanks to CarlosAg on the IIS.net forums for the basis of this answer.
Create a class that subclasses ProtocolProvider and have it return a TaskList by overriding GetSiteTaskList and GetSitesTaskList.
In your Module.Initialize method, get an IExtensibilityManager from the serviceProvider
Register an instance of your ProtocolProvider to the IExtensibilityManager by calling RegisterExtension.
Update
It turns out a ProtocolProvider can only provide a TaskList for the "Sites" view, but can provide a different TaskList depending on which site is selected (if any).
To provide a custom TaskList for a site's homepage (ie. with the list of features), you need to implement IHomepageTaskListProvider and register it with the IExtensibilityManager mentioned above.
Within the IHomepageTaskListProvider.GetTaskList implementation, you can find out if you the current "homepage" is a site or global by getting a Connection from the IServiceProvider and checking the ConfigurationPath.PathType property (it's an ConfigurationPathType enumeration)