Detect Long Press in Android

Azhar
Updated on 03-Jul-2020 11:28:52

1K+ Views

This example demonstrates how do I detect long Press 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.GestureDetector; import android.view.MotionEvent; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    GestureDetector gestureDetector;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       gestureDetector = new GestureDetector(this, new GestureListener());   ... Read More

Detect End of ScrollView in Android

Azhar
Updated on 03-Jul-2020 11:28:18

2K+ Views

This example demonstrates how do I detect end of scrollView 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.MotionEvent; import android.view.View; import android.view.ViewTreeObserver; import android.webkit.WebView; import android.widget.ScrollView; import android.widget.Toast; public class MainActivity extends AppCompatActivity implements View.OnTouchListener,    ViewTreeObserver.OnScrollChangedListener {    ScrollView scrollView;    WebView webView;    @Override ... Read More

Create Spinner Programmatically from Array in Android

Azhar
Updated on 03-Jul-2020 11:27:41

2K+ Views

This example demonstrates how do I create spinner programmatically from 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.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.Spinner; public class MainActivity extends AppCompatActivity {    Spinner spinner;    String colors[] = {"Red", "Blue", "White", "Yellow", "Black", "Green", "Purple", "Orange", "Grey"};    ArrayAdapter spinnerArrayAdapter;    @Override    protected void onCreate(Bundle ... Read More

Check Grant Permission at Run Time in Android

Azhar
Updated on 03-Jul-2020 11:27:09

2K+ Views

This example demonstrates how do I check grant permission at un-time 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.Manifest; import android.content.pm.PackageManager; import android.os.Build; import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v4.app.ActivityCompat; import android.widget.Toast; public class MainActivity extends AppCompatActivity{    private static final int REQUEST_PERMISSION_CODE = 101;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

Use Volley Library to Parse JSON in Android App

Azhar
Updated on 03-Jul-2020 11:26:36

1K+ Views

This example demonstrates how do I use a volley Library to parse a JSON in 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 – To create a JsonArray, go to https://myjson.com/ create your own JsonArray, for example, refer the code below.{    "employees": [       {          "firstname": "Niyaz",          "age": 30,          "mail": "niyaz3444@gmail.com" ... Read More

Call a Method After a Delay

Azhar
Updated on 03-Jul-2020 11:25:53

971 Views

This example demonstrates how do I call method after a delay 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.os.Handler; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       Handler handler = new Handler();       handler.postDelayed(new Runnable() ... Read More

Jump to Home Screen of the App Using a Button in Android

Azhar
Updated on 03-Jul-2020 11:25:19

1K+ Views

This example demonstrates how do I jump to the home screen of the app using a button 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.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       Button button ... Read More

Specify Order of Flex Items in CSS

Daniol Thomas
Updated on 03-Jul-2020 10:45:06

172 Views

Use the order property to specify the order of a flexible item relative to the rest of the flex items inside the same container.ExampleYou can try to run the following code to implement the order property −Live Demo                    .mycontainer {             display: flex;             background-color: orange;             align-content: space-between;             height: 150px;             width: 600px;             flex-wrap: wrap;          }          .mycontainer > div {             background-color: white;             text-align: center;             line-height: 40px;             font-size: 25px;             width: 100px;             margin: 5px;          }                     Quiz                Q1          Q2          Q3          Q4          Q5          Q6          Q7          Q8          

CSS align-items Property

Nitya Raut
Updated on 03-Jul-2020 10:38:37

138 Views

Use the align-items property to align the flex items.ExampleYou can try to run the following code to implement the align-items property −Live Demo                    .mycontainer {             display: flex;             background-color: orange;             align-items: center;             height: 150px;             width: 600px;          }          .mycontainer > div {             background-color: white;             text-align: center;             line-height: 40px;             font-size: 25px;             width: 100px;             margin: 5px;          }                     Quiz                Q1          Q2          Q3          Q4          

Role of CSS justify-content Property: space-around Value

Rishi Rathor
Updated on 03-Jul-2020 10:35:56

137 Views

Use the justify-content property with value space-around to add space near the lines.ExampleYou can try to run the following code to implement the space-around value −Live Demo                    .mycontainer {             display: flex;             background-color: red;             justify-content: space-around;          }          .mycontainer > div {             background-color: orange;             text-align: center;             line-height: 60px;             font-size: 30px;             width: 100px;             margin: 5px;          }                     Quiz                Q1          Q2          Q3          Q4          

Advertisements