Found 1631 Articles for Android

Android imageView Zoom-in and Zoom-Out?

Azhar
Updated on 07-Jul-2020 11:53:39

6K+ Views

This example demonstrates how do I Zoom In and Zoom Out an android ImageView.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.view.MotionEvent; import android.view.ScaleGestureDetector; import android.widget.ImageView; public class MainActivity extends AppCompatActivity {    private ScaleGestureDetector scaleGestureDetector;    private float mScaleFactor = 1.0f;    private ImageView imageView;      @Override    protected void onCreate(Bundle savedInstanceState) {       ... Read More

How to disable back button in android while logging out the application?

Azhar
Updated on 07-Jul-2020 11:54:34

982 Views

This example demonstrates how do I disable back button in android while logging out the application.Step 1 − Create a new project in Android Studio, go to File rArr; 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.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    @Override    public void onBackPressed() {       ... Read More

How to disable Mobile Data on Android?

Azhar
Updated on 07-Jul-2020 11:48:58

1K+ Views

This example demonstrates how do I disable Mobile data in Android.For your find Information, unless you have a rooted phone I don't think you can enable and disable data programmatically because in order to do so we have to include MODIFY_PHONE_STATE permission which is only given to system or signature apps.setMobileDataEnabled() method is no longer callable via reflection. It was callable since Android 2.1 (API 7) to Android 4.4 (API 19) via reflection, but as of Android 5.0 and later, even with the rooted phones, the setMobileDataEnabled() method is not callable.Step 1 − Create a new project in Android Studio, ... Read More

How do we set the input type for an Android EditText programatically?

Azhar
Updated on 07-Jul-2020 11:47:39

156 Views

This example demonstrates how do I set the input type for an Android EditText programmatically.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.text.InputType; import android.view.View; import android.widget.EditText; public class MainActivity extends AppCompatActivity {    EditText editText;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);     ... Read More

How to set the value for the attribute layout_weight for button in Android dynamically from java code?

Azhar
Updated on 08-Jul-2020 05:50:42

1K+ Views

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

How do I hide and show a menu item in the Android ActionBar?

Azhar
Updated on 07-Jul-2020 11:43:04

4K+ Views

This example demonstrates how do I hide and show a menu item in the Android ActionBar.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.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.widget.CompoundButton; import android.widget.ToggleButton; public class MainActivity extends AppCompatActivity {    ToggleButton button1;    Menu myMenu;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);     ... Read More

How to load files from asset directory into WebView in Android?

Azhar
Updated on 07-Jul-2020 11:44:21

3K+ Views

This example demonstrates how do I load files from asset directory into WebView 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; import android.webkit.WebView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       WebView webView = findViewById(R.id.webView);       webView.loadUrl("file:///android_asset/mytext.html"); ... Read More

How to convert a color integer to a hex String in Android?

Azhar
Updated on 07-Jul-2020 11:44:56

3K+ Views

This example demonstrates how do I 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; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       TextView textView = findViewById(R.id.textView);       int intColor = -16895234;       String hexColor = ... Read More

How can I override the 'Home' button in my Android App?

Azhar
Updated on 07-Jul-2020 11:40:42

581 Views

This example demonstrates how do I 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; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    @Override    protected void onUserLeaveHint(){       Toast.makeText(getApplicationContext(), "Home Button is Pressed", Toast.LENGTH_SHORT).show();       ... Read More

How to get the Android Emulator's IP address?

Azhar
Updated on 23-Oct-2019 08:34:58

839 Views

This example demonstrates how do I get the Android Emulator’s IP address.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.net.wifi.WifiManager; import android.os.Bundle; import android.text.format.Formatter; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    Button button;    TextView textview;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main); ... Read More

Advertisements