Git Product home page Git Product logo

Comments (13)

mancj avatar mancj commented on May 31, 2024

I fixed this bug, try the latest version. Let me know if it works and I'll make a new release.

compile 'com.github.mancj:MaterialSearchBar:0.6.1-beta'

from materialsearchbar.

mancj avatar mancj commented on May 31, 2024

The problem was that the maxSuggestionsCount default value in the SuggestionsAdapter is equals 0. And you just had to set the new value manually

from materialsearchbar.

c4adarsh avatar c4adarsh commented on May 31, 2024

Its not working. See the below method. I have used the setMaxSuggestionCount. Should I do something else.

private void openSearchArea(List suggestions){
searchBar.setMaxSuggestionCount(suggestions.size());
customSuggestionsAdapter.setSuggestions(suggestions);
customSuggestionsAdapter.notifyDataSetChanged();
}

from materialsearchbar.

mancj avatar mancj commented on May 31, 2024

sorry, I made a mistake. You need to compile the version 0.6.1-beta. I updated my comment above

from materialsearchbar.

c4adarsh avatar c4adarsh commented on May 31, 2024

customSuggestionsAdapter.setMaxSuggestionsCount(suggestions.size());
customSuggestionsAdapter.setSuggestions(suggestions);
customSuggestionsAdapter.notifyDataSetChanged();

still doesn't work

from materialsearchbar.

mancj avatar mancj commented on May 31, 2024

Post your custom adapter code, please.

from materialsearchbar.

c4adarsh avatar c4adarsh commented on May 31, 2024

import android.graphics.Color;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.mancj.materialsearchbar.adapter.SuggestionsAdapter;

public class CustomSuggestionsAdapter extends SuggestionsAdapter<String, CustomSuggestionsAdapter.SuggestionHolder> {

private SuggestionsAdapter.OnItemViewClickListener listener;

private String mUnderline = Constants.WHITE;

public CustomSuggestionsAdapter(LayoutInflater inflater) {
    super(inflater);
}

public void setListener(SuggestionsAdapter.OnItemViewClickListener listener) {
    this.listener = listener;
}

public void setUnderlineColor(String mColor){
    mUnderline = mColor;
}

@Override
public void onBindSuggestionHolder(String suggestion, SuggestionHolder holder, int position) {
    holder.title.setText(suggestion);
    if(mUnderline == Constants.WHITE){
        holder.view.setBackgroundColor(Color.WHITE);
    }else{
        holder.view.setBackgroundColor(Color.WHITE);
    }
}

@Override
public SuggestionHolder  onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = getLayoutInflater().inflate(R.layout.suggestion_row, parent, false);
    return new SuggestionHolder(view);
}

@Override
public int getSingleViewHeight() {
    return 60;
}

class SuggestionHolder extends RecyclerView.ViewHolder{
    protected TextView title;
    protected View view;

    public SuggestionHolder(View itemView) {
        super(itemView);
        title = (TextView) itemView.findViewById(R.id.my_list_item);
        itemView.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v) {
               listener.OnItemClickListener(getAdapterPosition(),v);
            }
        } );
        view = (View) itemView.findViewById(R.id.view);
    }
}

}

from materialsearchbar.

mancj avatar mancj commented on May 31, 2024

I don't see any problems. Can you show the xml file?
And make sure MaterialSearchBar's height set to wrap_content.

from materialsearchbar.

c4adarsh avatar c4adarsh commented on May 31, 2024

suggestion_row.txt

from materialsearchbar.

mancj avatar mancj commented on May 31, 2024

I meant the xml file where you create MaterialSearchBar, not the adapter's row.

from materialsearchbar.

c4adarsh avatar c4adarsh commented on May 31, 2024

serach_layout.txt

from materialsearchbar.

mancj avatar mancj commented on May 31, 2024

It still doesn't work with height wrap_content?

from materialsearchbar.

c4adarsh avatar c4adarsh commented on May 31, 2024

Nop. It doesn't work. Leave this issue open. I will check your code after 10th. Thanks for the help.

from materialsearchbar.

Related Issues (20)

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.