'I have an error when creating a search and list view for my app
My app is linked to a microsoft server which has tables with employee names that need displayed on the app when searched. I also want whenever a letter is typed in the search bar for names to appear that start with that typed letter, I am very close to this but im getting one error that is telling me to create a constructor in two different lines where it says getApplicationContext.
private void initSearchWidgets() {
SearchView searchView = (SearchView) findViewById(R.id.searchView);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
ArrayList<ClassListItems> filteredNames = new ArrayList<ClassListItems>();
MyAppAdapter adapter = new MyAppAdapter(getApplicationContext(), 0, filteredNames);
listView.setAdapter(adapter);
return false;
}
});
}
private void setUpList() {
listView = (ListView) findViewById(R.id.searchView);
MyAppAdapter adapter;
adapter = new MyAppAdapter(getApplicationContext(), 0, itemsArrayList);
listView.setAdapter(adapter);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|