We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Building your first real-world Android app using Xamarin in just 60 minutes

00:00

Formal Metadata

Title
Building your first real-world Android app using Xamarin in just 60 minutes
Title of Series
Number of Parts
133
Author
License
CC Attribution - NonCommercial - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
Do you have a great knowledge about C#? Maybe you’ve already built a great mobile app on Windows Phone or Windows 8 or even Windows 10? Would you like to be able to use your knowledge to build an Android app without having to resort to other languages or IDEs? This is possible using Xamarin! In this session, Gill Cleeren will take you through the creation of your first Android application: Joe’s Coffee Store. Along the way, you will learn the basic concepts of Android such as Activities and see how we can use these from Xamarin.Android. We’ll need to connect with services to get access to data and we’ll learn how to navigate in the app. You’ll see we can do this all of this directly from Visual Studio. We will finish the session by looking at how we can deploy the application to the Google Play Store so it’s ready for our users!
Software developerAndroid (robot)Fundamental theorem of algebraElectronic mailing listTouchscreenVirtual machineAndroid (robot)Mobile appDecision theoryMultiplication signVotingTouchscreenElectronic mailing listCartesian coordinate systemEmailWebsiteBitTranslation (relic)Green's functionFocus (optics)Point (geometry)Software developerData storage deviceData managementComputer iconBuildingMathematicsWordBootingPlastikkarteoutputExtension (kinesiology)AuthorizationTwitterView (database)Projective planeFundamental theorem of algebraFitness functionComputer animation
Software developerAndroid (robot)Hydraulic jumpCartesian coordinate systemBitIntegrated development environmentTouchscreenText editorGame controllerHydraulic jumpDemo (music)Electronic mailing listMultiplication signComputer animation
Software developerComputing platformMobile WebVisual systemProduct (business)User interfaceCodeShared memorySoftware frameworkWeightAndroid (robot)Mobile appWritingWindows PhoneType theoryPhysical systemMaxima and minimaJava appletCartesian coordinate systemPhysical systemSoftware frameworkDifferent (Kate Ryan album)PlanningNetwork topologyLimit (category theory)Multiplication signAndroid (robot)AdditionWindowMappingObservational studyMachine visionComputing platformSpeech synthesisVirtual machineTap (transformer)Link (knot theory)Run time (program lifecycle phase)Object (grammar)Open sourceGreatest elementStudent's t-testMachine codeProduct (business)Mobile appProgramming paradigmFunction (mathematics)Replication (computing)Data storage deviceGoogolRevision controlWeightTouchscreenCross-platformSource codeVideo gameImplementationJava appletSpectrum (functional analysis)BitCASE <Informatik>User interfaceShared memoryQuicksortService (economics)CodeBlogPoint (geometry)Process (computing)Compilation albumElement (mathematics)Building.NET FrameworkNamespaceoutputVisualization (computer graphics)Web 2.0Real numberDisk read-and-write headPerspective (visual)Hidden Markov modelWrapper (data mining)MereologyInstallation artWritingGroup actionSoftware developerSlide ruleBoom (sailing)Focus (optics)Form (programming)Software testingIndependence (probability theory)FreewareIntegrated development environmentHoaxView (database)
Java appletCodeWeightSoftware developerComputing platformLatent heatAbstractionInterface (computing)ArchitectureShared memoryWindows PhoneAndroid (robot)Visual systemEmulatorSoftware development kitInstallation artComputer configurationDevice driverVirtual realityHypercubeFundamental theorem of algebraComputer fileCartesian coordinate systemLevel (video gaming)Computer architectureTemplate (C++)Virtual machineoutputFile systemLibrary (computing)Mobile appMachine codeSocial classCodeType theoryProduct (business)String (computer science)Projective planeDifferent (Kate Ryan album)Software developerBitCovering spaceBookmark (World Wide Web)Run time (program lifecycle phase)BuildingComputer fileWindowJava appletAndroid (robot)Computer configurationService (economics)Demo (music)Computing platformPortable communications deviceVisualization (computer graphics)Multiplication signUniverse (mathematics)Fundamental theorem of algebraAverageBytecodeInstallation artHypercubeEndliche ModelltheorieProcess (computing)TouchscreenSurfaceMedical imagingSoftware maintenanceRevision controlOpen setTerm (mathematics)Focus (optics)Just-in-Time-CompilerEmulatorBlock (periodic table)Object (grammar).NET FrameworkShared memoryDefault (computer science)GoogolNetwork topologyGoodness of fitRight angleSoftware testingBoom (sailing)Wave packetVirtualizationSurgerySequelCASE <Informatik>Physical lawMachine visionCuboidWritingFamilyAnalytic setReplication (computing)Computer animation
View (database)Fundamental theorem of algebraCodeSoftware developerMobile appSocial classAndroid (robot)Read-only memoryStructural loadLatent heatInternet forumTask (computing)TouchscreenMathematicsVariable (mathematics)Computer fileString (computer science)Cartesian coordinate systemTouchscreenCASE <Informatik>1 (number)View (database)Computer fileSocial classUser interfaceData managementProcess (computing)BitCodeBuildingState of matterNumberSlide ruleAnalogyBlock (periodic table)Intrusion detection systemBridging (networking)Computer iconMobile appTask (computing)Default (computer science)Tap (transformer)WindowPrice indexMultiplication signEqualiser (mathematics)Functional (mathematics)Parameter (computer programming)Fitness functionCuboidAndroid (robot)Content (media)Line (geometry)Focus (optics)Function (mathematics)Attribute grammarCompilation albumArithmetic meanPoint (geometry)Feasibility studyEvent horizonSemiconductor memoryLinearizationDeclarative programmingPlastikkarteSource codeGame controllerText editorDifferent (Kate Ryan album)Extension (kinesiology)Data structureSet (mathematics)Visualization (computer graphics)Insertion lossParticle systemForestGreatest elementVideo gameCycle (graph theory)Replication (computing)Diffuser (automotive)Network topologyZoom lensMereologyDirectory serviceRow (database)Program flowchart
CodeGUI widgetSoftware developerCategory of beingRepresentation (politics)Control flowPartial derivativeField (computer science)Fundamental theorem of algebraAndroid (robot)Demo (music)MaizeCorrelation and dependencePredictabilityOvalInterior (topology)String (computer science)Computer-generated imageryRepository (publishing)SpeciesFluid staticsCore dumpSpacetimePhysical systemInternet forumTendonRun time (program lifecycle phase)Computer wormMenu (computing)Execution unitReflection (mathematics)Basis <Mathematik>MathematicsSocial classView (database)Demo (music)Android (robot)Core dumpIntegerProjective planeType theoryDirectory serviceMultiplication signContent (media)Computer fileCodeGame controllerCartesian coordinate systemEndliche ModelltheorieoutputMessage passingCuboidIntrusion detection systemEvent horizonData storage deviceRepository (publishing)Revision control2 (number)Attribute grammarSlide ruleService (economics)Keyboard shortcutWindowPortable communications deviceDatabaseTouchscreenComputer iconCASE <Informatik>Text editorInheritance (object-oriented programming)Object-oriented programmingRootInterface (computing)Source codeLine (geometry)Electronic mailing listLibrary (computing)System callSet (mathematics)Medical imagingString (computer science)Computing platformMachine visionOrder (biology)Doubling the cubeRule of inferenceSemiconductor memoryGoodness of fitRoundness (object)Uniform resource locatorQuicksortElectric generatorForestData miningForcing (mathematics)Computer animation
Software developerElectronic mailing listVisual systemView (database)Fundamental theorem of algebraLeakSocial classAndroid (robot)Computer iconFiber bundleOvalString (computer science)Personal digital assistantCountingControl flowParameter (computer programming)Demo (music)Royal NavyCellular automatonExecution unitAndroid (robot)Sheaf (mathematics)ThumbnailProgramming paradigmMereologySource codeView (database)Electronic mailing listWindowoutputObject (grammar)CASE <Informatik>Electronic visual displayState observerRow (database)Mobile appTouchscreenMessage passingType theoryDifferent (Kate Ryan album)Overlay-NetzCategory of beingCountingService (economics)String (computer science)Flow separationDefault (computer science)Open setCartesian coordinate systemAreaInterface (computing)Multiplication signNumberMedical imagingRight angleLine (geometry)WeightKeyboard shortcutVirtualizationStructural loadAdaptive behaviorSocial classParameter (computer programming)Computer fileMusical ensembleSet (mathematics)Control flowMechanism designGreatest elementEmulatorSubject indexingCombinational logicContent (media)Software frameworkCodeBitDivisorExecution unitFrequencyPhysical lawNetwork topologyInstance (computer science)Rule of inferenceMathematicsResultantMachine visionSeries (mathematics)Information securityBuildingGroup actionIdeal (ethics)Boolean algebraField (computer science)System callData storage deviceComputer animation
Electronic mailing listView (database)Software developerInheritance (object-oriented programming)Android (robot)Context awarenessCountingPosition operatorMultiplication signRow (database)Template (C++)Android (robot)Electronic mailing listCodeModal logicCASE <Informatik>Medical imagingOrder (biology)Computer animation
Computer fileSocial classView (database)Data conversionInheritance (object-oriented programming)Software developerContext awarenessDemo (music)Inclusion mapExecution unitView (database)Computer fileRow (database)Keyboard shortcutDemo (music)Right angleGroup actionSource codeMultiplication signNetwork topologyDifferent (Kate Ryan album)CASE <Informatik>Computer clusterAreaQuicksortMetropolitan area networkMathematicsVertex (graph theory)Orientation (vector space)Medical imagingCartesian coordinate systemGame controllerTouchscreenLinearizationInstallation artCodeTexture mappingComputer animation
Software developerAbstractionMilitary operationFundamental theorem of algebraAddress spaceGroup actionAndroid (robot)DialectParsingSocial classInformationFiber bundleOvalService (economics)View (database)Electronic mailing listAndroid (robot)System callNumberMessage passingType theoryGroup actionKey (cryptography)Social classTouchscreenFiber bundleIntegerSampling (statistics)Object (grammar)CASE <Informatik>Multiplication signPhysical systemDifferent (Kate Ryan album)Endliche ModelltheorieCodeCartesian coordinate systemForm (programming)Set (mathematics)Computer animation
Software developerMereologyComplex (psychology)Android (robot)Drop (liquid)Key (cryptography)Service (economics)Row (database)Message passingBitCartesian coordinate systemSynchronizationStructural loadSocial classElectronic mailing listComputer fileSensitivity analysisFunction (mathematics)Lie groupCycle (graph theory)Goodness of fitTouchscreenWebsiteSource codeComputer animation
String (computer science)Android (robot)Software developerFormal languageMultiplicationComputer iconImage resolutionComputer-generated imageryRevision controlFormal languageDrop (liquid)Cartesian coordinate systemDefault (computer science)Type theoryTranslation (relic)String (computer science)Computer fileCASE <Informatik>Data storage deviceAndroid (robot)Computer iconIntrusion detection systemView (database)CodeDemo (music)Computer animation
Software developerCue sportsString (computer science)Revision controlRAIDRun time (program lifecycle phase)Partial derivativeCAN busFluid staticsWeightBuildingMathematical analysisExtension (kinesiology)Point (geometry)Replication (computing)QuicksortTranslation (relic)Data storage deviceMappingWave packetBitCartesian coordinate systemString (computer science)Category of beingFormal languageComputer fileCASE <Informatik>Crash (computing)Multiplication signResultantDifferent (Kate Ryan album)Image resolutionComputer iconType theoryPopulation densityGroup actionCodePixelAndroid (robot)Revision controlDefault (computer science)Intrusion detection systemReal numberSocial classComputer animation
Software developerComputer configurationWebsiteEmailDistribution (mathematics)GoogolBit rateMathematical analysisComputerComputer iconMobile appAndroid (robot)Android (robot)Data storage deviceBuildingComputing platformCurveBitFile Transfer ProtocolFilesharing-SystemComputer fileCartesian coordinate systemWeightGoogolComputer animation
Transcript: English(auto-generated)
Hello everyone, I Hope you had some good food Yeah hamburgers and stuff. Yeah, cool. So what are we going to be doing? We are going to be looking at a Xamarin Android and I'm going to in the next 60 minutes or so
Explain you how you can build. Well a small working application using Xamarin androids So let me first introduce myself very briefly. My name is Sheila Claire and coming from Belgium here for the third time at NDC Working as a mobile architect at a company called ordina where we focus where I focus basically on the Xamarin projects
For quite some time already If you have any questions on Xamarin development, please feel free to contact me via Twitter or via email and Also, I'm proud to say that I'm a Pluralsight author have been so for Three and a half years, I think actually This session is is a one-hour session, of course, but I'm creating a four-hour
Pluralsight course on building a fully working a more extensive Application in Xamarin Android as well. The one on Xamarin iOS is online It's basically also a copy of the Xamarin Android application. So it's the same application which get built
I have one on WPF and I have a couple of on HTML 5 So if you have any interest Pick up a free card for a one free one free month at the boot of Pluralsight and You can take a look at this course in some more detail. All right So what are we going to be doing? Very briefly. I'm going to show you
The Xamarin story. What is Xamarin? What is Xamarin Android exactly? How does the do how does Xamarin Android fit in Xamarin and and and how do they relate and then we're gonna dive into building So the first thing that we're going to be looking at because I'm going to explain The Android concepts because you have to know that the Android fundamentals to actually know about Xamarin Android
So I'm going to explain those and while it was doing that we're gonna build a detail screen a detail screen It has a couple of views on there And we're gonna see how that relates to the activities and the fundamental things that we have to learn in Xamarin Android Once we've done that we're going to take a look at how we can create Lists and how we can actually create a list screen and from there navigate to the detail screen that we have already created in the first
part If possible, but I don't think we can do that in an hour. That's normally 75 minute session We can also look at fragments, but let's not go too deep in that We're gonna take a look at how we can optimize the application. How can we do translations in the app?
How can we add really the correct icons and stuff like that? And then we can we're basically ready to prepare the application and to publish it in the store So that's what we have for the next 60 minutes so by the time you walk out of this room, you will have understanding of the basics the fundamentals of Android development and therefore also Xamarin Android because it's basically wrapping wrapping around it and you will see how a fully working
Application can be built using my favorite tool at this point Xamarin Android now before we take a look at how we can build things and how Xamarin actually works Let me show you what we will be creating. So the scenario for this particular talk is called the Android coffee store manager
It's a basic master detail application with on the first screen a list and when we click on an item We will see the details of the coffee that we have selected in the first one. So let me quickly jump to My demo environment and let's make this a little bit bigger some reason it's kind of small now, so this is
The the overview screen so the list screen and when I click on one of the items here I will be navigating to the detail screen on which we have a text edit and edit text control here And we can scroll up and down. So there's some scrolling in there. There's a
Data and so on so forth and when we click on the Save button, we're navigating back to that first screen So that's the scenario that we'll be looking at. So it's a very simple master detail screen But if you think of it many applications don't really need that much more than what this application will be adding. So
Let's take a look at how we can actually get this to work. So Most of the time when I do Xamarin up Talks and Xamarin Android talks many people have heard of Xamarin
So let me briefly give you an overview of what Xamarin is what Xamarin Android is how to relate and then we can look At the code to build this application. So Xamarin in itself is Enabling us to build cross-platform applications. Now the cross-platform paradigm is nothing new It has been around for quite a few years already and other technologies have have emerged to do cross-platform
Mostly are actually focusing on the web stack that you built your application in JavaScript HTML CSS you put that in a web view you wrap it as an application and boom you put it in the store That is not what Xamarin will actually build for us. Xamarin will actually compile into native applications
It is not a cross compile and I'll show you in a couple of slides how actually Xamarin is compiling your application But what Xamarin will output is both Xamarin Android and Xamarin iOS is a native a fully native application That has a couple of consequences The first one is we have the ability to use the native user interface elements
When we're building an app and we put a button on the screen We're actually putting a UI button in iOS and Android button in in Android on that screen. It's not an emulated button It's not a fake a web button. It's a real button. We also get native performance We're building a native app. It's as performant as an iOS Objective C or a Java Android application
Independent tests many bloggers have done some tests on the performance and sometimes it's even faster than the native compiling So it's actually really performant these amaran applications that we're getting now Just saying that we're gonna ride our applications in a cross-platform way would not be a selling point
For us, of course as the net developers. We we actually extend to reach of our knowledge we can actually write everything from top to bottom in C sharp and The one of the main benefits is the fact that we can share code across platforms Normally when you build a native application for iOS you build it from top to bottom in Objective C in Java
When you build the Android application and in C sharp when you build a Windows Phone application now Which by using Xamarin we can actually reuse a lot of that code because if you think of it Accessing a service in Android and accessing a service in iOS is basically the same thing But you have to write it twice if you want to target the two platforms and the same goes for the data layer and so
On and so forth. So many many times Sharing code between the different platforms will save you a lot of time and I'm coming back to that and our application as well Will be built with that in mind now when you download Xamarin, it's actually when you have Visual Studio on your PC
It's actually just a tool set on top of Visual Studio It installs itself in Visual Studio If you don't have Visual Studio or you're using a Mac It will actually allow it will actually come with its own IDE and that's called Xamarin studio I'll be using Xamarin studio. But what I'm doing here in Xamarin studio You can do it exactly in the exact same way in Visual Studio. It's a commercial product
There's a license involved a license of if you use the the full edition is about 2,000 euros per year That's I think around 1,500 pounds per year But there is also a free edition if you if you install the trial let it expire It will keep on working in the so-called starter edition and you can actually publish apps in the store with that free starter edition
There's a couple of limitations, but I'm not going to go there. You can find it on the website So basically what we are doing with Xamarin is we are extending the reach of our C sharp and net knowledge Not we are no longer limited to just using or building apps for Windows We can also build now apps for Android for an iPhone and iPad
iOS in in general even of course Windows Phone and Windows Windows desktop as well that remains the same Xamarin is not really covering that and even Xamarin on the max You can also target that platform Basically meaning that using Xamarin you can target billions and billions of devices using your C sharp knowledge now Xamarin itself
Comes basically with three major Platforms three major frameworks that say Xamarin Android That's the goal of this talk Xamarin iOS is the second one and Xamarin forms at the other talk Xamarin forms is Completely different thing allowing you to build even the UI also cross-platform not gonna go there
We're gonna focus on the real Xamarin So the traditional the classic Xamarin and that's Xamarin Android that we are going to be looking at now Where can we run those Xamarin applications or Xamarin Android applications? Everywhere everywhere where Android is running you can also target that with Xamarin Android
So that means that if you have a watch a Samsung gear a Motorola 360 Whatever device that comes out with Android or whatever watch that comes out You can talk it you can build apps with that using Xamarin if you have a Google Glass lying around somewhere No one is using them still so you can install you can actually write Xamarin Android applications for that a Kindle fire a Kindle phone
It's running Android so you can actually build or you can target it with Xamarin Android So basically everything that Android or where Android is running You can actually build a Xamarin Android applications for it Now, what are we going to be doing gonna be writing C sharp top to bottom. We're gonna be using dotnet
So basically that means that the system namespace a system XML System IO system link all the system namespaces that we know from dotnet are going to be included in the Xamarin framework So we don't have to learn a completely new framework or we have to do don't have to learn objective C or Java to write
Android applications. No, just continue using C sharp, but if you think of it Well, just using dotnet and just using C sharp We probably are not going to be able to all of a sudden target an Android platform That's exactly what Xamarin is actually coming in Xamarin will basically fill that gap and that's this part here You can think of of Xamarin as being like a wrapper a wrapping layer around all the Android
Apis the native Android APIs and that's how we can target them using C sharp We don't have to write anything else. We can act we can talk with sensors We can write code that works with an action bar And the actual bar is the tabs that you have for example in the Google Play Store
We can use the NFC sensors the text-to-speech API's all API's that are natively accessible or Available let's say in Android aren't available from Xamarin Android as well. There's no compromise It's not going to happen that that the designer or the architect has created the application out a layout for for yours
For an Android application and you're gonna say well We're gonna build it with Xamarin Android and you look at it and you say hmm That's not gonna work and that design is not going to be one-on-one the same No, not gonna happen because we are actually still using the native SDK native API's but from a C sharp perspective We're actually talking with them using C shop
now Xamarin itself, how does it work because it may be a bit of a of a Head explosion that all of a sudden you can now target Xamarin Sorry Android with C sharp. Why have we not been doing that for so many years then? Well, actually it works because of a couple of things
I Just said that in the previous slide here. We are actually going to work with system namespaces and we are Actually working with the dotnet framework, but we're working not with the real dotnet framework We're working with the mona framework at the open source version of dotnet Which has been around for so many years already
It has been around almost as long as plain dotnet So the mona framework is an implementation that was actually written by the same people behind Xamarin So it's not something new. It was already written in 2001 and has been maintained all of all that time so basically what happens is your application that we are going to be building in Xamarin Android is
Communicating with the full version or the part of that version of the mona framework And that mona framework as source will be compiled into that application Giving you the ability to talk with system namespaces and so on and so forth It's going to be packaged inside of your APK because Xamarin Android application is also going to become an APK an Android
application package and then that Android application package is installed on the device here and it actually like your dotnet application on your Windows PC Installs like a runtime like it's called a mona virtual machine
It's like a runtime and it will do just-in-time compilation of your code towards bytecode It's basically IL that is compiled. It will compile itself into bytecode when the application is running That's it. That's basically how it works Why did not why did no one think of it so many years ago and so of course your mona virtual machine
So your run time your Android run time Xamarin Android run time will come I will communicate With with the virtual machines that come by default with Android and this gives us the ability to do basically Everything that we want or that we can do on an Android device Now like I said one of the other benefits apart from the fact that we're writing native applications is the fact that
We can share code between different Platforms and that's also a big plus because when you when you as a company start building a mobile Application you build the iOS application and then you say well now we have to bring in an iOS team So they will build that application and to end boom. It's done now it goes in maintenance and then they say well
Let's now build the Android application Building a job bring in a Java team. They will build it and those teams. They cannot communicate the developers They cannot communicate. But anyway, so they cannot exchange any code Now with Xamarin, we're basically not having that problem because you can now write once all the code
That is basically not the UI code So the data access that the the surface access the model classes every all the things that that are somehow Shareable write them once and give them to the different product teams or the different project teams Let's say and they can actually write the applications on top of it
All that code is C sharp all that code can be written once and shared across projects in general We see for the project that we've been doing Depending on the project an average code reuse of around 50 to 60 percent Xamarin themselves say quite high They sometimes say even 80 percent That's marketing talk in my opinion
Normally, we end up around 50 to 60 percent depending on how much business code there is But in general that's of course still a big plus a big advantage if you can reuse that much code Instead of having to write everything two or three times now, how can we do that? Well You can do that using something called a shared project if you've ever done any Windows 8 development
Well that this is the Windows 8 Universal application talk That's not something that I recommend using because it it gives quite a lot of clutter in your code the recommended way of writing Shared code is in my opinion the so-called PCLs or portable class libraries Basically a portable class library
It's just a class library which can be referenced from different project types and I'll be using that in the application as well So the architecture that you end up with is something like this. You will have a lot of shared code Like I said, this is that 50% or so of your code base in there You will have your data layer. For example a SQLite maybe file access those kind of things you can write at once
It's all the same Data access layer communicating with a data service access layer Communicating with a rest service in dotnet. There's a couple of options to do that. Well do it once and then like your Your mobile apps on top of that the business layer the model objects
So your model classes write them once put them in that shared block here And then on top of that you will have your different mobile applications The iOS app the Android app and the windows for now, we of course gonna focus on this thing here so what we're really writing here is the actual way of Writing a UI in Android XML will show that in just a second and we'll have some code here
Normally that would have been Java code, but in Xamarin Android that is C sharp code as well. Okay So what do you need and then we'll really start building that application I'll quickly show you what you actually need to get started with Xamarin Android now getting started Xamarin Android
You can just take out your PC install it and you're good to go. You really don't need a lot to get started Like I said, it's a commercial product Xamarin. So you will need a license, but you can install the trial and actually go from there You can use a PC. You can do everything that I'm doing here on the Mac. You can do everything on the PC as well
Install visual install Visual Studio and install Xamarin Xamarin will plug itself into Visual Studio Or you can also use Xamarin studio the ID that comes with It will also take care of everything that you need in terms of Android SDKs because there's quite a lot of things that you have To install on your PC including Java your PC is basically now
Open for the rest of the world. But anyway You will have to install the it will install that say the Android SDK it will install emulators They're not so good. It says here emulators twice. There's a reason for that in just a second I'm going to explain you why and I also of course for all mobile development
Do get a cheap device a hundred-year device is actually the best thing to test an Android application on Because they're slow and if an application runs on a slow device It will also run on a good device on a high-end device. So install it next next finish It will do everything for you Like I said, it will also install the Google SDK and it will all of the Android SDK and it will also install
Emulators now those emulators are good for one thing in my opinion That's drinking coffee because you click on something you can go get a cup of coffee And by the time you're back, it will actually have reacted to your click. They're so slow. Don't use them So they installed let them do what they want Instead use another emulator
My personal favorite on the Mac platform is Genymotion. There's a free version of it of Genymotion that you can use If you're on a Windows PC and and when I work on my Windows machine I use the Android emulator from Microsoft, which is a hyper V image very good very fast also from Visual Studio
You can download it separately. So you can actually use it from Visual Studio 2013 or 2015 There is an Android player from Xamarin as well That that as well as Genymotion use VirtualBox under the under the covers So if you're on Windows hyper V's, that's why I like hyper V on on Windows
So on the Mac, I recommend Genymotion There is going to be an Android player for Xamarin from Xamarin for the Mac as well, but that's not released yet All right, so that should give you an overview of what you need what it is. Basically, let's now get started by building this thing so We're gonna start building that detail screen now that detail screen before we get there
I have to explain you a couple of fundamentals because I don't think anyone here in the room is really an Android developer and Developing an Android is well kind of a bit of different There's some some concepts are completely different from what we know what we know in in Windows So that's why I have divided the talk in a couple of
Fundamental aspects that you need and then we're gonna apply them in the demo. So we start from finding a project and A couple of years back when I would have seen this screenshot I would have thought hell has frozen over because there's Android in Visual Studio and there's iOS in Visual Studio But no, that's because of the fact that I've installed Xamarin
So there we have iOS and some there or somewhere over there here We have Android and when you click on Android a couple of project templates will appear The first one is the one that you should be taking the blank app. Now, why am I emphasizing that? Well when you use this template The Visual Studio or Xamarin in general will take a look at the highest
Installed version of the Android SDK. So whenever a new version of Android is released Android 5 Android 6 There's a new version of the API released and intermediate releases are quite common as well. For example so when you when you click on that blank app, it will look at the highest version of the
SDK that is installed on your machine and in Android terms, this is called API levels So we're currently at API level 24. That's Android 6 It will automatically reference basically or will register your application so it can run on Android 6 Click on that file in your project and you will get something like this now if you look at this
Well, this is a solution explorer with some files in there automatically created for us And we're gonna have to take a look at some of these files because there's quite a few things that are a bit different than In the Windows world do keep in mind a couple of things. There's a folder called resources There's a folder called drawable
There's a very important folder here called layout inside of resources By the way with a file in there called main XML as a folder values with a file strings at XML That's an about file. This file is going to be a very important file Resource dot designer dot CS and then we have a file here called main activity
Keep those things in mind I'm going to explain how the different pieces of the puzzle fit together and let's start with that with the one at the bottom That main activity now activities in Android are probably the most basic building Look that you have an activity is more or less a screen the functionality of a screen and
Well, I say that it's not a hundred percent true but in general for now you can understand it that way Let's say it's the code behind. I shouldn't be saying that but it's the code behind for a screen Yeah, when you look at the Android documentation you will see that an activity is is
Described as being all the code to have I think it's all the functionality for us for a specific task Now most of the time the task is probably one screen and so an activity let's say is the functionality for one screen Now, how should you imagine Android it is not and this is completely different from Windows world
It is not like a bunch of Apple or one application Which is starting up an Android application is really a collection of activities you can imagine Android as being a sea with all kinds of islands in there and Disconnected islands and they don't have bridges between them and those little islands are activities
Each of those islands have a particular task and I'll come back to that analogy later on so The activities are basically the building blocks and that's also a very important one because the second line here says apps Don't have an entry point The activities are the building blocks, but apps don't have an entry point. How do you normally start an application?
Mean I'll go and look in an Android application. There's not gonna be a main in there There's one activity That you will mark as being the start up activity and if you change it to another activity while that screen will then start you can actually Mark more than one activity to start and it will actually launch them on top of each other kind of weird, but it's possible
So basically whenever the code for one activity is executed Then the entire application is loaded into memory and that application becomes under running application I think I said most of the things that don't want this slide already art So Activities classes are the are your most important building block now an activity in code is basically just a class
That inherits from the base activity a class that comes from Android has been wrapped by Xamarin Android and that's why we can here reference the C sharp activity Now just by making it a class that inherits from activity doesn't really make it an activity yet for Android
We have to add this attribute here activity because of the fact that that attribute is there at compile time Xamarin will take a look at all the classes with this attribute and take them and put them in the manifest file Android when the application is running when the application is running on the device. We'll look at all the activities in your application
There's a couple of parameters on here. The label is this thing here The main launcher parameter Equal to true is an indicator to say to Android when the application is running when user taps the icon This is the activity that should be launched main launches too
so by default you will have only one of those in your application and then we have the icon that is this thing here and Well that has kind of a weird syntax Doesn't it add drawable slash icon will come to that syntax in just a second bear with me for a second So that's the activity now an activity is like I said the building block of Android
Android applications are built up out of a number of activities and they are very important to Android now That's also why the lifecycle of an activity is all sorry of an application is basically It's directly related let's say to the activity
Lifecycle as well now if you look at the activity lifecycle I couldn't fit it on one slide to make it readable. This is the activity lifecycle an activity itself Can be in a number of states if it's under if it's viewable then it's probably the running app the running activity
But before it's actually running a number of events will be fired And when another activity comes in front of it another screen comes in front of it That activity will basically be put to sleep and it can be in the past state It can be in a stopped state. It can be destroyed and so on and so forth I'm not gonna go too much in this lifecycle because there's quite a few things that you have to learn to get that lifecycle to
Work in most cases most of your code will go in the so-called on create method Do do keep in mind that when yet when the activity changes state when when it's visible when it's not visible anymore Events will fire in your code that will actually say well, we're feasible. We're not visible anymore. We have to do stuff
Well, one of the most important ones that will always fire is the on create the on create is running is firing When your activity is going to be created, let's skip the other ones for now We are going to write our code in that thing here on create
So they have the activity and we have an override of the on create Now let's focus our attention on the next line here set content view Set content view. So basically the activity is just a functionality for a screen We don't have any UI code yet Well that UI code is going to be linked. Let's say with this activity using this line
Set content view which is going to be the view for this activity and I'm passing it something resource dot layout dot main If you think back of this folder structure that was created in my application in my solution Explorer
Had the resources folder a layout folder and a file called main dot XML That's probably something to do with this Well, I'm gonna show you the glue between the two before I'm doing that Let's quickly take a look at the views thing here The views indeed are files the physical files
Which are located in a folder resources layout and they have an extension AXML in Android native Android XML files here. They're called a XML Android XML They're one-on-one the same with native Android if you have an existing Android application Take those XML files and you can actually drop them in a summer in Android application. They're one-on-one the same
There's nothing different. That is why I said in the beginning. We're using native user interface cards So this is what you what you get in Visual Studio or in Xamarin studio when you open one of those XML files and When you click on source down here, it will actually show you this and let's zoom in on that a bit
XML code plain XML code. It's very act very readable If you use if you if you have ever used XAML well, this is pretty easy to understand It's a declarative way or HTML. It's a declarative way of building up your UI at the very top We have a linear layout Android the applications run on all kinds of devices
So laying out everything correctly on all these devices is sometimes quite a bit of a difficult job to get right And that's why Android comes with layout managers that manage how its children will be laid out on the screen and one of the simplest ones is the linear layout and
Like name gives away it will lay out its children in a linear way in this case vertically So it will actually position all its children below each other One are a couple of these very simple controls in the view. Well, we have the text you that's your label We have the edit text. That's your text box basically and we have a button and that's the one that you have here
Nothing very difficult. Now when you look at the code, it's still quite readable. There's one thing that should get your attention The ID the ID has been specified here at plus ID slash text view one at plus ID edit text one And so on and so on. There's quite a bit weird syntax quite of a weird way of of
writing those IDs now how is actually What's this all about and that actually brings us also back to that resource dot layout of main that we had in just a second now Like I said to my views live in this XML file here I'm setting my view. I'm linking my view with my
Activity by setting or calling set content view resource layout main So basically what happens or what seems to be happening is that Android is looking at this directory That is resources directory and everything that is in there is going to be let's say typed So that's what it actually looks like. Well, it's more or less the same now Android
Internally works with something called resource IDs Everything and I really mean everything within that resources directory gets an ID a file like a view file gets an ID Even a control inside of that view like we had here also gets an ID and
And that ID is of type integer. So basically what happens is that when you compile your application There is a file generated for you And that file is a reflection of all the resources in the resources folder That you can access from code basically
So this ID class is generated for you And like I said Android works with IDs for all your resources It will actually generate those IDs, but when I talk to you and I say well, we need control two one zero five three five seven Oh, you're gonna say excuse me, which one was it again? We don't want to work with that
So we actually need some way to link those resource IDs with Values that we understand with strings and that is what Xamarin is doing for us in a class Per resource that is going to be generated inside of your resources folder I'm going to show you that in just a second from code and once you have that you can actually link the view and the and the code and you can actually
Sorry the view and the activity and you can actually access your controls from code By now saying resource dot ID dot my button Calling the so-called fine to you by ID method. It's a generic method
So you have to pass the type you can actually in your activity access the views from your view file Quite a different way of working than what we have in Windows where we simply access those things automatically Now one one slide before we go to the go to the demo Like I said Activities have that activity attribute on top of it now all these
All these attributes everything that is inside of your application is going to be described in one file And that is the manifest file. So everything that your application contains views resources Activities are all wrapped. They're all described. Let's say in one file and that is the application manifest file
Alright, let's take a look at how we can actually now see that running inside of Xamarin studio So let's go to the first Version of this demo There we go, so
If we run this now and I am going to clean it because the applications all have the same name and sometimes it doesn't really Clean and uninstall it correctly when I just compile so I am cleaning application between runs and
If we run this we should now actually see appear in just a second the detail screen of the application Already, and then we're going to see how things fit together to get to that detail screen Sometimes takes a couple of seconds to get there. There we go. So there we have the detail screen How did we get that screen and how did I get my data in there?
And I think there's also an event here that pops a little Pops up a little message box here that says okay you save this coffee So how did we get to this particular place in our code? So this is the solution first I don't I have created my application with
The fact that I'm going to probably build an iOS application in mind as well So I took out all the code that could share between platforms and I've placed that in this Android coffee store core project So, what do you typically put in there and I know this is demo so it's very simple But model classes are going to be typically in there
There's going to be a repository in there Which in this case just returns a hard-coded coffee but could perhaps go to a service could go to a database and so on and then you have your Service layer that works with the repository that typically goes in there as well
All that code is in just an external project it's of type portable class library So all that goes all that code goes in there and that is of course just now referenced with a simple reference From my Xamarin Android application now Like I said the Android application that we have here is starting with an activity main activity
You can name it whatever you want. It's not required. It's not a convention even so let's take a look at that main activity It's a class which inherits from the base activity coming from Xamarin Android when we do we'll go to definition We can see the class activity and as you can see here in the Explorer here
There's quite a few things on that activity. I don't think we have time to look at all of these So let's not do that So activity comes with quite a few things and to make it an activity at the activity attribute at the top The label is name the main launcher says this is the one that I want to start when I launch my application and the icon
Well, that's that weird syntax again as well. We'll come back to that in just a second. I call the set content view passing in Resource layout main that is actually an integer like you can see here now resource layout main is that far here Let's open it So it will open the the designer
Interface with a toolbox that will allow me to drop something in there in just a second So for example, if I want to add a button here at the green lines indicate where I can drop that button I'm gonna do that because then I will mess up my interface take a look at the source here So I can scroll in my application. So I've put at the very root a scroll view
In there I have placed a linear layout which allows me to place all my controls below each other and there we have an image View that was the image at the top text you is that that label and edit text is that editable text?
Do keep in mind that oops do keep in mind that we have those special IDs here I'm gonna come back to those in just a second now in my activity Over here. We had called set content view resource layout main when I do a go to definition I will not go to that XML file No, I will actually go to a class layout in which in which there is a constant int main and that's that resource
ID that Android has generated for me. This is the file the file that we now have open is This file here resource dot designer CS that file is every time that Android is recompiling Or that my Xamarin Android application is recompiling is being regenerated. So don't change it yourself. Of course the layout becomes a partial class
Of the main that the surrounding class the base class is the not the basis the the external class is actually class resource resource layout main and There's also a class ID being generated here ID is actually
Mapping to all those IDs here that we have created for us in the in the in the view file So we have a coffee ID label coffee ID text and so on and so on once we have those generated for us in the Activity I have I'm calling my my shared code here Get me a date get me a coffee on the data service and then I'm passing that to this method bind data
And in the bind data, for example, let's take a look at this edit text here I'm going to call find view by ID passing in the type I want to get and then I say resource ID Coffee name text and that gives me access to my edit text finally and then I can actually put some data on there
That's what I'm doing here coffee name text is coffee coffee name And that's how we have actually linked up everything together that clear for everyone alright, so let's go back to the slides and Let's continue though when we looked at the application in the beginning
We actually also wanted to have navigation from a list you Now let's first add that list you and then we'll add navigation now list views are the way of adding a list in Android Pretty simple mobile applications needs lists need lists all the time settings are lists
Music in Spotify is a list. All those things are actually most of those are actually list views now It would be pretty simple, but again, it's a bit different than what we're used to in a Windows world What do we do in Windows? We say a list view or whatever dot item source is this observable collection and do stuff with it
Display my data. Well in Android it's not the case in Android and by the way, it's more or less the same in iOS There's an intermediate class that sits between and in Android this thing is called the adapter The adapter is basically your thing that you are going to push your data to Your list view is actually connected with the adapter and asks the adapter for the correct data
Basic if you've ever done a SP net and you've done the object data source when we were all small kids That is basically an adapter. That's the same paradigm that is being used here So the list view is the visit the the visual part The adapter is the thing that loads in the data that we push the data towards
This is what the list view looks like a very basic list you you can add this thing here Which is called the thumbnail or sorry the thumb on the thumbnail and when you actually have a lot of data It's recommended that you section your data I'm not going to show you that but it's pretty simple and you section your data and you can have a little
Overlay that shows what what your section and that you're currently on While you're scrolling so which are the important classes here the list view The list activity. I'm going to show you in just a second and then that adapt There's a built-in adapter a adapter I don't think you'll often use that most of the time you'll create your own adapter
And that's what we are going to be doing here as well So let's take a look at how we can actually display some data. So this is probably the simplest Way of displaying a list in your application as you can see my activity is not inheriting from activity It's now inheriting from list activity a different type of activity that comes with the Xamarin Android
SDK there are quite a few built-in activities and this list activity Well, I think by the name you can think what it's doing is displaying a list It has a list view built in and that list view is already linked with an adaptive property So the only thing that I need to do to display data here in my own create is say well
They're adapted the built-in list adapter of this list activity. I want you to display some data So I instantiate you as being a new every adapter of strings It's just going to display string So this is going to look very plain and simple and I'm passing in some data and I'm also passing in how each individual row should be displayed and
Notice here something different. Normally you had resource layout simple to start on one or what have you now? We have Android this is a baked in resource a built-in resource that comes with Android Android itself as a framework also has a couple of resources built in and this is one of those
Now most of the time you will not be using that area adapter and you will be creating your own Adapt and I'm instead of looking at edit here. Let's take a look at it in the code now the area adapter the area adapter sorry that the Adaptive in general is a class that needs to implement an interface base adapter and for this
Adapter to actually work you need to overwrite a few things for this to work. Let's take a look So let's go to this one here this one this one yep
Let's clean it very quickly and I will run it and I will see the list appearing so run it Open Genymotion. So this is Genymotion for the people have not mentioned seen it So Genymotion is actually the emulator that I use on the Mac
Publishing its packaging actually then we're going to publish it So the the clean thing I'm really doing here because I have several applications with the same name several debris And then sometimes it doesn't always uninstall the previous one. So this is what we now have a list It's not a scrollable list because of the fact there's not enough data, but this would actually by default be a scrollable list
Let's take a look at how we got that list on the screen So maximize this here Well in this case and now have a different activity the coffee overview activity and this is an activity which inherits from that list Activity now do note that you don't always have to inherit from this activity
If you have a list just put on a list view in your XML and you're playing you're good to go as well Works in the same way, but this makes things a bit easier. This has its built-in view notice There's no set content view call here. I'm not calling set this view there. No not necessary. It has its own view
Now if we take a look at list activity Opening. Yeah, there we go So this activity inherits like a set from activity and has a list adapter built in and that is linked with this list you already So these two know each other. So the only thing that I need to do is instantiating a new adapter in that list adapter property here and
I am using a coffee adapter and a coffee adapter is probably not something that comes with Android. So I've built this myself Passing in the data by the way that I want to display could come from a service or something Go to the definition of coffee adapt, there we go. Coffee adapter is
Inherent from base adapter and for this to become an adapter Oh, let's put it differently to make this adapter work in combination with my list view. I need to override four things Get item ID returns, which item is currently in view Microphone is slipping away an indexer
Account the count needs to be known by the list you to know when it when you're scrolling How long is that thumb going to be and then the last one and that's probably the most important one is get view Get view is called and let's put a break one here and you'll see it
Get view is called per row that is appearing in the screen. So this is now called once Twice three times four times and so on so forth Yeah, so by default if you have an Android screen and it displays, let's say ten rows Can put ten rows on screen it will call these gets you ten times. This is virtualization
Right. It doesn't if you have if you throw a million lines on it It will not run this gets you a million times that will probably make your Android a device explode You don't want that So this gets view will only be called X number of times where X is the amount of rows that will be on screen
Ten or eleven maybe twelve depending on the device But when you start scrolling rows are gonna pop off at the top and new rows need to be added at the bottom so what is happening is that if Android has popped up popped off row at the top it will put it in a little graveyard and
When a new row at the bottom is needed it will actually pass that view in in that convert your parameter here That convert view is actually sometimes filled in for you and if it is then it's a row that has been already created and it's popped off at the Top of the screen or if you're scrolling down at the bottom of the screen, of course
So I check here if convert view is actually no and if that is the case Well, I need to create a new row then and I'm doing that using something called the inflate mechanism Inflate is basically think of this as you give it an XML file and it's it's inflating it to instantiate objects from it So it's inflating the row and what am I inflating?
Simplest item one. It's an Android baked in resource Once I have that I have my row now I need to bind data to that row and now you'll need to go to the Android documentation because you need to know which Text or which label or which image view is on there, which is the ID
You need to find that in Android in Android documentation And in there you can find resource dot ID dot text one is actually in the simplest item one So we actually bind it this way and we return it Yeah now this is
Using a built-in Android resource, like I said This is a built-in resource that comes with Android Android has I think in general in total It has around 15 built-in templates With very very good describing names as you can see the simple list item activated one simple list item one
Activity list item one. I they have spent so much time coming up with these names. It's it's it's astonishing So what you can actually do is use another of these built-in row templates Go to your code and you can actually
See that Instead of having simple list item one here. You can actually dive in and use one of the built-in other Android resources Now in most cases They're not going to be what you need So you will have you will actually have to create your own template and that's most of the time
Necessary because you will need to display an image there a text book there text book there and another textbook on the far, right? So if you want to do that It's actually possible a role layout is just XML. It is just plain XML again So create in your resources layout file
I saw a folder another file a layout file and XML file with the layout of your view That's done when that's done. Then you can actually this is for example simple layout I'm gonna show it in the demo and once that is done you go to your Adapter again and in your get view you will not be returning an Android resource, though
You will be returning your own resource Inflate that data bind it and you have your own row template Right and you can actually customize your rows. Let's take a look. So I'm going to another demo here
So, let's let's run this first and you'll see a difference now and now see that we actually have The layout that we had in the very beginning already. So with the image in there
Compiling I think a second installing. There we go So now we should see there we go. We have an image We have a custom row view defined for an application
Right an image and two text views text labels below each other Now, let's take a look at the code for this. How was this actually created? Well in my Resources layout folder. I have this coffee row view a XML file It doesn't visualize because I don't have any data bound to it
So it's not visible, but when we take a look at the source is actually is a linear layout within there So it's a horizontal linear layout as you can see and the orientation is set to horizontal there and on the left I have an image view This one here. Whoops this one and then I have another linear layout nested. Of course, you can nest these things vertical
Orientation with two textures in there. So this is now and my thing on the right my two textures I have my row created for me now in my adapter. I need to make a change. It's not an Android resource anymore It's not my own resource
coffee Resource dot layout of coffee row view and that will be generated and once I have that one once that's inflated I can actually start searching for my controls for my views inside of my row and that will actually In this case and then data binding the coffee name the price and the image and I have actually now used my own row
clear Good to go All right now We also now need we have now Successfully created the list view we've created The detail view now, we should actually link these two together. And how are we going to do that using something called?
Intents, we need to navigate from one screen to another now to navigate we can use or we should be using an intent Now remember that in the beginning of the talk I told you you should see Android as like as a big C and all these and and all activities are little islands
and now all of a sudden Activity one or island one needs to say something to island two activity two. How is it gonna do that? Well, it's gonna take a glass bottle put a little message in there Drop it in the sea and it picks it up because it reads the message and sees we need to navigate to that activity Okay, you're now active on screen
That's what an intent is it's a message between different activities activities are very loosely coupled model and activity sorry intense allow us to Let these two activities communicate without actually knowing each other It's not that I have to instantiate in activity one a new activity do and then open it
No, it's a very loosely coupled system Now Navigation is just one of the things that you can do with intense There's many many more things that you can do with intent. For example, if an activity says well The user has clicked on this phone number here. We need to go to the phone to the phone call application
Well, in fact the phone views or the call view is also an activity everything in Android is an activity So basically what you're then saying is well user clicked on his phone number We now need to navigate to the call activity It's also basically an intent having the intention to make a phone call every time that you say well We need to do this. We need to just do this particular actually we have the intention of doing something
It's probably that you will have to create an intent Again, there's many more cases of where you will using intents, but that's where we are going to be using it now An intent like I said is a message you will have to include or say to Android Well, we need to do this
But you also probably will have to include some data When I say to my phone make a phone call, it's not gonna know where it has to phone who it has to call There's the same thing here. We need to include the data. Who are we going to call? So for example, these are some sample code to make a phone call I want to I'm going to create a new intent and the type is action call
This is basically an explicit intent an explicit intent says to Android I want you to do this I Have to pass some data the phone number in a particular in a particular syntax that I have to use and then I say start activity passing in my intent and
Android will see this so it needs to make a phone call Let's go to the phone call activity start it up and do the phone call If I want to do navigation like in my application, what are we going to do? Also going to create an intent we're going to target we're going to set the class target to which we want to navigate
The coffee detail activity is where we want to navigate and when I go from master to detail, I also have to include Why am I going what am I going to navigate to which is the ID? So that the you can actually pass quite a lot apart from objects You can also only pass simple types here in this case a key value selected coffee ID and that coffee ID
On the other on the receiving side, of course, we also have to do something In this case, I'm going to get off the intent the an integer intent of X So it gives me access to something called a bundle It's a dictionary that I can pass between activities passing the the key and I go I will get back to value
Let's take a look so Go here And then go here go here and open the solution file There we go Do a small cleanup again
Clean and then run it now will actually be where we were in the very beginning So where we can navigate from the master to the detail Let's take a look
Synchronizing. There we go. So when I now click on one of the items here, I Will be taken to the detail screen. Hopefully there we go So what now happened was the first activity through in that that intent and just picked it up Needs to go to that activity passing in that data activity
You're not active and this is the data that the first activity is called has passed to you, by the way The old activity is now still active It's not really active, but it's still there when I do this back here Then the lifecycle is actually killing this second activity. That is actually the destruction of that activity happening
So let's take a look. So in the overview activity so in the overview activity That is this one. I have created so that's a list activity and there's an overwrite that I can handle for row clicks So there's an all list item click and I first I'm going to ask which one of these coffees was
Selected which one was tapped. I'm instantiating an intent. Whoops. I'm instantiating an intent here I'm setting the class to which I want to navigate the coffee detail activity I pass in a key value coffee ID. I put it inside the coffee ID and I start the activity
On the receiving side. So in the coffee detail activity in my own create over here I have access to my intent. You cannot do that just everywhere in here I'm calling intent extras get int pass in that same key this one here
This gives me access to that ID I go to my data service load in the details and I can display my data All right So we have five minutes left. So that's just enough to skip fragments and Take a look at how we can optimize the application a little bit
Okay, there you go. So optimizing the application In most cases applications need to be translated they go in a store which is worldwide and applications need to be localized Just like we can actually do with With IDs we can also pass in a string value as a resource ID
so for example here, we have a text view and Instead of directly pasting or writing the text here that needs to be displayed I'm pointing it to another resource at plus sorry at string coffee name label and that's a value here in
another file an XML file that contains text values and that's a file called strings.xml and that strings.xml is actually translated or can be translated for every language that we want so the value strings is there by default do you want other languages well be my guest take another copy that folder
copy that folder put behind the the country code and then in there you put your translations and automatically Android will take a look at the current the current active the current active language and we'll pick up the correct language if available and the last thing that also is in that resources folder
was that drawable so remember in the beginning we had at drawable icon that was at the top of my activity well that add drawable icon is following the same thing that is happening has been happening with the resources folder in there there's a couple of folders and you can actually
point to add drawable icon basically Android will also type what is going to be inside of your resources folder and allow you to access that from code let me show you that in the last demo so let's go to the seventh
version it's one so the couple of things that I need to show you here over here we have a file strings of XML and in that strings XML I have again resource IDs resources in this case it's called coffee name label and I
have the translation it's the default translation but I have the translation next to it in my main XML in my main XML I have over here somewhere the text
it's not hard coded anymore inside of my XML code here but I am actually pointing it to an ad string coffee name label if we open the resource designer file this one you will also see here a class string which has been generated for me which also contains a mapping for all these values and
that's how it's actually looking up the languages or the translations that we want by simply copying values into values en values and our values de you can actually translate your application and the last thing I need to show you here is that drawable folder I actually should say folders as
you can see there's a couple of drawable folders in there with an extension and the extension points to the the pixel density the DPI that that icon can be used for and or it's used on many types of devices with a higher resolution lower resolution and in fact you should actually optimize your
application so that your icons your drawables are in there in different resolutions and so most of the time in a real application you'll actually have a copy of your resources in these different in these different folders automatically this is also going to be reflected in your resources folder
sorry in your resources file your resources designers yes and that is why you can simply point to it when you go to your application properties and you go to application Android application go here and in the application icon we can actually now point it to add drawable coffee bean icon which is an
icon in that drawables depending on the resolution and what will pick the correct one from the correct folder and when that always and when that is all finished well then you're basically ready to publish your application in the store and deployment of Android applications in general is typically
done of course to a store now Android is is a bit of the Wild West you basically everything works in Android you can deploy in the store the Google Play Store is of course the most famous one other stores exist the Amazon store exists but also non officials like get jar exist but like I
said Android is a bit of the Wild West you can actually give a USB drive to someone and say well my apk file is on there and you can actually sideload it you can email an Android application to someone so deployment in a corporation is very simple put it on an FTP or a file share and you can actually install it from there so with that out of the way and I hope I've
given you a good overview of what Xamarin Android is all about and what you can do with it it's actually broadening what we can do with our C sharp and net knowledge there's a learning curve definitely you have to understand you're building for a new platform Android is not a very small platform is quite a few things to learn but with the fact that you can
leverage what you already know I think you're good to go I hope you enjoyed it and enjoy the rest of the day thank you for being here it is any questions we'll take them offline because I think the next yeah