Posts

Display and Swipe-to-Delete Data in RecycleView using Cursor

Image
For this blog let assume, I already have the class to interact with sqlite database (Contract, DBHelpler, ContentProvider Classes). Now let start with showing the data using recycleview. I am going to create a todo list app so you will find alot of variables that refer to terms as task/todo list etc. in another article i will be adding its sqlite database class for reference if anyone wants to refere. but here you only find how to display and swipe the data.  Display Data in RecycleView  1. Update the UI in the MainActivity.xml file    2. Add new layout resource file with name 'todo_list_item.xml' Right click on layout folder and select 'new' then select 'layout resource file'. Type the name as 'todo_list_item' and select the root element 'Linear Layout'. and lastly click Ok. now replace the below code in the file code.      3. Create a new class 'TodoListAdapter'  Before creating a new class, i am going to cre...

Dynamically create Fragments in android with ViewPager

Image
In this article I am going to describe step by step how we can Dynamically create tabs in the android app. Steps involve in achieving the result: 1. Start with creating a new project 2. Define the Database Layer 3. Writing Fragment and Fragment Pager Adapter 4. Update main activity to work with ViewPager Part 1: Start with creating a new app project   (I am using android studio for development) Click on android studio > Start a new Android Studio Project > Specify Project Name, location and Press Next > Select your appropriate Minimum SDK and click Next  > Select Empty Activity and Press Next > Specify the Activity name (if required) and Press Finish. So now we are ready to go. Part 2: Implementing Database Layer Contract Class Our next step is creating a Database layer -  why we need Database the answer is we will be fetching the tab details from sqlite database. Create a folder 'Data' under your package folder and then create a cla...