This example demonstrates how do I convert Drawable to a Bitmap 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.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { ImageView imageView; Button btnConvert; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... Read More
This example demonstrates how do I get zoom functionality for images 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.import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.MotionEvent; import android.view.ScaleGestureDetector; import android.widget.ImageView; public class MainActivity extends AppCompatActivity { private ScaleGestureDetector scaleGestureDetector; private float scaleFactor = 1f; private ImageView imageView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); imageView = findViewById(R.id.imageView); ... Read More
This example demonstrates how do I add google search functionality in an 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.app.SearchManager; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity { EditText editText; Button btnSearch; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... Read More
The HTML DOM touchmove event is triggered when touch is moved across the touch screen.NOTE − This event is only for touch devices.Following is the syntax −Trigger touchmove event in HTML −ontouchmove = "eventFunction()"Trigger touchmove event in JavaScript −eventObject.ontouchmove = eventFunctionNote − We ran Touch event examples on Online HTML Editors accessed on Mobile or systems with touch access. This is done so that we can perform touch operations like touch the screen for 2 seconds.Let us see an example of touchmove event property −Example Live Demo HTML DOM touchmove event * { padding: 2px; ... Read More
The HTML DOM touchstart event is triggered when touch screen is touched.NOTE − This event is only for touch devices.Following is the syntax −Trigger touchstart event in HTML −ontouchstart = "eventFunction()"Trigger touchstart event in JavaScript −eventObject.ontouchstart = eventFunctionNote − We ran Touch event examples on Online HTML Editors accessed on Mobile or systems with touch access. This is done so that we can perform touch operations like touch the screen for 2 seconds.Let us see an example of touchstart event property −Example Live Demo HTML DOM touchstart event form { width:70%; margin: 0 ... Read More
This example demonstrates how to pass data between Activities on Android application.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
This example demonstrates how do I use date and time picker 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.app.DatePickerDialog; import android.app.TimePickerDialog; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.format.DateFormat; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; import android.widget.TimePicker; import java.util.Calendar; public class MainActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener { TextView textView; Button button; int day, month, ... Read More
This example demonstrates how do I get a list of installed android applications.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.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.widget.ArrayAdapter; import android.widget.ListView; import java.util.List; public class MainActivity extends AppCompatActivity { ListView listView; ArrayAdapter arrayAdapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... Read More
This example demonstrates how do I get the dialer to open with the open number displayed 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.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void ShowDialer(View ... Read More
This example demonstrates how do I disable gridView scrolling 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.annotation.SuppressLint; import android.content.Context; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { GridView gridView; Integer[] imageIDs = {R.drawable.one, R.drawable.two, R.drawable.three, R.drawable.four, R.drawable.five, R.drawable.six, R.drawable.seven, R.drawable.eight, R.drawable.nine, R.drawable.ten}; ... Read More