Android – Unit tests

Android unit tests with JUnit, <span>Android – Unit tests</span>, KandZ

Android Studio uses JUnit 4 to run unit tests. JUnit 4 is the most popular for Java. Units tests, tests only the java parts of your application without the use of Android Device/Emulator. Tests are grouped in a class and each unit test is a separate method what it is marked with @Test annotation. You can run a single unit test, or all the tests in a class. You can also debug them. Every unit test should use the static methods of the Assert class, to evaluate the result. Environment…

Android – Unit tests Read More

Android – ListView with ArrayAdapter

Android unit tests with JUnit, <span>Android – Unit tests</span>, KandZ

ListView displays a collection of views. Each view is placed immediately below the previous view. First, you need a list view in your layout XML file. Next you need an ArrayAdapter and a list with items. Here is how you can handle the clicks on the list view I used a default layout that is coming with Android SDK, android.R.layout.simple.list_item_1. You can create your own layout. Here is an example: listItem.xml Now you can replace android.R.layout.simple.list_item_1 with R.layout.listItem Android – ListView with ArrayAdapter

Android – ListView with ArrayAdapter Read More

Android – Implement Parcelable to pass an object via Bundle

Android unit tests with JUnit, <span>Android – Unit tests</span>, KandZ

If you want to pass an object via Bundle you have to serialize it or to implement the Parcelable interface (it is an Android Implementation for Java serializable). It is recommended the second option because it is faster than the first one. Steps to implement Parcable: … implements Parcelable 2. Implement the two methods, describeContents() and writeToParcel() If you write an other parcelable you should do it this way: 3. All the classes implementing the Parcelable interface must also have a static field called CREATOR that implements the Parcelable.Creator interface.…

Android – Implement Parcelable to pass an object via Bundle Read More