SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie Разработка приложений для 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
 

Ähnlich wie Разработка приложений для 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
 

Mehr von 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
 

Mehr von 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 для устройств разных разрешений и размеров
 

Kürzlich hochgeladen

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Kürzlich hochgeladen (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.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)

Hinweis der Redaktion

  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.