Posts

Showing posts from December, 2018

Swipe to delete RecyclerView Item

Image
"Swipe To Delete RecyclerView"    In previous blog we have studied how to implement RecyclerView in android. Now we are going to studying about touch events in RecyclerView. In this blog I'm going to write about how to delete row from RecyclerView by swipe from left to right or vice versa. For implementing touch event in RecyclerView we need to attach ItemTouchHelper. See the following code snippet. First create removeItem() method as shown in following code and paste it in "RecyclerAdapter.java" class, created in previous example. public void removeItem(int position){ listItems.remove(position); imageArray.remove(position); notifyItemRemoved(position); notifyDataSetChanged(); } Now copy and paste the code after setting adapter to recyclerview as shown in previous demo of RecyclerView. //TODO : Create and set adapter to RecyclerView final RecyclerAdapter recyclerAdapter = new Re...

RecyclerView Android

Image
"RecyclerView"      In previous two blogs we have studied about how to create ListView with array adapter and Custom Adapter using BaseAdapter class. In this blog we are going to study about what is RecyclerView and how to implement it in android. Before studying about it lets understand what is main difference between ListView and RecyclerView. RecyclerView is flexible version of ListView , If you want to show large data set in list or data that frequently change you should use RecyclerView. The views in RecyclerView are represented by View Holder objects. Each view holder represents a single view. RecyclerView creates view holder as are needed to display the on screen portion of the dynamic content.  In RecyclerView the creating view and binding values with UI components are separating in thwo methods called : onCreateViewholder() and onBindViewHolder(). In other hand the ListView does not separating it, rather it create view and bind values ...

CustomListView

      "Custom ListView"          Hello friends, In previous blog we are studied about ListView with ArrayAdapter. Now in this block weare going to study about custom ListView using BaseAdapter.      In previous blog we have created one Simple ListView that contains only text. The custom ListView means creating custom layout of list items. In this tutorial we are going to adding image, text and button in one list row.      Before implementing custom ListView lets know about BaseAdapter. In Android, an Adapter is a bridhe between UI component and data source (Like, ArrayList, Array etc) that help us to fill data in UI components.     To customize ListView we can create own Adapter class with own layout file by extending BaseAdapter class. BaseAdapter can be used for implementing custom ListView, GridView , Spinner etc.     The following code snippet shows the overrid methods of Bas...

ListView In Android

"ListView" Hi friends, Today we are going to learn what is listView and how to implement in android? ListView is group of items and all items are display in vertical scrollable view. The list items are inserted in listview by using adapter. Here using ArrayAdapter and We will learn Base adapter in next tutorial. Lets start to implement listview with array adapter in android. Create one layout file that contains following code. Here the name of file is "activity_main.xml" In above file we have added ListView and set an id "list_demo". Now create one java file and paste the following code. Here the name of file is "MainActivity.java" package com.beauty.listviewdemo; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.ListView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { //Create ListView...