Tutorial by Examples

MediaPlayer class can be used to control playback of audio/video files and streams. Creation of MediaPlayer object can be of three types: Media from local resource MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.resource); mediaPlayer.start(); // no need to call prepare(); create...
The MediaPlayer$prepare() is a blocking call and will freeze the UI till execution completes. To solve this problem, MediaPlayer$prepareAsync() can be used. mMediaPlayer = ... // Initialize it here mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener(){ @Override public ...
Inline style You can manipulate the inline CSS style of an HTML element by simply reading or editing its style property. Assume the following element: <div id="element_id" style="color:blue;width:200px;">abc</div> With this JavaScript applied: var element = doc...
init Called synchronously after the instance has been initialized and prior to any initial data observation. created Called synchronously after the instance is created. This occurs prior to $el setup, but after data observation, computed properties, watch/event callbacks, and methods ha...
Since all lifecycle hooks in Vue.js are just functions, you can place any of them directly in the instance declaraction. //JS new Vue({ el: '#example', data: { ... }, methods: { ... }, //LIFECYCLE HOOK HANDLING created: function() { ...
JavaScript has a predefined collection of reserved keywords which you cannot use as variables, labels, or function names. ECMAScript 1 1 A — EE — RS — Zbreakexportsupercaseextendsswitchcatchfalsethisclassfinallythrowconstfortruecontinuefunctiontrydebuggeriftypeofdefaultimportvardeleteinvoiddoneww...
import "reflect" value := reflect.ValueOf(4) // Interface returns an interface{}-typed value, which can be type-asserted value.Interface().(int) // 4 // Type gets the reflect.Type, which contains runtime type information about // this value value.Type().Name() // int value.SetInt(5)...
import "reflect" type S struct { A int b string } func (s *S) String() { return s.b } s := &S{ A: 5, b: "example", } indirect := reflect.ValueOf(s) // effectively a pointer to an S value := indirect.Elem() // this is addressable, since we've derefed a point...
import "reflect" s := []int{1, 2, 3} value := reflect.ValueOf(s) value.Len() // 3 value.Index(0).Interface() // 1 value.Type().Kind() // reflect.Slice value.Type().Elem().Name() // int value.Index(1).CanAddr() // true -- slice elements are addressable value....
import "reflect" // this is effectively a pointer dereference x := 5 ptr := reflect.ValueOf(&x) ptr.Type().Name() // *int ptr.Type().Kind() // reflect.Ptr ptr.Interface() // [pointer to x] ptr.Set(4) // panic value := ptr.Elem() // this is a deref value.Type().Name() // int...
Package can have init methods which are run only once before main. package usefull func init() { // init code } If you just want to run the package initialization without referencing anything from it use the following import expression. import _ "usefull"
Directives comes with the AngularJS library itself. A sample directive can be created as: angular.module('simpleDirective', []) .directive('helloData', function() { return { template: 'Hello, {{data}}' }; }); And can be used as: JS: angular.module('app', ['simpleDirective']) .con...
In go it can sometimes be useful to know which underlying type you have been passed. This can be done with a type switch. This assumes we have two structs: type Rembrandt struct{} func (r Rembrandt) Paint() {} type Picasso struct{} func (r Picasso) Paint() {} That implement the Painter ...
In C# (and .NET) a string is represented by class System.String. The string keyword is an alias for this class. The System.String class is immutable, i.e once created its state cannot be altered. So all the operations you perform on a string like Substring, Remove, Replace, concatenation using + o...
To get started programming with CUDA, download and install the CUDA Toolkit and developer driver. The toolkit includes nvcc, the NVIDIA CUDA Compiler, and other software necessary to develop CUDA applications. The driver ensures that GPU programs run correctly on CUDA-capable hardware, which you'll ...
You can install Json.Net into your Visual Studio Project in 1 of 2 ways. Install Json.Net using the Package Manager Console. Open the Package Manager Console window in Visual Studio either by typing package manager console in the Quick Launch box and selecting it or by clicking View -> O...
The following table shows the keywords for built-in C# types, which are aliases of predefined types in the System namespaces. C# Type.NET Framework TypeboolSystem.BooleanbyteSystem.BytesbyteSystem.SBytecharSystem.ChardecimalSystem.DecimaldoubleSystem.DoublefloatSystem.SingleintSystem.Int32uintSyste...
Immutable types are types that when changed create a new version of the object in memory, rather than changing the existing object in memory. The simplest example of this is the built-in string type. Taking the following code, that appends " world" onto the word "Hello" string ...
This is the flavor of markdown that's used by Stack Overflow and other Stack Exchange sites. When you answer a question or add documentation you use this markdown. This answer is made out of SO markdown See Official Documentation The main things that SO markdown adds are under "Stack Exchan...
The goal is to generate the following XML document: <FruitBasket xmlns="http://www.fruitauthority.fake"> <Fruit ID="F0001"> <FruitName>Banana</FruitName> <FruitColor>Yellow</FruitColor> </Fruit> <Fruit ID="F000...

Page 228 of 1336