Found 1626 Articles for Android

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

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

258 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

5K+ 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

4K+ 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

778 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

1K+ 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

How to add a button to PreferenceScreen in Android?

Azhar
Updated on 07-Jul-2020 09:14:41

2K+ Views

This example demonstrates how do I add a button to PreferenceScreen in android.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 android.os.Bundle; import android.widget.Toast; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.main_activity);       getSupportFragmentManager().beginTransaction().replace(R.id.settings, new SettingsFragment()).commit();       ... Read More

Work with google docs offline using android

Samual Sam
Updated on 23-Oct-2019 06:33:14

181 Views

In many places; airplane, café, ships, etc…. you don’t get proper internet connection, but for many people work become necessary wherever they are. Google Docs helps those kinds of people through Offline mode feature. Using Google Drive, you can edit documents, spreadsheets, and presentations offline, you can access files on your mobile devices and whenever you come back online, your changes on the Docs will be synced to the cloud.Before using Google Docs offline, the question comes in mind that how do we implement this?It is very simple, just install Google Docs and Google Sheets on your Android device and ... Read More

How to upgrade your smartphone to android m

Samual Sam
Updated on 13-May-2022 07:21:27

172 Views

The latest version of Android, Android Marshmallow, is often referred to as Android M. Android M comes with a lot of new cosmetic upgrades for the phones along with many bug fixes. Android M comes with new features like refined permissions, simplified volume controls, improved copy and paste function, Google Now on Tap, and Android Pay.Not only that, it also has an built-in fingerprint scanning support and many other new enhancements which makes it a highly desired smartphone OS in 2016. Android M, being the desired smartphone OS used by the majority of the community, is almost a must-have for ... Read More

Advertisements