Imitez l'effet du champ de recherche bilibili (seulement trois phrases sont nécessaires pour y parvenir)
Jetez d'abord un œil à l'image d'aperçu (il y a une petite distorsion après la conversion) :
1. Prise en charge de l'historique de recherche (déjà stocké dans la base de données)
2. L'effet de recherche est fondamentalement le même que celui de bilibili.
3. Si vous devez modifier davantage de contenu, vous pouvez télécharger la bibliothèque et la modifier vous-même.
4. Je ne suis pas un expert. S'il y a quelque chose qui ne va pas, veuillez le signaler via Problèmes. Merci.
5. Merci d'avoir fait référence à l'article de ce bon de commande.
6. Merci d'avoir soumis des problèmes. Cela fait si longtemps que je n'ai pas mis à jour.
Avec Gradle :
implementation ' com.wenwenwen888:searchbox:1.0.1 '
La première phrase, instanciation :
SearchFragment searchFragment = SearchFragment . newInstance ();
Deuxième phrase, définir le rappel :
searchFragment . setOnSearchClickListener ( new IOnSearchClickListener () {
@ Override
public void OnSearchClick ( String keyword ) {
//这里处理逻辑
Toast . makeText ( ToolBarActivity . this , keyword , Toast . LENGTH_SHORT ). show ();
}
});
La troisième phrase, affiche le champ de recherche :
searchFragment . showFragment ( getSupportFragmentManager (), SearchFragment . TAG );
Copyright 2016 wenwenwen888
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.