Tutorial by Examples: c

Create drawable file named with custom_rectangle.xml in drawable folder: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color=&quo...
activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation=...
Docstrings are - unlike regular comments - stored as an attribute of the function they document, meaning that you can access them programmatically. An example function def func(): """This is a function that does nothing at all""" return The docstring can ...
Add code in your Activity. This would work for Fragment also, no need to add this code in Fragment. @Override public boolean dispatchTouchEvent(MotionEvent ev) { View view = getCurrentFocus(); if (view != null && (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == Moti...
DP to Pixel: private int dpToPx(int dp) { return (int) (dp * Resources.getSystem().getDisplayMetrics().density); } Pixel to DP: private int pxToDp(int px) { return (int) (px / Resources.getSystem().getDisplayMetrics().density); }
Tags are typically applied via the editor; however, you can also apply tags via script. Any custom tag must be created via the Tags & Layers window before being applied to a game object. Setting Tags in the Editor With one or more game objects selected, you can select a tag from the inspecto...
Tags make it particularly easy to locate specific game objects. We can look for a single game object, or look for multiple. Finding a Single GameObject We can use the static function GameObject.FindGameObjectWithTag(string tag) to look for individual game objects. It is important to note that, i...
When comparing two GameObjects by Tags, it should be noted that the following would cause Garbage Collector overhead as a string is created everytime: if (go.Tag == "myTag") { //Stuff } When performing those comparisons inside Update() and other regular Unity's callback (or a ...
Set High resolution programmatically. Camera mCamera = Camera.open(); Camera.Parameters params = mCamera.getParameters(); // Check what resolutions are supported by your camera List<Size> sizes = params.getSupportedPictureSizes(); // Iterate through all available resolutions and choos...
I have created GeoFenceObserversationService singleton class. GeoFenceObserversationService.java: public class GeoFenceObserversationService extends Service implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener, ResultCallback<Status> { protected s...
There are many possible ways of customizing the look of a Button. This example presents several options: Option 0: Use ThemeOverlay (currently the easiest/quickest way) Create a new style in your styles file: styles.xml <resources> <style name=“mybutton” parent=”ThemeOverlay.AppC...
preg_replace_callback works by sending every matched capturing group to the defined callback and replaces it with the return value of the callback. This allows us to replace strings based on any kind of logic. $subject = "He said 123abc, I said 456efg, then she said 789hij"; $regex = &q...
The purpose of the classpath is to tell a JVM where to find classes and other resources. The meaning of the classpath and the search process are intertwined. The classpath is a form of search path which specifies a sequence of locations to look for resources. In a standard classpath, these places...
use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\GenericEvent; // you may store this in a dependency injection container for use as a service $dispatcher = new EventDispatcher(); // you can attach liste...
use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\Event; $dispatcher = new EventDispatcher(); // you can attach event subscribers, which allow a single object to subscribe // to many ...
By default stored procedures and functions or not generated by mysqldump, you will need to add the parameter --routines (or -R): mysqldump -u username -p -R db_name > dump.sql When using --routines the creation and change time stamps are not maintained, instead you should dump and reload the ...
#include <stddef.h> /* for offsetof() */ #include <stdlib.h> /* for exit() */ #include <stdio.h> /* for perror() */ #include <string.h> /* for strcmp() */ #include <unistd.h> /* for close(), unlink() */ #include <fcntl.h> /* for open() */ #incl...
In [1]: import pandas as pd In order to run a query in BigQuery you need to have your own BigQuery project. We can request some public sample data: In [2]: data = pd.read_gbq('''SELECT title, id, num_characters ...: FROM [publicdata:samples.wikipedia] ...: ...
If you have created service account and have private key json file for it, you can use this file to authenticate with pandas In [5]: pd.read_gbq('''SELECT corpus, sum(word_count) words FROM [bigquery-public-data:samples.shakespeare] GROUP BY co...
This example demonstrates how to do compile time checking of an annotated element. The annotation The @Setter annotation is a marker can be applied to methods. The annotation will be discarded during compilation not be available afterwards. package annotation; import java.lang.annotation.Eleme...

Page 484 of 826