Search code examples
androidlistviewclickable

How to make a list non-clickable?


i am using an AsyncTask class to search a word, so i want to appear the word "searching" in the list while proccess is executed

Okay, what I want to do is to have a non clickable list until search is completed, in order to ,if searching word is clicked nothing happens...

Which is the correct way to do this? Thanks a lot!


Solution

  • While you load, search and get data you can display a header view or/and a footer view in your ListView. Simply add these views before setting the adapter. When you search for a word, call setClickable(false) on the ListView and enable your header/footer view by, for example, calling addFooterView(mFooterView) to show your message.

    Notice that you have to add the views before setting the adapter.

    Example:

    LayoutInflater inflater = getLayoutInflater();
    mFooterView = inflater.inflate(R.layout.footer, null, false);
    mListView.addFooterView(mFooterView);       
    mListView.setAdapter(mAdapter);
    

    After this, feel free to call addFooterView() to show your message and call removeFooterView() to hide your message.