Unit2 Compressed
Unit2 Compressed
Onpause()
Onstart()
Onresume()
• Activity doesn’t exist
UI DESIGN • Foreground activity
• Background activity Onresume()
Foreground Activity Pause(onpause(),
onresume())
• Pause Onpause()
Onstart()
• Android Activity Lifecycle is controlled by 7 methods
of android.app.Activity class. The android Activity is Onrestart() Onstop()
the subclass of MainActivity class. Background Activity
Android Activity
File: MainActivity.java File: MainActivity.java File: MainActivity.java
Lifecycle methods
• package example.javatpoint.com.activitylifecycle; • @Override • @Override
• import android.app.Activity; • protected void onStart() { • protected void onPause() {
• import android.os.Bundle; • super.onStart(); • super.onPause();
• import android.util.Log; • Log.d("lifecycle","onStart invoked"); • Log.d("lifecycle","onPause invoked");
• public class MainActivity extends Activity {
• } • }
• @Override
• @Override • @Override
• protected void onCreate(Bundle savedInstanceStat
e) { • protected void onResume() { • protected void onStop() {
• super.onCreate(savedInstanceState); • super.onResume(); • super.onStop();
• setContentView(R.layout.activity_main); • Log.d("lifecycle","onResume invoked"); • Log.d("lifecycle","onStop invoked");
• Log.d("lifecycle","onCreate invoked"); • } • }
• }
v7 Preference Support
v7 recyclerview library API Level: 21 Intent
Library
• The recyclerview library adds the RecyclerView class. • The preference package provides APIs to support • Android 5.0 (LOLLIPOP) offers new features for users • An Intent is a messaging object you can use to request
• This class provides support for the adding preference objects, such and app developers. an action from another app component.
RecyclerView widget, a view for efficiently displaying as CheckBoxPreference and ListPreference, for users to • Support for 64-bit CPUs
large data sets by providing a limited window of data modify UI settings. • Support for print previews
items. • The v7 Preference library adds support for interfaces, • Material design, bringing a restyled user interface.
such as
• Project Volta, for battery life improvements.
• Preference.OnPreferenc eChangeListener
• Smart lock feature.
• Preference.OnPreferenceClick Listener
• Updated emoji.
• and classes, such as
• A flashlight-style application is included.
• CheckBoxPreference
• ListPreference
Views and View Groups Views and View Groups Basic View
• View Class are the basic building block for user • View Group Class • Button: Button is pushed or pressed or clicked.
interface components. • The View-Group is the base class for layouts, which • Every view should have a unique identifier which
• A View occupies a 2-dimensional area (say: rectangle) holds other Views and define their properties. identifies the element in the project. Make sure, two
on the screen, which is responsible for framing and • Actually an application comprises combination and elements should not share their unique ID. We
handling different type of events. nesting of Views-Group and Views Classes. implement certain methods and interfaces which
• Views are used to create input and output fields in the listens to user input and act accordingly.
an Android App. • TextView: This view is basically meant for displaying
• It can be input text field, radio field, image field etc. the text of application. For example the label of
• They are same as, input text field, image tag to show application is displayed here.
images, radio field in HTML.