The HTML DOM Video autoplay property returns/sets boolean value corresponding to whether the video will play automatically on page load or not.SyntaxFollowing is the syntax −Returning boolean value - true/falsemediaObject.autoplaySetting autoplay to booleanValuemediaObject.autoplay = booleanValueHere, “boolean value” can be the following −booleanValueDetailstrueIt defines that video will automatically play onpage loadfalseIt defines that video will not automatically playon page loadLet us see an example of Video autoplay property −Example Live Demo HTML DOM Video autoplay * { padding: 2px; margin:5px; } form { width:70%; ... Read More
The HTML DOM Video buffered property returns a TimeRanges object containing information about the video’s buffered range length and its start, end position.SyntaxFollowing is the syntax −Returning TimeRanges ObjectmediaObject.bufferedLet us see an example of Video buffered property −Example Live Demo HTML DOM Video buffered * { padding: 2px; margin:5px; } form { width:70%; margin: 0 auto; text-align: center; } input[type="button"] { border-radius: 10px; } ... Read More
The HTML DOM Video canPlayType() returns a string corresponding to whether the browser can play the specified video type or not.SyntaxFollowing is the syntax −Returning boolean value - true/falsevideoObject.canPlayType(typeAsParameter)Here, the return value can be the following −returnValueDetailsprobablyIt defines that browser mostlikely supports the specified video typemaybeIt defines that browsermight support the specified video type, but playback will have tobe attempted to be sure"" (empty string)It defines that browserdefinitely doesn’t supports the specified video typeLet us see an example of Video canPlayType() property −Example Live Demo HTML DOM Video canPlayType() * { padding: 2px; ... Read More
This example demonstrates how do I set the value for the attribute layout_weight for button in android dynamically from java code.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.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.Button; import android.widget.LinearLayout; public class MainActivity extends AppCompatActivity { LinearLayout linearLayout; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); linearLayout ... Read More
While deserializing, a Gson can expect a JSON object but it can find a JSON array. Since it can't convert from one to the other, it can throw an error as "JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY" at the runtime.Exampleimport com.google.gson.Gson; public class GsonErrorTest { public static void main(String args[]) throws Exception { String json = "{\"employee\":[{\"name\":\"Raja Ramesh\", \"technology\":\"java\"}]}"; Gson gson = new Gson(); Software software = gson.fromJson(json, Software.class); System.out.println(software); } } class Software { Employee employee; } class Employee { String name; ... Read More
The HTML DOM UiEvent detail property returns a number corresponding to clicks triggered continuously.NOTE − If ondblclick event is triggered returned value is ‘2’, and always ‘0’ if onmouseover or onmouseout event is triggered.SyntaxFollowing is the syntax −Returning number of clicks triggered continuously −event.detailLet us see an example of Event detail property −Example Live Demo HTML DOM UiEvent detail form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { ... Read More
The javax.json.JsonWriter interface can write a JSON object or array structure to an output source. The class javax.json.JsonWriterFactory contains methods to create JsonWriter instances. A factory instance can be used to create multiple writer instances with the same configuration. We can create writers from output source using the static method createWriter() of javax.json.Json class.Syntaxpublic static JsonWriter createWriter(Writer writer)In the below example, we can serialize a JSON object using the JsonWriter interface.Exampleimport java.io.StringWriter; import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; import javax.json.JsonWriter; public class JsonWriterTest { public static void main(String[] args) { JsonObject jsonObj = Json.createObjectBuilder() .add("name", ... Read More
This example demonstrates how do I create Horizontal ListView 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.Kindly add the below-given dependence in the Gradle −implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.android.support:cardview-v7:28.0.0'Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.os.Bundle; import java.util.ArrayList; import java.util.Arrays; public class MainActivity extends AppCompatActivity { RecyclerView recyclerView; RecyclerView.LayoutManager layoutManager; RecyclerView.Adapter adapter; ArrayList numberName; ArrayList numberImage; @Override ... Read More
This example demonstrates how do I make an android slidingdrawer slide out from the left 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.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { ... Read More
This example demonstrates how do I create a focusable editText inside ListView 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 − Create a new layout resource file and add the following code− Step 4 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; import android.app.LauncherActivity; import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.EditText; import ... Read More