Use Checkbox in Android

Azhar
Updated on 21-Aug-2019 08:28:54

376 Views

This example demonstrates how do I make a specific text on TextView bold 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 android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    CheckBox pizza, coffee, burger;    Button buttonOrder;    @Override    protected void onCreate(Bundle savedInstanceState) {   ... Read More

Use ButterKnife in Android

Azhar
Updated on 21-Aug-2019 08:27:41

993 Views

This example demonstrates how do I ButterKnife 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 – Open build.gradle(Module App) and add the following dependencyimplementation 'com.jakewharton:butterknife:8.8.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'Step 4 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; import butterknife.BindView; import butterknife.ButterKnife; public class MainActivity extends AppCompatActivity {    @BindView(R.id.textView)    TextView textView;    @BindView(R.id.textView2)   ... Read More

Use Drag and Drop in Android

Azhar
Updated on 21-Aug-2019 08:24:11

575 Views

This example demonstrates how do I use drag and drop 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 android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.DragEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; public class MainActivity extends AppCompatActivity implements View.OnTouchListener, View.OnDragListener {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

Convert Java Bitmap to Byte Array in Android

Azhar
Updated on 21-Aug-2019 08:24:02

5K+ Views

This example demonstrates how do I convert java bitmap to byte array 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 android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; public class MainActivity extends AppCompatActivity {    Button button;    ImageView ivSource, ivCompressed;    @Override    protected ... Read More

Communication Between Activity and Service in Android

Azhar
Updated on 21-Aug-2019 07:57:55

3K+ Views

This example demonstrates how do I communicate between Activity and Service 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 android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.support.v7.app.AppCompatActivity; public class MainActivity extends AppCompatActivity implements View.OnClickListener {    Button buttonStart, buttonStop;    @Override    public void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       ... Read More

Ping External IP from Java Android

Azhar
Updated on 21-Aug-2019 07:50:28

3K+ Views

This example demonstrates how do I ping external IP from java 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 android.content.Context; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; import java.io.IOException; public class MainActivity extends AppCompatActivity {    Boolean isConnected = false,    isWiFi = false,    isMobile = false;    @Override    protected void onCreate(Bundle savedInstanceState) {       ... Read More

Check Amount of RAM Used by an Android App

Azhar
Updated on 21-Aug-2019 07:48:28

776 Views

This example demonstrates how do I check the amount of RAM to be used by an android app.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 android.app.ActivityManager; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       final TextView textView = findViewById(R.id.text); ... Read More

HTML DOM Input Radio Form Property

AmitDiwan
Updated on 21-Aug-2019 06:57:36

161 Views

The HTML DOM Input Radio form property is used for returning the form reference that contains the given input radio button. If the radio button is outside the form then it will simply return NULL. This property is read-only.SyntaxFollowing is the syntax for input radio form property −radioObject.formExampleLet us look at an example for the Input radio form property. Input radio form Property FRUIT: Mango Get the form id by clicking on the below button GET FORM    function formId() {       var P=document.getElementById("Mango").form.id;       document.getElementById("Sample").innerHTML = "The id of ... Read More

HTML DOM Input Radio Autofocus Property

AmitDiwan
Updated on 21-Aug-2019 06:42:59

303 Views

The HTML DOM input radio autofocus property is associated with the HTML element’s autofocus attribute. This property is used for setting or returning whether the input radio button automatically be focused when the page loads or not.SyntaxFollowing is the syntax for −Setting the autofocus property.radioObject.autofocus = true|falseHere, true represents the radio button should get focus and false represents otherwise. It is set to false by default.ExampleLet us look at an example for the Input Radio autofocus property − Input password autofocus property RADIO: CHECK FOCUS    function FocusVal() {     ... Read More

HTML DOM Style BorderImage Property

AmitDiwan
Updated on 21-Aug-2019 06:32:41

97 Views

The borderImage property is used for setting or getting the border image of an element. It is a shorthand property, so that we can manipulate borderImageSource, borderImageSlice, borderImageWidth, borderImageOutset and borderImageRepeat properties at one go.SyntaxFollowing is the syntax for −Setting the borderImage property −object.style.borderImage = "source slice width outset repeat|initial|inherit"ValuesThe property values are explained as follows −Sr.NoValues & Description1borderImageSourceIt specifies the image path to be used as a border.2borderImageSliceIt specifies the image-border inward offsets.3borderImageWidthIt specifies the image-border width.4borderImageOutsetIt specifies the border image area amount by which it extends beyond the border box.5borderImageRepeatIt specifies that the image-border should be rounded, repeated ... Read More

Advertisements