Search Dialog Library

Additional

Language
Kotlin
Version
v1.3 (Jan 1, 2020)
Created
Nov 7, 2017
Updated
Jan 1, 2020
Owner
Ajith v Giri (ajithvgiri)
Contributors
Ajith v Giri (ajithvgiri)
FANMixco
2
Activity
Badge
Generate
Download
Source code
APK file

Advertisement

SearchDialog

Android Search Dialog Library

Setup

1. Provide the gradle dependency

Add it in your root build.gradle at the end of repositories:

 allprojects {
  repositories {
   ...
   maven { url 'https://jitpack.io' }
  }
 }

Add the gradle dependency to your app module build.gradle file:

 dependencies {
         implementation 'com.github.ajithvgiri:search-dialog:v1.3'
 }

2. Initialization of the SearchDialog

Java

model contains id and title

      List<SearchListItem> searchListItems = new ArrayList<>();
      SearchableDialog  searchableDialog = new SearchableDialog(this, searchListItems, "Title");

Kotlin

model contains id and title

    val searchableDialog = SearchableDialog(this, searchListItems, getString(R.string.country))
    searchableDialog.setOnItemSelected(this) // implement 'OnSearchItemSelected'in your Activity

3. Show the SearchDialog

        searchableDialog.show();

4. Get Selected Item from the SearchDialog

Java

         @Override
         public void onClick(int position, SearchListItem searchListItem) {
                searchableDialog.dismiss();
               // searchListItem.getId(); returns id
              // searchListItem.getTitle(); returns title
         }

Kotlin

        override fun onClick(position: Int, searchListItem: SearchListItem) {
           searchableDialog.dismiss()
           //searchListItem.id.toString()
           //searchListItem.title
        }

5. Screen Shots