Javascript – Create, move and remove HTML elements

Javascript – Create, move and remove HTML elements

Create an HTML element To create an HTML element, first you must use createElement(). Then set any values and the style. The last step is to add the created element in the DOM using append(), appendChild(), insertBefore() or innerHTML property. Move an HTML element If you want to move an HTML element you should use append() and appendChild(). This can only happen if you get the element somewhere else in the document. Remove an HTML element You can remove an HTML element using the removeChild(element) method or the innerHTML property…

Javascript – Create, move and remove HTML elements Read More

Content Provider – Part 2 – create and query

Content Provider – Part 2 – create and query

You can read part 1 here. To create a Content Provider you need to: extend the ContentProvider class implement the lifecycle methods implement the data lookup methods implement the modification methods create a Content Provider identification specify Content Provider’s visibility to other apps Content Provider is responsible to connect to the database and perform all the database interactions. The methods are similar to the SQLite API. Add a Content Provider to your app Right-click the package name, then click New, Other and then Content Provider. You will see the following…

Content Provider – Part 2 – create and query Read More

Android – Create a DB contract class

Android – Create a DB contract class

A Database contract class is a class that holds information about the database, schema/structure. It also has constants that describes the database, tables, columns and table creation strings. One more thing to remember is that we do not need instantiate it, because it holds only information. Let’s start. Create a new Java class file. The class must be final. The constructor should be private and empty. Now create a public, static and final class for each table in the database that implements Basecolums if you want to use an ID…

Android – Create a DB contract class Read More

Android Studio – Create and run a Virtual Device

Android Studio – Create and run a Virtual Device

It is important to have a Virtual Device, maybe more than one. You can run your app without the need for a physical device and you can also test your app in different specifications (screen size/resolution, API etc) Click Tools and then AVD Manager. You will see the following windows: Click Create Virtual Device. Select the category, then a device definition. I chose Nexus 5x. Click Next Click Other Images and select or Download the system image for your device. It is better to choose an armeabi-v7a and with Google…

Android Studio – Create and run a Virtual Device Read More

Android Studio – Create a project, source code and resource files

Android Studio – Create a project, source code and resource files

Start Android Studio. You will see the following. Click Start a new Android Studio project Choose what kind of project will be, the target platform Now choose what kind of activity you want to create with the project. Click Next. Now specify the Name,package name, save location, language and Minimum API level. Click Finish. Create a source code file. Right-click the package, click New and then click Java Class Specify the name and any other fields you need. Click OK Create a resource file. Right-click res, click New and then…

Android Studio – Create a project, source code and resource files Read More