So here i need to get the text the user enters into the search view in order to be able to update the GOOGLE_BOOKS_REQUEST_URL
,
public class BookListingActivity extends AppCompatActivity implements LoaderCallbacks<List<BookListing>> {
private static final String LOG_TAG = BookListingActivity.class.getName();
/**
* This is the search the user does for the API query
*/
private String userQuery;
/**
* URL for book data from the google books dataset
*/
private String GOOGLE_BOOKS_REQUEST_URL =
"https://www.googleapis.com/books/v1/volumes?q=" + userQuery;
/**
* Constant value for the book loader ID. We can choose any integer.
* This really only comes into play if you're using multiple loaders.
*/
private static final int BOOK_LOADER_ID = 1;
/**
* Adapter for the list of books
*/
private BookListingAdapter mAdapter;
/**
* TextView that is displayed when the list is empty
*/
private TextView mEmptyStateTextView;
/**
* ProgressBar that is displayed when the list is loading
*/
private ProgressBar mProgressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Find the searchView in which the query will be performed
SearchView query = (SearchView) findViewById(R.id.search_button);
query.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});