Find online courses made by experts from around the world.
Take your courses with you and learn anywhere, anytime.
Learn and practice real-world skills and achieve your goals.
Have you ever seen a beautiful screen and wondered how it was designed or read a hundred lines of neatly formatted code and wondered how it works? This course aspires to seamlessly blend app design with android development giving you the complete picture. Learn how to design and code a fully working, professionally designed Android app from Photoshop to Playstore under 16 hours.
We build an app called BucketDrops in the series which lets you keep track of life goals. The course begins with app design instructed by Gary and covers the following:
We then dive into Android Programming using Android Studio instructed by Vivek Ramesh "Vivz" which covers the following topics
Follow along as Gary Simon and Vivek Ramesh "Vivz" walk you through the entire process of designing and coding a production-ready android app.
Who are these guys?
Gary Simon has been a professional designer for over 15 years and has dealt with over a thousand clients on a variety of design and development projects. He owns a popular design business, along with its associated youtube presence which is one of the most popular design channels with almost 100,000 subscribers.
Vivz has been a java developer for nearly a decade and is the founder of a channel called slidenerd that deals with mobile programming on YouTube with almost 100,000 subscribers
Between the two, millions upon millions of aspiring designers and coders alike have benefited from their instructions.
Who should take this course?
Anyone that's interested in designing and developing apps for android. You can be an absolute beginner and follow along. You can also be an intermediate/advanced designer or coder and still gain valuable insights.
So if you're ready to start designing and coding amazing android apps, let's get started!
Not for you? No problem.
30 day money back guarantee.
Learn on the go.
Desktop, iOS and Android.
Certificate of completion.
|Section 1: Introduction|
|Section 2: Introduction to Photoshop for UI Design|
In this lesson, we're going to overview all of the properties that are important when creating new documents and artboards within Photoshop. From the document type, width/height values, resolution, color modes, and background contents. We will also discuss artboards, which is a relatively new feature within Adobe Photoshop that allows you to create multiple canvases (called Artboards) within a single document. We will also discuss how you can work with the artboard tools and properties.
In this lesson, we will discuss how exactly layers work from a very basic understanding, to a more comprehensive understanding. You will learn how to create layers, add layer styles, blend modes, raster vs. shape layers, and more.
In this lesson, we're going to create a new document for the purposes of demonstrating how to design a very basic UI header. We'll start by creating a new document, and then creating a shape layer for holding a navigation. We'll then use the type tool to create the navigation links, and then add a hover state. Then to wrap it up, we will add a modal popup for displaying a checkmark.
In this lesson we'll discuss how to export our assets within Adobe Photoshop. We'll discuss how you can quickly select layers through "Auto-Select" by clicking within the design as opposed to manually navigating through the layers menu, and then we will discuss how you can export assets quickly and efficiently.
|Section 3: Introduction to Adobe Illustrator for Logo & Icon Design|
In this lesson, we will overview exactly how to create documents within Adobe Illustrator, along with all of the necessary properties that are important to note when creating new documents. We'll cover profiles, artboard numbers, size, units, width x height, bleed and advanced properties. We'll also discuss how we can quickly adjust the canvas size after we've created the document.
In this lesson, we will discuss all of the properties that are important when dealing with layers within Illustrator. There are several differences when it concerns layers in Photoshop vs. layers in Illustrators.
Tools and Techniques
|Section 4: BucketDrops: Designing the Logo & Icon in Illustrator|
Creating the Basic Bucket Shape
Adding the Drop Inside the Bucket
Finishing the Logo & Icon
|Section 5: BucketDrops: Designing the Mockups in Photoshop|
Beginning the Initial Add a Drop Mockup
Finishing the Add a Drop Mockup
Designing the Action Bar
Designing the Bucket Drop Rows Container
Designing the Add a Drop Overlay
Finishing up the Mockup Designs
Exporting the Assets
Organizing the Assets
|Section 6: Introduction To Coding|
|This video shows you how to setup Java JDK on the Mac. Java JDK is needed for compiling Android applications. The process to setup the JDK is highly similar on both Mac and Windows. Check if Java is already installed in the first step by running the ‘java’ command or ‘java -version’ on your terminal in the Mac or Command Prompt on Windows. If the command interpreter says it does not recognise the Java command, download it in the first step from Oracle’s official website and install the JDK by following simple steps, check if the installation was successful from the command line. At the end of this video, you’ll be able to get JDK up and running.|
|Android Studio is the core software needed for making Android applications. Eclipse was used earlier but now Google officially recommends Android Studio. Download Studio from their official site, decide which Android versions you would require and download each required version using the Android SDK manager. The Android emulator lets you run your Android apps on a virtual device that runs inside your computer. Download and setup the Android emulator to test your apps. At the end of this video, you’ll be able to run Android Studio on your computer.|
|This video shows you how to setup a simple Hello World App in Android. Start Android Studio, check if you have the latest version along with all the updates, select ‘Start a new Android Studio project’. Specify the name of the application, company domain that is used to identify all that apps that you will build in the future, project location which lets you store project files to a particular directory. Decide whether you want to target only phones or tablets, wear, TV and auto in addition to glass. Use one of the standard templates provided by Android Studio that control how many screens are created for you initially. Specify the name of your main screen or main activity along with a name for its XML layout file that simply controls what the user sees on that screen. Edit the styles.xml file to specify that we want to display our main screen without the horizontal bar at the top which is called as the app bar or action bar or Toolbar in Android. This video also shows you how to fix errors and bugs using Google and Stack Overflow. At the end of this video, you’ll be able to run a simple hello world app in Android in the standard emulator that Android Studio provides.|
|This video shows you how to run your Android app on a custom emulator by Genymotion. In the first step, download and install Virtual Box from Oracle which is free and necessary for running Genymotion. In the next step, create an account on Genymotion which is free, login with the credentials and download Genymotion. Once done, start the Genymotion app on Windows or Mac, add a new virtual device which is basically the Android device running inside your computer on which you would like to test your apps. Once you add a few devices, start Android Studio , navigate to its settings and download the Genymotion Plugin which integrates running Genymotion directly from android studio instead of launching it as a standalone application. Restart Android Studio and now you can use the virtual devices added via Genymotion to run your apps.|
|This video explains what is a version control system, especially what is Git and what is GitHub, how you can use Git to organise, maintain and track changes in code made either by a single person or a group of people working on a project together at the same time. It starts by showing you the issues you are likely to encounter without a VCS. Then it discusses the difference between a Centralised Version Control System or Client Server Version Control System and a Distributed Version Control System and discusses the issues faced in both. It introduces you to the Working Directory, Staging Area and Repository of Git and finally talks about what GitHub actually does.|
This video shows how to upload code to GitHub directly from Android Studio. We need to have Git installed for this to happen which we can easily check by opening the Terminal or Command Prompt and typing the Git command. If Git is actually installed, it will show you the version number of Git when you type ‘git —version’ in the Terminal or Command Prompt. If Git is not installed, download it for your platform, install it like any other tool. Create an account on GitHub which is free with public repositories. Open Android Studio and simply select the option ‘Share Project On GitHub’ which lets you login to GitHub from Android Studio, select all the files which you want to commit and push the files to the remote origin.
|This video explores the Settings area in Android Studio to uncover how to change fonts for the editor, the console, text color and size. How to use keyboard shortcuts in Android Studio. How to download, install and use plugins in android studio. How to use version control features such as GitHub. How to control compiler settings and cradle versions along with instant run that lets you run an app instantly by changing a line of code. How to use live templates and smart code insertions to reduce typing time. How to change the settings for third party plugins such as Genymotion which is used to run our Android emulator.|
|This video explains the units of measurements in Android. It takes a simple Image to illustrate that pixels cannot be used to specify sizes in Android has different Android devices can fit different number of pixels on screen. The idea also called screen density determines how crisp an Android screen can be. A screen with higher density takes lesser space to display the same content whereas its the opposite for screens with lower density values. Pixels, Millimetres, Inches, Points, Density Independent Pixels, Scaled Pixels are some of the units of measurement in Android. Every device having its own density, you often target a range of devices with a particular density instead of specific values. These range values are called density buckets. Finally the video illustrates the difference between sp and dp and shows why sp is to be used for font sizes.|
This video explores the project structure in Android Studio to make you understand the different parts and where to store what type of data. The drawable folders are good for storing images, the mipmap folders are good and very specific to storing launcher icons, the layout folder contains XML user interface definitions for all the screen elements, the values folder contains colour definitions, text definitions and dimension definitions which can be used to specify widths heights etc. and the styles file contains appearance descriptions of each UI control or widget should exactly look like on screen. All these values have a unique ID generated automatically for them by Android which is placed inside a file called R.java. The code files are placed inside the java folder whereas the AndroidManifest file contains a list of all android components used. The gradle build files describe the list of dependencies or libraries that our app requires to work properly.
|This video starts by talking about what is a View and a ViewGroup. A View is a rectangular area on the screen that can handle touch by the user. A ViewGroup or a Layout is a way of arranging views on the screen. The LinearLayout is a special type of ViewGroup that lets you add items either horizontally or vertically. To create a tabular structure, you can nest a LinearLayout within another one which is also demonstrated in this video.|
|This video shows you how you can size the Views inside the LinearLayout by specifying 2 special values. The match_parent value indicates that the View should take up all the available width inside the ViewGroup in which it is currently placed. The wrap_content value indicates that the View should take up only the amount of space it requires to display the content inside it or no space if the View has no content which is applicable to certain Views. Weights let you control the ratio of space taken by Views with respect to each other. In a horizontal LinearLayout, weights control how much percentage of the screen width is occupied by each View when we specify a layout weight for that View. A value of 1 for every View indicates that all Views take up equal space inside the LinearLayout. In a vertical LinearLayout, weights control how much percentage of the screen height is occupied by each View when we specify a layout weight for that View|
This video illustrates two concepts- gravity that controls where the content appears within the View, left, right, top, bottom, centre, middle or a combination of all and layout gravity that controls where the View itself appears within its ViewGroup or layout and the same options apply as gravity.
|This video shows another layout called RelativeLayout in action. This layout stacks items on top of each other by default. We can specify whether the View should stick to the left, right, top, bottom of the parent ViewGroup inside which it is contained or whether it should be centred horizontally or vertically with respect to the ViewGroup. The View can also specify a combination of the attributes and its size may be modified to respect the constraints in that case. The RelativeLayout also lets you specify placement of Views with respect to each other and provides options where a View can be placed above, below or beside another View and can start or end to imitate the other View’s bounds.|
|This video illustrates the difference between padding and margin. Padding controls the spacing between the content inside the View and the boundaries of the View. Margin controls the spacing between the View and boundaries of the ViewGroup inside which the View is placed. Padding and Margin values can be specified in either XML or code.|
|This video demonstrates the different ways to handle clicks on a button using a simple login form. The first method uses an onClick attribute in XML where you specify the name of a method from java code that should be called when the Button is Clicked. Ensure that the method exists and takes a View argument as input parameter. The second way is to have your Activity implement the OnClickListener which has a single method called onClick that tells you which View was clicked in the form of its parameter. Initialise the Button in code and don’t forget to set the OnClickListener for it.|
This video discusses how an Activity works in Android and what are the methods that an Activity class provide and how and when the Android system calls these methods. It then illustrates the recent activities running on the phone and the Activity back stack which is basically the list of screens that the person is navigating through. The currently active screen is at the top of the stack and when you press the back button, it is removed from the top and destroyed bring the last Activity the user was engaging with to the top of the stack. Finally the video introduces the methods involved in the Activity lifecycle which you need to use as a developer in your apps to handle certain situations.
|This video demonstrates how the Activity lifecycle methods are called by the Android system. When the app starts, onCreate, onStart, onResume are called which together constitute the Activity creation cycle. onCreate is called once per Activity creation and you can initialise Views and objects inside this method. When you move away from the Activity onPause and onStop are called. If you press back or rotate the screen the Activity is first destroyed which involves calling onPause, onStop, onDestroy and the Activity is created once again with the creation cycle. The onSaveInstanceState is called when the values of the relevant objects inside the activity is saved prior to destroying it. The onRestoreInstanceState is called giving the developer a chance to reload values into those objects whose state was saved in the onSaveInstanceState after the Activity was built from scratch.|
|Section 7: Bucket Drops Project Setup|
|This video shows how the bucket drops app works on the Genymotion emulator. The app has a home screen that contains a button which when clicked opens a dialog that lets you add a goal that you want to accomplish in the near future. You set the date, the goal itself and when you click add it, you are taken to the home screen which now shows the list of all items that you added. You can sort items by ascending or descending order of dates, you can also mark an item as complete by clicking on the item which opens another dialog letting you mark items. The app also runs a background service which checks your approaching deadlines and alerts you if you have unfinished goals.|
This video shows the list of topics that we plan to cover in the full series along with links on how to get the code for each video. We start with an introduction to android programming that deals with basic topics, then we cover how to setup Bucket Drops in Android Studio. We move to the part now where we code the home screen with a background image which is loaded using the Glide library. We explain the concept of Fragments and Dialogs in the next section and move to our database product Realm which is a replacement for SQLite. We then cover the Recycler View in absolute detail and move to styles and themes and implementation for swipe to delete. The next part focuses on Custom Views and Widgets in Android and how you can use them to match your UI/UX needs. We finally talk about Broadcast Receivers, Services and how to publish the app on the play store.
|This video demonstrates the basics of the various components involved in building Android apps.An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View).A Fragment represents a behaviour or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running.A Service is an application component that can perform long-running operations in the background and does not provide a user interface. Another application component can start a service and it will continue to run in the background even if the user switches to another application. A BroadcastReceiver is an Android app component that responds to system-wide broadcast announcements. An intent is an abstract description of an operation to be performed. An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities.|
|This video talks about what is context in Android. Context allows access to application-specific resources and classes, as well as calls for application-level operations such as launching activities, broadcasting and receiving intents, etc. Context in Android is an interface to global information about an application environment. There are 4 different Context objects in existence, the Activity itself, the Application Context, the Base Context and the raw Context object that the device manufacturer has implemented.|
|This video illustrates the structure of each screen in our Bucket Drops app, the UI widgets involved and the arrangement of Views on the screen|
This video shows how to setup the Bucket Drops app in Android Studio. Start Android Studio and click on Start a new Android Studio Project, You are taken to the Configure your new project screen, give the application name as Bucket Drops, specify a package name and save the code to a certain folder on your PC or Mac. Select the devices that you wish to target and select a template where we will choose Empty Activity. Give a name for the Activity that android studio must create for you and then specify the name of the layout file appropriately. And you are all set to code.
|Section 8: Coding the Main Screen|
|This video shows you how to create the empty screen which is shown to the user when there are no items to display in the bucket list. The logo of the app can be displayed with the help of Image View whereas the other widget will be a Button that says Add a Drop which the user can click and launch a Dialog letting them fill details about the drop to be added. Both the widgets are added inside a Relative Layout and the necessary logo mage is copied to the drawable folder.|
This video shows how to make a selector in Android. A selector is basically a collection of drawables where each drawable is displayed when the widget using the selector is in a particular state and as a developer you have to specify which states of the selector correspond to which drawables. When the button is pressed, it selects the first colour in our case and when the button is not pressed, it selects the second colour from the selector for our Button when we apply a selector to the text colour of our Button. Instead of using images as selector items, we can also use shapes like rectangle where we specify the solid colour and the stroke colour that must be applied at each state of the selector.
|This video illustrates the different scale types supported by widgets that are capable of displaying Images in Android. Centre displays the image centred in the view with no scaling. centerCrop scales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centres the image in the view. centerInside scales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as centre. fitCenter scales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centred inside the view. fitStart same as fitCenter but aligned to the top left of the view. fitEnd same as fitCenter but aligned to the bottom right of the view. itXY scales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio. matrix scales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.|
|This video shows how to add a Toolbar in XML to the main screen. A Toolbar is a generalisation of action bars for use within application layouts. While an action bar is traditionally part of an Activity's opaque window decor controlled by the framework, a Toolbar may be placed at any arbitrary level of nesting within a view hierarchy. An application may choose to designate a Toolbar as the action bar for an Activity using the setActionBar() method. Use the Toolbar from the support package which is capable of running on the older devices as well.|
|This video shows how to avoid Out Of Memory Errors while loading larges images inside an Image View by using a special library called Glide. Displaying Bitmaps efficiently can be done with standard Android techniques discussed in the official Android website or using third party libraries such as Picasso, Glide, Fresco and Universal Image Loader.|
|This video shows how to handle Button clicks in Android. There are 5 different ways for doing this. Use the android:onClick attribute in XML and give some method name as the value of this attribute. Define this method inside the Activity and ensure it takes a View argument. As an alternative you can let your Activity or Fragment implement the View.OnClickListener which is an interface with a single method called onClick. Set this listener on the Button by saying setOnClickListener. The other methods revolve around the different ways of doing this which would involve either implementing the Listener directly in the Activity or Fragment or using anonymous inner classes.|
|Section 9: Introduction To Fragments|
|This video talks about Fragments in Android. Fragments are like mini-activities that can be used to display chunks of the UI. On a smaller device like a phone, the Fragments may be displayed one per Activity. On a larger device like a tablet, the Fragments may be displayed right beside each other. Fragments have their own lifecycle which runs in parallel with the Activity’s lifecycle. The onAttach, onCreate, onCreateView, onActivityCreated, onStart, onResume, onPause, onStop, onDestroyView, onDetach are some of the methods in the lifecycle of a Fragment.|
|This video shows an example of Fragment lifecycle in Android by printing the different methods to Log-cat as they are called by the Android system. The example simply adds a Fragment to an Activity and tries doing several things such as starting the app, exiting from the app by minimising it, exiting from the app by pressing the back button, rotating the screen and so on. The methods onAttach, onCreate, onCreateView, onActivityCreated, onStart, onResume, onPause, onStop, onDestroyView, onDestroy, onDetach are called at different times depending on what the user is doing with the app.|
|This video illustrates the lifecycle of a Fragment in conjunction with the lifecycle of an Activity. The Log-cat shows the sequence of method calls from both the Activity and the Fragment at the same time. The Fragment methods include onCreate, onCreateView, onViewCreated, onActivityCreated, onStart, onRestart, onResume, onPause, onStop, onDestroy, onDestroyView and onDetach whereas the activity methods include onCreate, onStart, onResume, onPause, onStop and onDestroy|
This video shows how to add a Fragment to XML directly. In the first step, create an activity and its layout file. Create a class that extends the android.app.Fragment or android.support.v4.Fragment and override the onCreateView method. Define a layout for the fragment that contains all the UI widgets which you want to display inside the Fragment. Link this layout inside onCreateView using a Layout Inflater. Create the fragment tag in the XML layout of the Activity and specify the class attribute to point to the Java class file of the Fragment that you created earlier.
This video talks about FragmentManager which is an interface for interacting with Fragment objects inside of an Activity and FragmentTransaction which is an API for performing a set of Fragment operations. FragmentManager tracks a list of Fragments in the current Activity. Each Fragment can be assigned an ID or a TAG which can be used by the FragmentManager later to find it using the findFragmentById or findFragmentByTag methods. FragmentTransactions let you add, remove, replace or hide Fragments in Activities programmatically.
|In this video we show you how to add a Fragment to an activity programmatically with the help of the FragmentManager and FragmentTransaction. Create two Fragment classes and their layout in XML. Go to the Activity where you need to add the Fragments. To get an instance of the support FragmentManager call getSupportFragmentManager. We simply call beginTransaction using the object of the FragmentManager which we just retrieved. Now we add or replace Fragments by creating their objects in code and assigning an ID or TAG so that we can retrieve them later using the findFragmentById or findFragmentByTag methods.|
This video talks about a fragment that displays a dialog window, floating on top of its activity's window called a DialogFragment in Android. This fragment contains a Dialog object, which it displays as appropriate based on the fragment's state. Control of the dialog (deciding when to show, hide, dismiss it) should be done through the API here, not with direct calls on the dialog. You can implement one either using the Fragment approach in which case you use the onCreateView method or the Dialog approach in which case you use the onCreateDialog approach. Create an XML layout of the Dialog that you want to display. Create a class that extends from DialogFragment. Override the onCreateView method or the onCreateDialog method depending on your chosen approach. Construct the object of a DialogFragment inside your activity and simply call the show method to display the Dialog or dismiss method to destroy the Dialog.
|This video shows how to create the XML layout for the Dialog responsible for adding items in our Bucket Drops app. In the first step we create the layout file with a RelativeLayout as the root element, it has a TextView that displays “Add a Drop” followed by an ImageButton to let the user close the Dialog. We have an EditText below to let the person enter their drop or goal and a custom Date Picker that lets them set the Date below this followed finally by the Button that lets you add a drop. We use the Android Studio Drawable Importer plugin to add the necessary icons.|
This video shows how to add the DialogFragment in code for adding drops to our database. In the first step, we create a class that extends DialogFragment, in the next step we override the onCreateView method and link the XML layout which we created in the last video. We create an on click listener inside our Activity which will be triggered when the users tries to add a new drop. Then we create an object of our DialogFragment class and call the show method that accepts a FragmentManager or a FragmentTransaction. We filter the input entered by the user using an inputType and finally add another ClickListener inside the Dialog to dismiss it when the person tries to close the Dialog.
|Section 10: Saving Data With Realm|
|This video talks about Realm database which is a replacement for SQLite & Core Data. Realm is not an ORM on top of SQLite. Instead it uses its own persistence engine, built for simplicity (& speed). Thanks to its zero-copy design, Realm is much faster than an ORM, and is often faster than raw SQLite as well. Realm supports iOS & OS X (Objective-C & Swift) & Android. You can share Realm files across platforms, use the same high-level models for Java, Swift & Objective-C, and write similar business logic on all platforms. Realm supports advanced features like Encryption, graph queries, and easy migrations. We discuss realm data types such as boolean, short, int, long, float, double, data and so on. Extend the RealmObject add private fields and public getter and setter methods to let Realm use your object as a Table where data can be inserted or retrieved. Realm supports transactions where you can write objects to realm and then commit the transaction or rollback if something failed. Realm transactions are either synchronous which is the default behaviour or they can be asynchronous if you supply a callback to the executeTransaction method. Realm supports 1 to 1, 1 to many and many to many relationships easily with the help of the model itself. Use a RealmList to model many objects in a relationship.|
|This video talks about realm queries in Android. Get an instance of the RealmObject for your class, call the where method to specify the name of the class or table to fetch results from, the equalTo method to specify conditions on instance variables of the class, find method or its variants to get a list of objects from the realm database that satisfy the given query which returns a RealmResults object. If you use the findAsync method, the query will be executed asynchronously and our RealmResults object will need a registered RealmChangeListener which has a single method called onChange which is called when the results are loaded. To sort results, you can use allObjects and allObjectsSorted variations, to compare values you can use methods such as between, greaterThan, lessThan, greaterThanOrEqualTo and lessThanOrEqualTo, equalTo, notEqualTo method. Use the sum, min, max and average methods to work with numerical results as a collection. To remove objects, begin a transaction and simply call removeFromRealm on a single object or clear on a RealmList or RealmResults object and commit the transaction.|
|This video talks about the advanced parts of realm android. The realm database file is located by default in the data/data/files/ directory and you get an instance of the default database by saying getInstance. You can create your own Realm database file for which you need to supply a RealmConfiguration object. It controls several aspects such as whether you want to perform encryption, your database version and so on. We set the default configuration after creating it by calling Realm.setDefaultConfiguration. RealmList or RealmResults or RealmObjects cannot be passed across different threads. To get the same results across threads, query the same results again. When you are done using Realm, don’t forget to close Realm instances. To directly load JSON object into the database, use createObjectFromJson method and to load a JSON array into the database directly, use the createAllFromJson method. When realm model is edited, don’t forget to change the schema number of the database or write a custom migration which basically enables realm to maintain data in the new table’s format. Realm provides a RealmBaseAdapter that lets you integrate the database directly with ListView or GridView|
|This video shows how to insert data into android realm database. Create a model class that extends from RealmObject, define a list of instance variables that will act as columns in the table the class will act as the table itself, add a few getter and setter methods that are needed to read and update values to the Realm database. Add the dependency for Realm in build.grade file and hit sync now. Simply create a plain object of the model class, set the required values using the model setter or constructors, get an instance of realm, begin a transaction, write the values and commit the transaction. To see if the data was successfully saved, use the Realm Browser to view the database file with the help of the Android Monitor.|
|Section 11: Introduction to the Recycler View|
|The RecyclerView widget is a more advanced and flexible version of ListView. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited number of views. Use the RecyclerView widget when you have data collections whose elements change at runtime based on user action or network events. The RecyclerView class simplifies the display and handling of large data sets by providing Layout managers for positioning items and Default animations for common item operations, such as removal or addition of items. You also have the flexibility to define custom layout managers and animations for RecyclerView widgets. To use the RecyclerView widget, you have to specify an adapter and a layout manager. To create an adapter, extend the RecyclerView.Adapter class. A layout manager positions item views inside a RecyclerView and determines when to reuse item views that are no longer visible to the user. To reuse (or recycle) a view, a layout manager may ask the adapter to replace the contents of the view with a different element from the dataset. Recycling views in this manner improves performance by avoiding the creation of unnecessary views or performing expensive findViewById() lookups. RecyclerView provides LinearLayoutManager which shows items in a vertical or horizontal scrolling list, GridLayoutManager which shows items in a grid, StaggeredGridLayoutManager which shows items in a staggered grid.|
|This video shows how to add the android recycler view to our app Bucket Drops. In the first step, get the Gradle dependency for the latest version of the Recycler View and sync the file. In the next step, navigate to the Activity’s layout XML file and add the RecyclerView in XML and ensure it occupies all the screen space. All you have to do is create the RecyclerView object in the Activity’s code file and link the xml widget in code with the findViewById method.|
|The video shows you how to build each row in the RecyclerView with the help of XML layouts. We require an ImageView for the drop icon, a TextView to display the drop and another TextView to display the date. use a custom background selector to give the item a different background when it is marked as complete.|
|This video shows you how to implement RecyclerView.Adapter class. In the first step, we create a class that extends from RecyclerView.Adapter. In the second step, create a class that extends from the RecyclerView.ViewHolder that specifies the layout for a single item inside the RecyclerView. Next we implement the onCreateViewHolder, the onBindViewHolder and getItemCount methods inside the RecyclerView.Adapter subclass. We get a Java object that represents the XML layout of a single item which we created in the previous video and supply this Java View object to the subclass of the RecyclerView.ViewHolder. The idea behind using a ViewHolder is to avoid calling findViewById for each row in the RecyclerView. The onBindViewHolder lets you put data inside each row which the user eventually sees on the screen.|
|This video shows how to display data from database inside RecyclerView. In our case, we need to display data from Realm database inside our RecyclerView with the help of the RecyclerView.Adapter. The onCreateViewHolder is called initially when a row needs to be displayed for a few times and then the onBindViewHolder is called for all subsequent iterations. Create an Application subclass and override the onCreate method to define a RealmConfiguration which we set as the default configuration. In the main activity, we simply get an instance of Realm using getDefaultInstance using which we can query all the drops stored in our database asynchronously. We use a RealmChangeListener to be notified when the drops have finished loading from the database and store the results inside a RealmResults object. Finally we call notifyDataSetChanged method to refresh the RecyclerView as we add more items to it.|
|This video shows you how to fix the error grade build failed error which you may encounter if your grade version is old and you need to update it. Check the latest version of Gradle online and download that by editing the build.grade file of the entire project.|
|This video shows you how to add an empty View to the RecyclerView which is displayed when the RecyclerView has no items to display. In our app BucketDrops, we hide the Toolbar and the RecyclerView when there are no items and we show them and hide the empty view when we have atleast one item to display. We use the RecyclerView.AdapterDataObserver class that notifies us of changes in the the RecyclerView’s items with the help of its onChanged, onItemRangeChanged, onItemRangeInserted, onItemRangeMoved, onItemRangeRemoved methods which are triggered when different notifyXXX methods are used in the RecyclerView.Adapter subclass|
|This video shows how to use RecyclerView.AdapterDataObserver to be notified of changes in the RecyclerView’s items so that we can hide the RecyclerView and the Toolbar when there are no items to display. In the first step, we make a custom RecyclerView in code. In the second step, we create an anonymous class that extends AdapterDataObserver and override its methods onChanged, onItemRangeInserted, onItemRangeChanged, onItemRangeMoved and onItemRangeRemoved. Next, we override the setAdapter method of the custom RecyclerView and call registerAdapterDataObserver to register the anonymous class with our RecyclerView. In the next step we simply toggle the Views using the setVisibility method to show or hide them based on the number of items inside our RecyclerView.|
|This video shows how to fix the background image loaded using Glide which has black edges on both sides the first time items are shown. We use the Android Device Monitor to see if Glide is loading 2 separate images by navigating to the File Explorer of our running device. The fix involves making the ImageView take all the space on the screen instead of being placed below the Toolbar.|
|Section 12: Building A Sectioned Recycler View|
This video shows the theory behind a Sectioned RecyclerView in Android. In our app BucketDrops, we have all the drops or goals added by the user initially followed by the Footer containing a button that lets the user add another drop. Override the getItemViewType which accepts a position to query and returns an integer value identifying the type of the view needed to represent the item at the given position.
|This video shows you how to implement a RecyclerView with sections in Android. In the first step, override the getItemViewType method to indicate that your RecyclerView is capable of displaying 2 different types of rows by returning 2 different integer values, one when the item at the supplied position is a normal item and the other when the item at the supplied position is a Footer. Change the onCreateViewHolder to return 2 different ViewHolder objects representing the regular item and the footer respectively. Change the getItemCount and onBindViewHolder to reflect the changes.|
|This video talks about how to draw a Divider between items of a RecyclerView using the RecyclerView.ItemDecoration class. Override the getItemOffsets method that lets you specify whether you want to allocate space to draw a divider between the RecyclerView items. Override the onDraw method which lets you draw the divider below the item or you can use the onDrawOver method which lets you draw the divider above the item. Finally specify the left, top, right and bottom values to draw the divider as per your requirements.|
This video shows you how to add a divider to our RecyclerView. In the first step, we make a drawable that contains a shape representing our divider with a solid colour. In the second step, we create a class called Divider that inherits from RecyclerView.ItemDecoration. We then override the onDraw method that lets us draw a horizontal divider after detecting the orientation of the LinearLayoutManager. We override the getItemOffsets method to specify spacing between the items where the divider will be drawn. We then calculate the left, top, right and bottom values for the divider and draw it for each child in the RecyclerView.
|This video shows how to handle events from the Button contained in the footer of the RecyclerView to add items to the database. We get a reference to the Button inside the FooterHolder class and implement the onClickListener which will fire whenever the Button is pressed. We propagate this event from the Adapter to the Activity where we can display the Dialog Add that finally lets the person add the item to the database.|
|Section 13: Swipe To Delete And Mastering The Recycler View|
This video introduces you to the RecyclerView.ItemTouchHelper class that lets you detect swipe and drag. Implement the ItemTouchHelper.Callback interface and override the onMove or onSwipe method to determine the actions that need to be executed when the item is dragged from one position to another within the RecyclerView or it is swiped. An alternate approach is to use the ItemTouchHelper.SimpleCallback where you can minimally define the behaviours that you want to support inside the RecyclerView. Use the makeMovementFlags method to specify the direction of drag or swipe. Override the isLongPressDragEnabled and return true to support dragging and override the isItemViewSwipeEnabled to support swiping.
This video shows how to implement Swipe to Delete for RecyclerView using the itemTouchHelper.Callback interface. In the first step we create a class that extends from ItemTouchHelper.Callback. Override the getMovementFlags to call makeMovementFlags where we specify the dragFlags and swipeFlags. In our case, we don’t support dragging and hence return 0 and for the swipe flags we specify ItemTouchHelper.END to indicate that our RecyclerView should be capable of being swiped from left to right in most languages and right to left while the user is using Arabic or Hebrew. To disable dragging, return false from the isLongPressDragEnabled method and to enable swiping return true from the isItemViewSwipeEnabled. Finally override the onSwipe method and forward the event to the RecyclerView.Adapter where we can delete the item from the database by calling the removeFromRealm method and notifyDataSetChanged method to refresh the RecyclerView.
|In this video, we create the Dialog which lets the person mark an item as complete and is triggered when the user clicks on any of their goals. Add an ImageButton to close the Dialog. Add a Button called Mark Complete with a tick image in XML|
|This video shows how to handle a RecyclerView’s item click. Create the DialogFragment subclass that displays the layout which we created in the previous video letting the person mark an item as complete. Set an OnClickListener for each row of the RecyclerView. When any item is clicked, dispatch the event to the main screen where we write code to display the Dialog. We also pass extra information with the help of a Bundle indicating the position of the item in the RecyclerView that was clicked by the user.|
|This video shows how to update data contained in the Android Realm database. Inside our DialogFragment subclass that lets the person mark an item as complete, we use the realm instance to begin a transaction, use a setter method to update the status of an item as complete and commit the transaction. Don’t forget to call notifyDataSetChanged method that lets you refresh the RecyclerView after you mark an item as complete so that we can display a different background for completed items.|
|This video shows how to add a menu to our Activity in Android. In the first step, create a folder called menu under res in your project directory. Right click on the folder and select new menu resource file. Call it whatever you want and after creating it, you’ll notice an XML file with a root menu tag inside it. Inside the menu tag, create as many item tags as you want and each item needs to have a title which is compulsory and an icon which is optional. The showAsAction attribute controls whether we see the menu item in the top app bar or action bar of our Activity. Override the onCreateOptionsMenu in the Activity to inflate the xml menu file using a MenuInflater object which you can retrieve by calling getMenuInflater inside our Activity. Finally override the onOptionsItemSelected method to handle menu item clicks inside our Activity.|
|This video shows how to approximate date and time using the DateUtils class in Android. The DateUtils class contains various date-related utilities for creating things like elapsed time and date ranges, strings for days of the week and months, and AM/PM text etc. Use the DateUtils.getRelativeTimeSpanString method to get time approximated and displayed in a simplified format which the user can easily understand.|
|This video shows you how to sort data inside our Recycler View on the basis of ascending and descending order of a goal’s target date. It also lets you display items which are either complete or incomplete. Use the onOptionsItemSelected method to jump between the different sorting options and the findAllSortedAsync method to specify the instance variable on the basis of which the sorting should take place along with the nature of the sort, whether its ascending or descending asynchronously. To display only complete or incomplete items, query all the items from the Drops table and filter those whose completed status is true for complete items and false for incomplete items. Use a RealmChangeListener to get notified when the results are loaded asynchronously and update the Adapter accordingly.|
This video talks about what are SharedPreferences in Android and how to store key value pairs in the Android file system using SharedPreferences. Use the getPreferences method to get the default SharedPreferences file or use getSharedPreferences method to specify a file name. To save a value, get a SharedPreferences object, use the SharedPreferences.Editor interface to get an object which has putXXX methods that let you store some value and finally call commit to save the values synchronously or apply to save the values asynchronously. To read values, get a SharedPreferences object and call getXXX methods on that object specifying the key whose value you would like to read. Specify default values in case the value for a key doesn’t exist.
|This video fixes a bug where we may be taken to the empty screen if there are no items to display while our filter is set to show only complete or incomplete items. We add a third type of item inside our Adapter that comes into the picture when the sorting option shows only complete or incomplete items and the RecyclerView has no items to show under the categories. We modify the getItemViewType and getItemCount methods to reflect the conditions under with the No Items View is shown to the user.|
This video shows you how to add animations to the RecyclerView which are seen in action while adding and removing items from the RecyclerView. In the first step, override the getItemId to return a unique id for each position in the RecyclerView or return RecyclerView.NO_ID. In the next step, call the setHasStableIds on your RecyclerView.Adapter subclass and supply true to this method and the animations run automatically after this.
Once upon a time, my teacher asked me to write a program to check if the input is leap year. I went to my teacher and asked him "Sir, can you please explain why you wrote if(i%4==0)?". He told me to get lost saying "I ll never learn programming"
Are you like me whose teacher writes code and never explains why? You have finally come to the right instructor on Udemy who teaches you now just how to code but also why.
I have taught 100000+ people so far on my channel slidenerd which is rated as one of the topmost sources in the world to learn Android or IOS and other aspects of mobile development and general programming by several online blogs and forums. I have made several hundred videos on YouTube over the years and many of them are at the top of the search results on YouTube and Google.
I have real world teaching experience and a degree in IT Engineering. with more than 10 years of coding experience. I have won several coding challenges in the meantime. What do you say? we learn the how, what, why behind everything together?
Gary Simon is a professional freelance graphics and web designer with well over a decade of experience. Having served over a thousand clients, Gary understands many facets of the design industry.
He has also been a course instructor for several of the top online education websites, teaching a wide range of topics including:
Gary began designing websites in 2000, and just a few years later started focusing on identity design. From that point on, Gary grew a large clientele that allowed him to fully develop skills that extend beyond design alone.
The following is a list of web technologies in which Gary is proficient:
He is also an expert with the following software:
Gary began teaching his skills to others after releasing a single logo design tutorial, which has since garnered over a million views. In 7 years, Gary has released over 200 video tutorials and 20+ video courses. On his Youtube channel alone, his videos receive a half million views monthly. He enjoys connecting with students and helping them develop their skills on an on-going and frequent basis.