SlideShare une entreprise Scribd logo
1  sur  25
Alexey Ustenko programmer @ustav
Разработка приложений для Android Honeycomb: ActionBar & Fragments
ActionBar
Режим совместимости
Стандартный режим
< manifest   xmlns:android = &quot;http://schemas.android.com/apk/res/android&quot; package = &quot;com.example.helloworld&quot; android:versionCode = &quot;1&quot; android:versionName = &quot;1.0&quot; > < uses-sdk   android:minSdkVersion = &quot;4&quot; android:targetSdkVersion = &quot;11&quot;   /> < application   . ..  > ... </ application > </ manifest > Включить отображение ActionBar
Анатомия - Home icon - Title - Navigation - Custom View placeholder - Action buttons
@Override public   boolean   onOptionsItemSelected(MenuItem item)  { switch  (item.getItemId()) { case   android.R.id. home : //  app  icon in Action Bar clicked; go home Intent intent =  new  Intent( this ,  HomeActivity . class ); intent.addFlags(Intent. FLAG_ACTIVITY_CLEAR_TOP ); startActivity(intent); return   true ; default : return   super .onOptionsItemSelected(item); } } Home icon
ActionBar actionBar =  this .getActionBar(); actionBar. setDisplayHomeAsUpEnabled( true ) ; Home as “Up”
NAVIGATION_MODE_LIST NAVIGATION_MODE_TABS Navigation Mode
<? xml   version = &quot;1.0&quot;   encoding = &quot;utf-8&quot; ?> < menu   xmlns:android = &quot;http://schemas.android.com/apk/res/android&quot; > < item   android:id = &quot;@+id/menu_search&quot; android:title = &quot;Search&quot; android:icon = &quot;@drawable/ic_menu_search&quot; android:showAsAction = &quot;ifRoom&quot; android:actionLayout = &quot;@layout/searchview&quot;   /> </ menu > <? xml   version = &quot;1.0&quot;   encoding = &quot;utf-8&quot; ?> < menu   xmlns:android = &quot;http://schemas.android.com/apk/res/android&quot; > < item   android:id = &quot;@+id/menu_search&quot; android:title = &quot;Search&quot; android:icon = &quot;@drawable/ic_menu_search&quot; android:showAsAction = &quot;ifRoom&quot; android:actionViewClass = &quot;android.widget.SearchView&quot;   /> </ menu > Action Layout
Action Mode
getActivity().startActionMode ( new  Callback() { @Override public   boolean  onPrepareActionMode(ActionMode mode, Menu menu) { return   false ; } @Override public   void  onDestroyActionMode(ActionMode mode) { } @Override public   boolean  onCreateActionMode(ActionMode mode, Menu menu) { return   false ; } @Override public   boolean  onActionItemClicked(ActionMode mode, MenuItem item) { return   false ; } }); Action Mode code example
Fragments
Жизненный цикл
DialogFragment
ListFragment
PreferenceFragment
<? xml   version = &quot;1.0&quot;   encoding = &quot;utf-8&quot; ?> < LinearLayout   xmlns:android = &quot;http://schemas.android.com/apk/res/android&quot; android:orientation = &quot;horizontal&quot; android:layout_width = &quot; match_parent &quot; android:layout_height = &quot; match_parent &quot; > < fragment   android:name = &quot;com.example.news.ArticleListFragment&quot; android:id = &quot;@+id/list&quot; android:layout_weight = &quot;1&quot; android:layout_width = &quot;0dp&quot; android:layout_height = &quot; match_parent &quot;   /> < fragment   android:name = &quot;com.example.news.ArticleReaderFragment&quot; android:id = &quot;@+id/viewer&quot; android:layout_weight = &quot;2&quot; android:layout_width = &quot;0dp&quot; android:layout_height = &quot; match_parent &quot;   /> </ LinearLayout > Add a Fragment in XML
FragmentManager fragmentManager = getFragmentManager( ); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); ExampleFragment  fragment =  new   ExampleFragment (); fragmentTransaction.add(R.id.fragment_container, fragment); fragmentTransaction.commit(); Add a Fragment in code
// Create new fragment and transaction Fragment newFragment =  new  ExampleFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack( null ); // Commit the transaction transaction.commit(); Fragment transactions
Communicating with the Activity View listView = getActivity().findViewById(R.id. list); Tab2Fragment fragment = (Tab2Fragment) getFragmentManager().findFragmentById(R.id.tab2); From Fragment to Activity From Activity (of another Fragment) to Fragment Tab2Fragment fragment = (Tab2Fragment) getFragmentManager().findFragmentByTag( &quot;tab2&quot; );
Custom action buttons for Fragment public   class  Tab2Fragment  extends  Fragment { @Override public  View onCreateView(LayoutInflater inflater, ViewGroup parent,  Bundle state) { View view = inflater.inflate(R.layout. tab2 ,  null ); setHasOptionsMenu( true ); return  view; } @Override public   void  onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu. tab2_menu , menu); } }
Фрагменты доступны с версии Android 1.6 (API level 4)  при использовании пакета совместимости,  который входит в Android SDK (android-support-v4.jar)
http://developer.android.com

Contenu connexe

Tendances

Android tutorial
Android tutorialAndroid tutorial
Android tutorialkatayoon_bz
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialEd Zel
 
2018 UI5con Drag-and-Drop Concept
2018 UI5con Drag-and-Drop Concept2018 UI5con Drag-and-Drop Concept
2018 UI5con Drag-and-Drop Conceptaborjinik
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldTarunsingh198
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)Google
 
android design pattern
android design patternandroid design pattern
android design patternLucas Xu
 
Android training day 2
Android training day 2Android training day 2
Android training day 2Vivek Bhusal
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2Vivek Bhusal
 
JSF Custom Components
JSF Custom ComponentsJSF Custom Components
JSF Custom ComponentsMichael Fons
 
Android Screen Containers & Layouts
Android Screen Containers & LayoutsAndroid Screen Containers & Layouts
Android Screen Containers & LayoutsVijay Rastogi
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspectiveGunjan Kumar
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espressoÉdipo Souza
 
Android appwidget
Android appwidgetAndroid appwidget
Android appwidgetKrazy Koder
 

Tendances (20)

Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
2018 UI5con Drag-and-Drop Concept
2018 UI5con Drag-and-Drop Concept2018 UI5con Drag-and-Drop Concept
2018 UI5con Drag-and-Drop Concept
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello world
 
What's new in android jakarta gdg (2015-08-26)
What's new in android   jakarta gdg (2015-08-26)What's new in android   jakarta gdg (2015-08-26)
What's new in android jakarta gdg (2015-08-26)
 
android design pattern
android design patternandroid design pattern
android design pattern
 
Android training day 2
Android training day 2Android training day 2
Android training day 2
 
Android Widget
Android WidgetAndroid Widget
Android Widget
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 
Android UI Fundamentals part 1
Android UI Fundamentals part 1Android UI Fundamentals part 1
Android UI Fundamentals part 1
 
JSF Custom Components
JSF Custom ComponentsJSF Custom Components
JSF Custom Components
 
Android Screen Containers & Layouts
Android Screen Containers & LayoutsAndroid Screen Containers & Layouts
Android Screen Containers & Layouts
 
Getting started with android dev and test perspective
Getting started with android   dev and test perspectiveGetting started with android   dev and test perspective
Getting started with android dev and test perspective
 
Day seven
Day sevenDay seven
Day seven
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espresso
 
Developing in android
Developing in androidDeveloping in android
Developing in android
 
Android appwidget
Android appwidgetAndroid appwidget
Android appwidget
 

En vedette

Bosnia 19 Feb 09
Bosnia 19 Feb 09Bosnia 19 Feb 09
Bosnia 19 Feb 09Ivan
 
Apresentacaoportugues#2
Apresentacaoportugues#2Apresentacaoportugues#2
Apresentacaoportugues#2complice9
 
God Blessed Beauty-天赐之美
God Blessed Beauty-天赐之美God Blessed Beauty-天赐之美
God Blessed Beauty-天赐之美Dean Shen
 
Droidcon 2011: Gingerbread and honeycomb, Markus Junginger, Greenrobot
Droidcon 2011: Gingerbread and honeycomb, Markus Junginger,  GreenrobotDroidcon 2011: Gingerbread and honeycomb, Markus Junginger,  Greenrobot
Droidcon 2011: Gingerbread and honeycomb, Markus Junginger, GreenrobotDroidcon Berlin
 
Unit 7-phaserule
Unit 7-phaseruleUnit 7-phaserule
Unit 7-phaseruleanuragmbst
 
Modes of heat transfer
Modes of heat transferModes of heat transfer
Modes of heat transferRIFFAT_ZAHID
 
Transient heat-conduction-Part-I
Transient heat-conduction-Part-ITransient heat-conduction-Part-I
Transient heat-conduction-Part-Itmuliya
 
heat conduction equations
heat conduction equationsheat conduction equations
heat conduction equationsZahir Baloch
 
Radiation heat transfer
Radiation heat transferRadiation heat transfer
Radiation heat transferAravind Sp
 
Lectures on Heat Transfer - Introduction - Applications - Fundamentals - Gove...
Lectures on Heat Transfer - Introduction - Applications - Fundamentals - Gove...Lectures on Heat Transfer - Introduction - Applications - Fundamentals - Gove...
Lectures on Heat Transfer - Introduction - Applications - Fundamentals - Gove...tmuliya
 
02-22-08 - Conduction, Convection & Radiation
02-22-08 - Conduction, Convection & Radiation02-22-08 - Conduction, Convection & Radiation
02-22-08 - Conduction, Convection & Radiationwjerlinger
 
Heat transfer
Heat transferHeat transfer
Heat transferLightkcse
 

En vedette (20)

Android overview
Android overviewAndroid overview
Android overview
 
Bosnia 19 Feb 09
Bosnia 19 Feb 09Bosnia 19 Feb 09
Bosnia 19 Feb 09
 
Apresentacaoportugues#2
Apresentacaoportugues#2Apresentacaoportugues#2
Apresentacaoportugues#2
 
God Blessed Beauty-天赐之美
God Blessed Beauty-天赐之美God Blessed Beauty-天赐之美
God Blessed Beauty-天赐之美
 
Cpg ua nstemi
Cpg ua nstemiCpg ua nstemi
Cpg ua nstemi
 
Ci for Android
Ci for AndroidCi for Android
Ci for Android
 
Droidcon 2011: Gingerbread and honeycomb, Markus Junginger, Greenrobot
Droidcon 2011: Gingerbread and honeycomb, Markus Junginger,  GreenrobotDroidcon 2011: Gingerbread and honeycomb, Markus Junginger,  Greenrobot
Droidcon 2011: Gingerbread and honeycomb, Markus Junginger, Greenrobot
 
Perpindahan panas
Perpindahan panasPerpindahan panas
Perpindahan panas
 
Introduction and Basic Modes of Heat Transfer
Introduction and Basic Modes of Heat TransferIntroduction and Basic Modes of Heat Transfer
Introduction and Basic Modes of Heat Transfer
 
Unit 7-phaserule
Unit 7-phaseruleUnit 7-phaserule
Unit 7-phaserule
 
Modes of heat transfer
Modes of heat transferModes of heat transfer
Modes of heat transfer
 
Modes of transfer of heat
Modes of transfer of heatModes of transfer of heat
Modes of transfer of heat
 
Detailed engineering-design-phase
Detailed engineering-design-phaseDetailed engineering-design-phase
Detailed engineering-design-phase
 
Transient heat-conduction-Part-I
Transient heat-conduction-Part-ITransient heat-conduction-Part-I
Transient heat-conduction-Part-I
 
heat conduction equations
heat conduction equationsheat conduction equations
heat conduction equations
 
Radiation heat transfer
Radiation heat transferRadiation heat transfer
Radiation heat transfer
 
Lectures on Heat Transfer - Introduction - Applications - Fundamentals - Gove...
Lectures on Heat Transfer - Introduction - Applications - Fundamentals - Gove...Lectures on Heat Transfer - Introduction - Applications - Fundamentals - Gove...
Lectures on Heat Transfer - Introduction - Applications - Fundamentals - Gove...
 
02-22-08 - Conduction, Convection & Radiation
02-22-08 - Conduction, Convection & Radiation02-22-08 - Conduction, Convection & Radiation
02-22-08 - Conduction, Convection & Radiation
 
Heat transfer
Heat transferHeat transfer
Heat transfer
 
Reactor types.ppt
Reactor types.pptReactor types.ppt
Reactor types.ppt
 

Similaire à Разработка приложений для Android Honeycomb: ActionBar & Fragments

Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android FragmentsSergi Martínez
 
Struts2
Struts2Struts2
Struts2yuvalb
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...Kirill Chebunin
 
Advanced Android gReporter
Advanced Android gReporterAdvanced Android gReporter
Advanced Android gReporternatdefreitas
 
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010Sergey Ilinsky
 
Alfresco Forms Service Deep Dive
Alfresco Forms Service Deep DiveAlfresco Forms Service Deep Dive
Alfresco Forms Service Deep DiveAlfresco Software
 
Liferay Training Struts Portlet
Liferay Training Struts PortletLiferay Training Struts Portlet
Liferay Training Struts PortletSaikrishna Basetti
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On RailsWen-Tien Chang
 
Introduction into Struts2 jQuery Grid Tags
Introduction into Struts2 jQuery Grid TagsIntroduction into Struts2 jQuery Grid Tags
Introduction into Struts2 jQuery Grid TagsJohannes Geppert
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax componentsIgnacio Coloma
 
Web APIs & Google APIs
Web APIs & Google APIsWeb APIs & Google APIs
Web APIs & Google APIsPamela Fox
 
Composite Applications with WPF and PRISM
Composite Applications with WPF and PRISMComposite Applications with WPF and PRISM
Composite Applications with WPF and PRISMEyal Vardi
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentationipolevoy
 
STYLISH FLOOR
STYLISH FLOORSTYLISH FLOOR
STYLISH FLOORABU HASAN
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2wiradikusuma
 

Similaire à Разработка приложений для Android Honeycomb: ActionBar & Fragments (20)

Introduction to Android Fragments
Introduction to Android FragmentsIntroduction to Android Fragments
Introduction to Android Fragments
 
Struts2
Struts2Struts2
Struts2
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
Advanced Android gReporter
Advanced Android gReporterAdvanced Android gReporter
Advanced Android gReporter
 
Rich faces
Rich facesRich faces
Rich faces
 
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
 
Alfresco Forms Service Deep Dive
Alfresco Forms Service Deep DiveAlfresco Forms Service Deep Dive
Alfresco Forms Service Deep Dive
 
Retrofitting
RetrofittingRetrofitting
Retrofitting
 
Liferay Training Struts Portlet
Liferay Training Struts PortletLiferay Training Struts Portlet
Liferay Training Struts Portlet
 
Spring 2.0
Spring 2.0Spring 2.0
Spring 2.0
 
Spring 2.0
Spring 2.0Spring 2.0
Spring 2.0
 
Building Web Interface On Rails
Building Web Interface On RailsBuilding Web Interface On Rails
Building Web Interface On Rails
 
Introduction into Struts2 jQuery Grid Tags
Introduction into Struts2 jQuery Grid TagsIntroduction into Struts2 jQuery Grid Tags
Introduction into Struts2 jQuery Grid Tags
 
Developing and testing ajax components
Developing and testing ajax componentsDeveloping and testing ajax components
Developing and testing ajax components
 
Web APIs & Google APIs
Web APIs & Google APIsWeb APIs & Google APIs
Web APIs & Google APIs
 
Composite Applications with WPF and PRISM
Composite Applications with WPF and PRISMComposite Applications with WPF and PRISM
Composite Applications with WPF and PRISM
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
DevDays09 Internet Explorer 8
DevDays09 Internet Explorer 8DevDays09 Internet Explorer 8
DevDays09 Internet Explorer 8
 
STYLISH FLOOR
STYLISH FLOORSTYLISH FLOOR
STYLISH FLOOR
 
Introducing Struts 2
Introducing Struts 2Introducing Struts 2
Introducing Struts 2
 

Plus de Alexey Ustenko

Разработка мобильных приложений в большой компании. Взгляд изнутри.
Разработка мобильных приложений в большой компании. Взгляд изнутри.Разработка мобильных приложений в большой компании. Взгляд изнутри.
Разработка мобильных приложений в большой компании. Взгляд изнутри.Alexey Ustenko
 
Android Support Library
Android Support LibraryAndroid Support Library
Android Support LibraryAlexey Ustenko
 
Верстка для Андроид
Верстка для АндроидВерстка для Андроид
Верстка для АндроидAlexey Ustenko
 
Content providers in Android
Content providers in AndroidContent providers in Android
Content providers in AndroidAlexey Ustenko
 
Android application structure
Android application structureAndroid application structure
Android application structureAlexey Ustenko
 
Разработка под Android для устройств разных разрешений и размеров
Разработка под Android для устройств разных разрешений и размеровРазработка под Android для устройств разных разрешений и размеров
Разработка под Android для устройств разных разрешений и размеровAlexey Ustenko
 

Plus de Alexey Ustenko (6)

Разработка мобильных приложений в большой компании. Взгляд изнутри.
Разработка мобильных приложений в большой компании. Взгляд изнутри.Разработка мобильных приложений в большой компании. Взгляд изнутри.
Разработка мобильных приложений в большой компании. Взгляд изнутри.
 
Android Support Library
Android Support LibraryAndroid Support Library
Android Support Library
 
Верстка для Андроид
Верстка для АндроидВерстка для Андроид
Верстка для Андроид
 
Content providers in Android
Content providers in AndroidContent providers in Android
Content providers in Android
 
Android application structure
Android application structureAndroid application structure
Android application structure
 
Разработка под Android для устройств разных разрешений и размеров
Разработка под Android для устройств разных разрешений и размеровРазработка под Android для устройств разных разрешений и размеров
Разработка под Android для устройств разных разрешений и размеров
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Dernier (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Разработка приложений для Android Honeycomb: ActionBar & Fragments

  • 2. Разработка приложений для Android Honeycomb: ActionBar & Fragments
  • 6. < manifest xmlns:android = &quot;http://schemas.android.com/apk/res/android&quot; package = &quot;com.example.helloworld&quot; android:versionCode = &quot;1&quot; android:versionName = &quot;1.0&quot; > < uses-sdk android:minSdkVersion = &quot;4&quot; android:targetSdkVersion = &quot;11&quot; /> < application . .. > ... </ application > </ manifest > Включить отображение ActionBar
  • 7. Анатомия - Home icon - Title - Navigation - Custom View placeholder - Action buttons
  • 8. @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id. home : // app icon in Action Bar clicked; go home Intent intent = new Intent( this , HomeActivity . class ); intent.addFlags(Intent. FLAG_ACTIVITY_CLEAR_TOP ); startActivity(intent); return true ; default : return super .onOptionsItemSelected(item); } } Home icon
  • 9. ActionBar actionBar = this .getActionBar(); actionBar. setDisplayHomeAsUpEnabled( true ) ; Home as “Up”
  • 11. <? xml version = &quot;1.0&quot; encoding = &quot;utf-8&quot; ?> < menu xmlns:android = &quot;http://schemas.android.com/apk/res/android&quot; > < item android:id = &quot;@+id/menu_search&quot; android:title = &quot;Search&quot; android:icon = &quot;@drawable/ic_menu_search&quot; android:showAsAction = &quot;ifRoom&quot; android:actionLayout = &quot;@layout/searchview&quot; /> </ menu > <? xml version = &quot;1.0&quot; encoding = &quot;utf-8&quot; ?> < menu xmlns:android = &quot;http://schemas.android.com/apk/res/android&quot; > < item android:id = &quot;@+id/menu_search&quot; android:title = &quot;Search&quot; android:icon = &quot;@drawable/ic_menu_search&quot; android:showAsAction = &quot;ifRoom&quot; android:actionViewClass = &quot;android.widget.SearchView&quot; /> </ menu > Action Layout
  • 13. getActivity().startActionMode ( new Callback() { @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false ; } @Override public void onDestroyActionMode(ActionMode mode) { } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false ; } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false ; } }); Action Mode code example
  • 19. <? xml version = &quot;1.0&quot; encoding = &quot;utf-8&quot; ?> < LinearLayout xmlns:android = &quot;http://schemas.android.com/apk/res/android&quot; android:orientation = &quot;horizontal&quot; android:layout_width = &quot; match_parent &quot; android:layout_height = &quot; match_parent &quot; > < fragment android:name = &quot;com.example.news.ArticleListFragment&quot; android:id = &quot;@+id/list&quot; android:layout_weight = &quot;1&quot; android:layout_width = &quot;0dp&quot; android:layout_height = &quot; match_parent &quot; /> < fragment android:name = &quot;com.example.news.ArticleReaderFragment&quot; android:id = &quot;@+id/viewer&quot; android:layout_weight = &quot;2&quot; android:layout_width = &quot;0dp&quot; android:layout_height = &quot; match_parent &quot; /> </ LinearLayout > Add a Fragment in XML
  • 20. FragmentManager fragmentManager = getFragmentManager( ); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); ExampleFragment fragment = new ExampleFragment (); fragmentTransaction.add(R.id.fragment_container, fragment); fragmentTransaction.commit(); Add a Fragment in code
  • 21. // Create new fragment and transaction Fragment newFragment = new ExampleFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); // Replace whatever is in the fragment_container view with this fragment, // and add the transaction to the back stack transaction.replace(R.id.fragment_container, newFragment); transaction.addToBackStack( null ); // Commit the transaction transaction.commit(); Fragment transactions
  • 22. Communicating with the Activity View listView = getActivity().findViewById(R.id. list); Tab2Fragment fragment = (Tab2Fragment) getFragmentManager().findFragmentById(R.id.tab2); From Fragment to Activity From Activity (of another Fragment) to Fragment Tab2Fragment fragment = (Tab2Fragment) getFragmentManager().findFragmentByTag( &quot;tab2&quot; );
  • 23. Custom action buttons for Fragment public class Tab2Fragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle state) { View view = inflater.inflate(R.layout. tab2 , null ); setHasOptionsMenu( true ); return view; } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu. tab2_menu , menu); } }
  • 24. Фрагменты доступны с версии Android 1.6 (API level 4) при использовании пакета совместимости, который входит в Android SDK (android-support-v4.jar)

Notes de l'éditeur

  1. Android introduced fragments in Android 3.0 (API Level &amp;quot;Honeycomb&amp;quot;), primarily to support more dynamic and flexible UI designs on large screens, such as tablets. Because a tablet&apos;s screen is much larger than that of a mobile phone, there&apos;s more room to combine and interchange UI components A fragment should be a modular and reusable component in your application.