last day (28 days later) » 

1:41 AM
0
A: unable to filter custom adapter data comes from mysql database

ArshadImplement Filterable in your adapter and Override filter function like below @Override public Filter getFilter() { Filter filter = new Filter() { @Override protected void publishResults(CharSequence constraint, FilterResults results) { it...

 
how to set my adaptor to my list view?
 
@ArpanSarkar check the updated answer, you can add list to adapter in PostExecute method
 
@Arsad is that filterable result after search?
 
FilteredItems array will contain your list after search. On search editText you need to add textChange listener and then call youradpater.filter(string)
 
yes...how I can do that with that search view?in my list activity
 
1:41 AM
add textChangeListener to your searchView. Or Post your activity code.
 
list activity is my main activity...check my code.I initialise my search view there..
check my updated code.I added
 
@ArpanSarkar add SearcView filter code, check my updated code
 
its not working...
 
can you post your updated code. Both Activity and Adapter. Complete Class
 
check my updated code
 
1:41 AM
@ArpanSarkar my bad. in onQueryTextChange you should return true at end
 
still it does not work...
 
if the above code your updated code? As in onPostExecute you are not setting your stockList to adapter and adpater to listview
 
check my updated code..I set adapter in postExecute method
 
define the adapter at class level, before onCreateMethod, CustomStockList adapter
 
i tried that..but did not work..search view not working properly i think...no error but no filter result comes...
 
1:41 AM
you have to add your filtering condition in filter() method, Search for this comment in adapter // your filtering condition there you need to add your condition, like to which field of StockData you want to compare your input with. Due to this only there is no filtering happening
 
please update your code...I can not understand properly..
 
on which fileld you want your filter to work? Model No? or Stock? Or both? Also can you post your code for StackData class
 
In StockData only have constructor and getter setter...nothings else.I want to filter model no but in list model no and stock show
 
What are the fields you have. On what basis you need the filtering to work!!!
 
i want to search by model no
 
1:41 AM
updated code. check the code below this line in my answer Your adapter will looks something like this, copy the filter function from there and use it
 
what is the the s in this function? if(data.getModelno().contains(s)) { FilteredItems.add(data); }
 
actually you need to use constraint it is the value which is passed from SearchView
updated the filter function
 
an error occur : com.example.arpan.aims E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.arpan.aims, PID: 5203 java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(2131165281, class android.widget.ListView) with Adapter(class com.example.arpan.aims.CustomStockList)]
stoped app when i enter any thing in search view..
 
is it crashing on load or after entering something in search?
 
after enter any later and show this error in logcat.
 
 
4 hours later…
5:31 AM
can you share your code in github or zip
so i will fix it and send you the build
updated code*
 

  last day (28 days later) »