Found 34486 Articles for Programming

Background ListView becomes black when scrolling in Android?

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

220 Views

Before getting into listview example, we should know about listview, Listview is a collection of items pulled from arraylist, list or any databases. Most uses of listview is a collection of items in vertical format, we can scroll up/down and click on any item. Here is the simple solution to avoid Background ListView becomes black when scrolling. 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. ... Read More

What is an Intent in Android?

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

13K+ Views

An intent is to perform an action on the screen. It is mostly used to start activity, send broadcast receiver, start services and send message between two activities. There are two intents available in android as Implicit Intents and Explicit Intents. Here is a sample example to start new activity with old activity.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. (First Activity layout)     Step 3 − Create a new ... Read More

How many types of intent are in Android?

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

16K+ Views

Before getting into types of intent, we should know what is an intent?. Intent is to perform an action. It is mostly used to start activity, send broadcast receiver, start services and send message between two activities. There are two intents available in android as Implicit Intents and Explicit Intents.Explicit Intent − It going to connect the internal world of an application such as start activity or send data between two activities. To start new activity we have to create Intent object and pass source activity and destination activity as shown below −Intent send = new Intent(MainActivity.this, SecondActivity.class); startActivity(send);And we ... Read More

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

391 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

237 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

Advertisements