Tutorial by Examples

public class SoundActivity extends Activity { private MediaPlayer mediaPlayer; ProgressBar progress_bar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tool_sound); ...
Problem: Vim users are not always happy. Solution: Make them happy. 7.4 :smile Note: Requires patch version ≥7.4.1005
To get the the exact size of a UIButton's text based on its font, use the function intrinsicContentSize. Swift button.intrinsicContentSize.width Objective-C button.intrinsicContentSize.width;
NSString provides method boundingRectWithSize which can be used to predict the resulting CGSize of a UILabel based on its text and font without the need of creating a UILabel Objective-C [[text boundingRectWithSize:maxSize options:(NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineF...
SilverStripe has reasonably good support for submitting form data using AJAX requests. Below is example code of how to set up a basic Form that accepts submissions by both AJAX and traditional default browser behaviour (as is good practice). Adding the form to our controller First we need to defin...
The following class is used to demonstrate, how instances of classes can be created: JavaFX 8 The annotation in Person(@NamedArg("name") String name) has to be removed, since the @NamedArg annotation is unavailable. package fxml.sample; import javafx.beans.NamedArg; import javafx....
public String getAppVersion() throws PackageManager.NameNotFoundException { PackageManager manager = getApplicationContext().getPackageManager(); PackageInfo info = manager.getPackageInfo( getApplicationContext().getPackageName(), ...
You should use this when you have two text fields that should receive exactly the same content. For example, you may want to confirm an email address or a password. This validation creates a virtual attribute whose name is the name of the field that has to be confirmed with _confirmation appended. ...
The :on option lets you specify when the validation should happen. The default behavior for all the built-in validation helpers is to be run on save (both when you're creating a new record and when you're updating it). class Person < ApplicationRecord # it will be possible to update email wi...
When using Autolayout with a UIScrollView, it does NOT resize properly depending on the size of its contents or subviews. In order to get a UIScrollView to automatically scroll when its contents become too large to fit in the visible area, we need to add a ContentView and some constraints that allo...
The simplest way to get an event handler called on a key press is to connect the handler to the key-press-event signal. In this example, we register for the event for the whole window, but you can also register for individual widgets too. The most important part is the connection of the handler to ...
UIView *view = [[UIView alloc] init]; [self.view addSubview:view]; //Use the function if you want to use height as constraint [self addView:view onParentView:self.view withHeight:200.f]; //Use this function if you want to add view with respect to parent and should resize with it [self a...
Could be even more basic, but this showcases some of the features the Vala language. The code using Gtk; int main (string[] args) { Gtk.init (ref args); var window = new Window (); window.title = "First GTK+ Program"; window.border_width = 10; window.window_...
Angular Forms and Inputs have various states that are useful when validating content Input States StateDescription$touchedField has been touched$untouchedField has not been touched$pristineField has not been modified$dirtyField has been modified$validField content is valid$invalidField content is ...
Angular also provides some CSS classes for forms and inputs depending on their state ClassDescriptionng-touchedField has been touchedng-untouchedField has not been touchedng-pristineField has not been modifiedng-dirtyField has been modifiedng-validField is validng-invalidField is invalid You can u...
To help you find and count characters in a string, CharMatcher provides the following methods: int indexIn(CharSequence sequence) Returns the index of the first character that matches the CharMatcher instance. Returns -­1 if no character matches. int indexIn(CharSequence sequence, int sta...
var source = new AutoCompleteStringCollection(); // Add your collection of strings. source.AddRange(new[] { "Guybrush Threepwood", "LeChuck" }); var textBox = new TextBox { AutoCompleteCustomSource = source, AutoCompleteMode = AutoCompleteMode.SuggestAppend, ...
textBox.KeyPress += (sender, e) => e.Handled = !char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar); This will only permit the use of digits and control characters in the TextBox, other combinations are possible using the same approach of setting the Handle property to true to block ...
textBox.SelectionStart = textBox.TextLength; textBox.ScrollToCaret(); Applying the same principle, SelectionStart can be set to 0 to scroll to the top or to a specific number to go to a specific character.
// Initialize a stack object of integers var stack = new Stack<int>(); // add some data stack.Push(3); stack.Push(5); stack.Push(8); // elements are stored with "first in, last out" order. // stack from top to bottom is: 8, 5, 3 // We can use peek to see the top elemen...

Page 636 of 1336