Search View App Source Code

                                                    Android Tutorials Point 

               The Best Android Apps Source Codes 


Welcome Dear Viewers,

The best Android Apps Source Code is available at one place. So to make Search View App just copy these codes into your App and Run any time. Literally I have explained each steps in this Tutorial.

This is Only page setup coding & next parts will be publish soon here too.  

I will show you their XML code and Java code for more clarification. So Lets start our Source Code.

To make search view app just follow these steps.




                                            Demo



Screen Shot:







Main Activity (XML File)



<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".MainActivity">



    <SearchView

        android:id="@+id/searchView"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content">


    </SearchView>


    <ListView

        android:id="@+id/listView"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"


        ></ListView>

</RelativeLayout>






...................................................................................................................................




Main Activity (Java File)



import androidx.appcompat.app.AppCompatActivity;


import android.os.Bundle;

import android.widget.ArrayAdapter;

import android.widget.ListView;

import android.widget.SearchView;


import java.util.ArrayList;


public class MainActivity extends AppCompatActivity {

    SearchView searchView;

    ListView listView;

    ArrayList<String> List1;

    ArrayAdapter adapter;



    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        searchView = findViewById(R.id.searchView);

        listView = findViewById(R.id.listView);


        List1 = new ArrayList<>();

        List1.add("Monday");

        List1.add("Tuesday");

        List1.add("Wednesday");

        List1.add("Thursday");

        List1.add("Friday");

        List1.add("Saturday");

        List1.add("Sunday");


        adapter=new ArrayAdapter(this, android.R.layout.simple_list_item_1);

        listView.setAdapter(adapter);

        searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

            @Override

            public boolean onQueryTextSubmit(String query) {

                return false;

            }


            @Override

            public boolean onQueryTextChange(String newText) {

                adapter.getFilter().filter(newText);

                return false;

            }

        });



    }

}


 


........................................................................................................................





All the Best 😇 

Best Regards

Android Tutorials Point 


To understand the tutorial step by step you have to be watch video from here.

Search View App YouTube Link

https://www.youtube.com/watch?v=1Jt2441J0OY&t=4s







Comments

Popular posts from this blog

E-Commerce App Source Code (Part - 5)

Todo App Source Code

E-Commerce App Source Code (Part - 2)