Tutorial by Examples

If you need a completely customized view, you'll need to subclass View (the superclass of all Android views) and provide your custom sizing (onMeasure(...)) and drawing (onDraw(...)) methods: Create your custom view skeleton: this is basically the same for every custom view. Here we create the...
Custom views can also take custom attributes which can be used in Android layout resource files. To add attributes to your custom view you need to do the following: Define the name and type of your attributes: this is done inside res/values/attrs.xml (create it if necessary). The following file...
Destructuring allows us to refer to one key in an object, but declare it as a variable with a different name. The syntax looks like the key-value syntax for a normal JavaScript object. let user = { name: 'John Smith', id: 10, email: '[email protected]', }; let {user: userName, id: us...
It is important for someone traversing through the git log to easily understand what each commit was all about. Good commit messages usually include a number of a task or an issue in a tracker and a concise description of what has been done and why, and sometimes also how it has been done. Better m...
Add this to your vimrc: nnoremap Q @q To start recording the "throwaway" macro, use qq. To finish recording hit q (in normal mode for both). To execute the recorded macro, use Q. This is useful for macros that you need to repeat many times in a row but won't be likely to use again af...
One way to create a macro is to record it. Start recording a macro and save it to a register (in this example, we'll use a, but it can be any register you could normally yank text to): qa Then run the commands you want to record in the macro (here, we'll surround the contents of a line with &lt...
LINQ is largely beneficial for querying collections (or arrays). For example, given the following sample data: var classroom = new Classroom { new Student { Name = "Alice", Grade = 97, HasSnack = true }, new Student { Name = "Bob", Grade = 82, HasSnack = false }, ...
HTML 4.01/XHTML 1.0 Strict includes the following void elements: area - clickable, defined area in an image base - specifies a base URL from which all links base br - line break col - column in a table [deprecated] hr - horizontal rule (line) img - image input - field where users enter data...
public class LogActionFilter : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { Log("OnActionExecuting", filterContext.RouteData); } public override void OnActionExecuted(ActionExecute...
This example creates a Polymer element named x-foo, whose template binds to a string property, named "message". The element's HTML is imported into the main document, which allows usage of <x-foo> tags in <body>. x-foo.html <dom-module id="x-foo"> <templ...
Swift let webview = UIWebView(frame: CGRect(x: 0, y: 0, width: 320, height: 480)) Objective-C UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; //Alternative way of defining frame for UIWebView UIWebView *webview = [[UIWebView alloc] init]; CGRect webviewFr...
Load content in webview from the url Swift webview.loadRequest(NSURLRequest(URL: NSURL(string: "http://www.google.com")!)) Objective-C [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
The PrettyPrinter utility will 'pretty print' XML documents. The following code snippet pretty prints unformatted xml: import scala.xml.{PrettyPrinter, XML} val xml = XML.loadString("<a>Alana<b><c>Beth</c><d>Catie</d></b></a>") val formatt...
Unlike many other programming languages, the throw and catch keywords are not related to exception handling in Ruby. In Ruby, throw and catch act a bit like labels in other languages. They are used to change the control flow, but are not related to a concept of "error" like Exceptions are...
The library CL-PPCRE provides the function split which allows us to split strings in substrings that match a regular expression, discarding the parts of the string that do not. (cl-ppcre:split "\\." "127.0.0.1") ;; => ("127" "0" "0" "1&quot...
std::async is also able to make threads. Compared to std::thread it is considered less powerful but easier to use when you just want to run a function asynchronously. Asynchronously calling a function #include <future> #include <iostream> unsigned int square(unsigned int i){ r...
If you want to pass in values to a method when it is called, you use parameters: - (int)addInt:(int)intOne toInt:(int)intTwo { return intOne + intTwo; } The colon (:) separates the parameter from the method name. The parameter type goes in the parentheses (int). The parameter name goes aft...
This is how to create a basic method that logs 'Hello World" to the console: - (void)hello { NSLog(@"Hello World"); } The - at the beginning denotes this method as an instance method. The (void) denotes the return type. This method doesn't return anything, so you enter void. ...
When you want to return a value from a method, you put the type you want to return in the first set of parentheses. - (NSString)returnHello { return @"Hello World"; } The value you want to return goes after the return keyword;
A class method is called on the class the method belongs to, not an instance of it. This is possible because Objective-C classes are also objects. To denote a method as a class method, change the - to a +: + (void)hello { NSLog(@"Hello World"); }

Page 179 of 1336