Android ToggleButton

To display checked/unchecked or On/Off state on the button, the Android Toggle Button can be used. When we need to change the settings between two states, like On/Off Sound, Wifi, Bluetooth, etc, the Android Toggle Button is recommended. The switch is a toggle button introduced in Android 4.0 to provide slider control. Both the Android … Read more

Android Custom Toast

In android, custom toast can also be created. Thus, images like congratulations or loss on the toast can be displayed. activity_main.xml: First, we need to drag the component that is needed to be displayed on the main activity. <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" >   <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello Android!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" … Read more

Android Toast

To display information for a short duration, Android Toast can be used. A message needs to be displayed quickly and to disappear after some time is included in a toast. The java.lang.Object class has a subclass of the android.widget.Toast class. A custom toast like toast displaying an image can also be created. Toast class: To … Read more

Android Button

Working with Button: Android Button Example A push-button is represented by the Android Button. The TextView class has an android.widget.Button subclass, while the Button class has a CompoundButton subclass. The button type in android includes RadioButton, ToggleButton, CompoundButton, and many more. Android Button Example with Listener: The below example is to create two text fields … Read more

Android Widgets

Android supports various widgets such as Button, EditText, AutoCompleteTextView, ToggleButton, DatePicker, TimePicker, ProgressBar, etc. They are easy to learn. The most important android widgets are: Android Button Android Toast Custom Toast ToggleButton CheckBox AlertDialog Spinner AutoCompleteTextView RatingBar DatePicker TimePicker ProgressBar

Screen Orientation Android

Being the attribute of the activity element, the screenOrientation allows the orientation of an android activity to be either of the portrait, landscape, sensor, unspecified, etc. The orientation type is defined in the AndroidManifest.xml file. Syntax: <activity android:name="package_name.Your_ActivityName" android:screenOrientation="orientation_type"> </activity><activity android:name="package_name.Your_ActivityName" android:screenOrientation="orientation_type"> </activity> Example: <activity android:name=" example.screenorientation.MainActivity" android:screenOrientation="landscape"> </activity>   <activity android:name=".SecondActivity" android:screenOrientation="portrait"> </activity><activity android:name=" … Read more

Android Hide Title Bar

We are going to discuss the ways to hide the title bar and to display the content in full-screen mode. requestWindowFeature(Window.FEATURE_NO_TITLE): It is a method of Activity, which must be coded before the setContentView method. It is called to hide the title. Code that hides title bar of activity: getSupportActionBar() method: Used to retrieve the … Read more

Android R.java file

Being an auto-generated file that is generated by AAPT (Android Asset Packaging Tool), Android R.java contains resource IDs for all the resources of res/ directory. The id for the created component is automatically generated in the R.java whenever a component is created in the android activity_main.xml file. The life cycle methods for an activity such … Read more

AndroidManifest.xml file in android

The information of the package, along with the components of the application such as activities, services, broadcast receivers, content providers, etc, are included in the AndroidManifest.xml file in android. There are also some other tasks performed by the AndroidManifest.xml file. These are: To protect the application to access any protected parts by providing the permissions. … Read more

Hello World Android

How to make android apps Here, we are going to create the simple hello android application using the Eclipse IDE. Follow the below steps: Create the new android project Write the message Run the android application Create the New Android project Follow the below steps to create a new android studio project: First select Start … Read more