Friday, December 18, 2015

Searching in List


We have a long list of item and it is difficult to find out a particular item in the list. In such scenario searching is useful.

Today I am going to demonstrate searching the list.

1. Create a layout with ListView I created activity_main.xml

In this I use by default relativeLayout and one EditText view where we type searching element. and a listView where we show our list item.

Now I am creating layout for show list item. I am show only string so I will take single TextView.

Now i am going to create a simple class to create list of string you can manually insert list item in Arraylist to display in list



This is launcher activity which is implementing TexWatcher which is used to check change in charcter which we type in the search box i.e. edit text view.



Now we are going to create Custum adapter class which is extending BaseAdapter and implementing Filterable which give us Filter class

You can Download complete project from Github

If have any problem mention in comment.





Thursday, July 2, 2015

How to create "Indeterminate Circular Progress Bar" like "Material Design Progress Bar".

In indeterminate mode, the progress bar shows a cyclic animation without an indication of progress. This mode is used by applications when the length of the task is unknown. The indeterminate progress bar can be either a spinning wheel or a horizontal bar.

Here, I will show you how create spinning wheel progress bar.

This is what you will achieve at the end of this tutorial




What are the steps the steps to achieve this:
Step 1: Copy Java class responsible for creating circular animation i.e. "CircularProgressWheel.java"
Step 2: Copy attrs.xml file in your values folder i.e. res/values/attrs.xml 
Step 3: Use "CircularProgressWheel.java" with fully qualified package name in your xml layout.

That's all you have to do to achieve this:


STEP 1:
You can get the code of "CircularProgressWheel.java" class by Clicking Here

STEP 2:
You can get the code of "attrs.xml" by Clicking Here.

STEP 3:
How to use CircularProgressWheel Class to get it into the action.
Just define in the layout xml files where you want to use it.


For Example:  res/layout/splashscreen.xml

 <LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:wheel="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/fragmentContainer"
    android:gravity="center"
    android:background="#ffe4fcff">
<TextView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:textSize="18sp"
     android:textColor="#5588FF"
     android:text="Loading Please Wait..."/>
 <packageName.CircularProgressWheel
     android:id="@+id/progress_wheel"
     android:layout_width="75dp" 
     android:layout_height="75dp"
     wheel:matProg_barColor="#4CAF50"
     android:layout_marginTop="20dp"
     wheel:matProg_progressIndeterminate="true" />
 </LinearLayout>


Note: You need to replace "packageName"  with your app's "PackageName".


That's All you need to do.