Posts

Showing posts from October, 2019

Android Menu | Different types of menu in android

Image
Android Menu : Android provides an easy and flexible user interface component known as menu, which is used to handle a set of actions. Menu is a set of options, the user can select from to perform an action . Android menu provide a familiar and consistent user experience all over the application.  Android Menu Types of Menu : Android offers three fundamental types of menus : Option Menu Context Menu Popup Menu 1.  Option Menu  : Android option menu is the primary collection of menu items for an activity. It is the place where we implement the actions that have a global impact on the app, such as Search, Settings and Delete. 2. Context Menu : Context menu provides a set of menu options when user perform long click on an Element. Most often context menu is used for items in a  RecyclerView ,  GridView ,  ListView  or other view collections in which the user can perform direct actions on each item. Android provides two differe...

How to create textview in android using android studio ?

Image
TextView : In this tutorial we will learn about how to create a textview    android , how to get the text value using  edittext   from the user and set the text value on textview when  button  is clicked and their example . TextView is an user interface design that displays text to the user . TextView is an android support widget which is used to show the text to the user . 1. Create a New Project : Lets we start with a new project in Android Studio from File New Project ⇒ select Empty Activity and go through it. 2. Add TextView in android xml layout : Add TextView to your XML Layout file i.e. activity_main.xml to create a textview to set the value for better user experience or just add the following code to activity_main.xml file . <TextView android:id="@+id/textView" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Hello World" /> 3. Now find the ...

Activity Life-cycle in Android | Android activity lifecycle

Image
Activity : Activity  is an application component that provide a single focused screen in Android App with which user can interact in order to do something . Activity is the main component of android app, which is displayed as a single window to the user, handles user events and provides behavior for a screen. Activity Lifecycle : The activity life-cycle is the set of states an activity can be in during its entire lifetime, from when it’s created to when it’s destroyed and the system reclaims that activity’s resources. Every screen on Android applications has a lifecycle. At every stage in the lifecycle of an activity has a corresponding callback method like onCreate(), onStart(), onPause() etc. The below Activity life cycle diagram shows the sequence of callback methods : When an activity changes their state, the associated callback method is called . Overriding a lifecycle callback method allows you to add behavior that occurs when your Activity transitions into ...

What is an activity in android ?

Image
Activity : One of the fundamental building block of Android app development is Activity. An activity represents a single screen in Android app with which user can perform a single, focused task such as  dial the phone , take a photo, send an email , or view a map. Activities are usually presented to the user as full-screen windows. Activity Stack to manage the Activity : Activities in the system are managed as activity stacks. Each time a new activity starts, the previous activity is stopped, but the system preserves the activity in a stack (the “back stack”). When a new activity starts, that new activity is pushed onto the back stack and takes user focus. The back stack abides to the basic “last in, first out” stack mechanism, so, when the user is done with the current activity and presses the Back button, that current activity is popped from the stack (and destroyed) and the previous activity resumes. All activities are work together to form a cohesive user experience...