Git Product home page Git Product logo

xamarin-searchbar's Introduction

sponsor

Xamarin-Material SearchBar Android

Material Design Search Bar for Android.

.NET

Package Latest Release
Xamarin-MaterialSearchBar NuGet Badge Xamarin-MaterialSearchBar

This version is based on the fantastic version created by: Mansur Nashaev

The original one:

This beautiful and easy to use library will help to add Lollipop Material Design SearchView in your project.


Read the Wiki for advanced examples and options.


But now, let's go deep into some code!

Basic example:

First to add Xamarin-MaterialSearchBar into your project you need to download the package from NuGet.

Next edit your XML and add the custom control:

<tk.supernovaic.MaterialSearchBar.MaterialSearchBar
	style="@style/MaterialSearchBarLight"
	app:mt_speechMode="true"
	app:mt_hint="Custom hint"
	app:mt_maxSuggestionsCount="10"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:id="@+id/searchBar" />

After that you can edit your activity and add the following piece of code:

public partial class YourClassActivity : AppCompatActivity, MaterialSearchBar.IOnSearchActionListener
{    
	private MaterialSearchBar MSearchBar { get; set; }

	protected override void OnCreate(Bundle savedInstanceState)
	{
		base.OnCreate(savedInstanceState);

		MSearchBar = FindViewById<MaterialSearchBar>(Resource.Id.searchBar);

		MSearchBar.SetOnSearchActionListener(this);

		MSearchBar.AddTextChangeListener(new MaterialSearchBarListener());
	}

	void MaterialSearchBar.IOnSearchActionListener.OnButtonClicked(int p0)
	{
		switch (p0)
		{
			case MaterialSearchBar.ButtonNavigation:
				Drawer.OpenDrawer((int)GravityFlags.Left);
				break;
			case MaterialSearchBar.ButtonSpeech:
				break;
			case MaterialSearchBar.ButtonBack:
				MSearchBar.DisableSearch();
				break;
		}
	}
}

public partial class YourClassActivity
{
	private class MaterialSearchBarListener : Java.Lang.Object, ITextWatcher
	{
		public void AfterTextChanged(IEditable s)
		{

		}

		public void BeforeTextChanged(ICharSequence s, int start, int count, int after)
		{

		}

		public void OnTextChanged(ICharSequence s, int start, int before, int count)
		{
                       //Here you can execute the query with the texted data.
		}
	}
}

Follow me at:

LinkedIn YouTube Amazon Goodreads Instagram Cyber Prophets Sharing Your Stories
LinkedIn YouTube Amazon Goodreads Instagram RedCircle Podcast RedCircle Podcast

xamarin-searchbar's People

Contributors

fanmixco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

xamarin-searchbar's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.