Found 34494 Articles for Programming

How can I add items to a spinner in Android?

George John
Updated on 30-Jul-2019 22:30:23

7K+ Views

Spinner is just like a drop down button, using this button we can select a item from set of items. This example demonstrate about how to add items to a spinner in android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.java.import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.MotionEvent; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.Toast; import java.util.ArrayList; public class MainActivity ... Read More

How to pass data between activities with android Serializable

Chandu yadav
Updated on 30-Jul-2019 22:30:23

2K+ Views

Using serialization, we can pass object's state or array between two activities. Before getting into the code, we should know about serialization and how does it work with intent in android.Serialization is a marker interface. Using serialization, we can convert state of an object into a byte stream. The byte stream is a platform independent, so it's going to work on the JVM and other platforms. Here is the example to send an object between two activities.Step 1 − Create a new project in Android Studio, Go to File ⇒ New Project and fill all required details to create a ... Read More

usleep() function in PHP

George John
Updated on 30-Dec-2019 07:01:37

38 Views

The usleep() function delays execution of the current script for few microseconds.Syntaxusleep(msec)Parametersmsec − The number of microseconds to delay the script.ReturnThe usleep() function returns nothing.Example Live DemoOutputThe following is the output.03:06:08 03:06:10 03:06:15

unpack() function in PHP

Chandu yadav
Updated on 30-Dec-2019 07:00:49

390 Views

The unpack() function unpacks data from a binary string.Syntaxunpack(format, data)Parametersformat − The format to use. Here are the possible valuesa −NUL-padded stringA − SPACE-padded stringh − Hex string, low nibble firstH − Hex string, high nibble firstc − signed charC −unsigned chars − signed short (always 16 bit, machine byte order)S − unsigned short (always 16 bit, machine byte order)n − unsigned short (always 16 bit, big endian byte order)v − unsigned short (always 16 bit, little endian byte order)i − signed integer (machine dependent size and byte order)I − unsigned integer (machine dependent size and byte order)l − signed ... Read More

uniqid() function in PHP

Arjun Thakur
Updated on 30-Dec-2019 06:59:26

234 Views

The uniqid() function generates a unique ID based on the current time in microseconds.Syntaxuniqid(prefix, more_entropy)Parametersprefix − The prefix to the unique ID.more_entropy − The more entropy at the end of the return value.ReturnThe uniqid() function returns unique identifiers as string.Example Live DemoOutputThe following is the output.5bfd5bd045faa

time_sleep_until() function in PHP

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

84 Views

The time_sleep_until() function delays execution of the current script until the specified time. Syntax time_sleep_until(time) Parameters time − The time until execution will delay. Return The time_sleep_until() function returns true on success. Example The execution of the above script is now delayed for 15 seconds.

time_nanosleep() function in PHP

George John
Updated on 30-Dec-2019 06:46:17

38 Views

The time_nanosleep() function delays execution of the current script for few seconds and nanoseconds.Syntaxtime_nanosleep(sec, nsec)Parameterssec − The number of seconds to delay the script.nsec − The number of nanoseconds to delay the script.ReturnThe time_nanosleep() function returns true on success.Example Live DemoOutputThe following is the output.02:57:04 02:57:06 02:57:08

sleep() function in PHP

Ankith Reddy
Updated on 30-Dec-2019 06:46:44

682 Views

The sleep() function delays execution of the current script for short time period.Syntaxsleep(sec)Parameterssec− The number of seconds to delay the script.ReturnThe sleep() function returns zero on success.Example Live DemoOutputThe following is the output.02:54:50 02:54:52 02:54:57

show_source() function in PHP

Arjun Thakur
Updated on 30-Dec-2019 06:44:49

126 Views

The show_source() function outputs a file with the PHP syntax highlighted.Syntaxshow_source(file, return)Parametersfile − The file name to display.return − If this parameter is set to true, this function will return the highlighted code as a string, instead of printing it out. Default is false.ReturnThe show_source() function returns the highlighted code as a string instead of printing it, if the return parameter is set to true otherwise, it returns true on success, or false on failure.ExampleThe following is an example, wherein we are using a test file ("new.php") to output the file with the PHP syntax highlighted.         ... Read More

php_strip_whitespace() function in PHP

Chandu yadav
Updated on 30-Jul-2019 22:30:23

67 Views

The php_strip_whitespace() function returns source with stripped comments and whitespace. Syntax php_strip_whitespace(file_path) Parameters file_path − The path of file. Return The php_strip_whitespace() function returns stripped source code on success. Example The above code strip all the comments and whitespace.

Advertisements