package com.example.georgekaraolanis.project7_booklistingapp;

import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import java.util.List;

public class MainActivity extends AppCompatActivity {

    /*URL to read from*/
    private static final String QUERY_URL = "  https://www.googleapis.com/books/v1/volumes?q=";

    /*Maximum number of items to get from query. In API documentation it is
      stated that its maximum value is 40, so we will use that.*/
    private static final String MAX_RESULTS_PARAMETER = "&maxResults=40";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

}

@@ -160,16 +160,164 @@
 Bundle;%0A
+import android.view.View;%0Aimport android.widget.Button;%0Aimport android.widget.EditText;%0Aimport android.widget.ListView;%0A%0Aimport java.util.ArrayList;
 %0Aimport 
@@ -723,24 +723,166 @@
 sults=40%22;%0A%0A
+    /*AsyncTask for network operations*/%0A    private AsyncTask bookAsyncTask;%0A%0A    /*Adapter for listview*/%0A    private BookAdapter adapter;%0A%0A
     @Overrid
@@ -1031,16 +1031,1630 @@
 y_main);
+%0A%0A        /*Adapter for ListView*/%0A        ListView bookListView = (ListView) findViewById(R.id.list);%0A        adapter = new BookAdapter(this,new ArrayList%3CBook%3E());%0A        bookListView.setAdapter(adapter);%0A%0A        /*Add click listener to button*/%0A        Button searchButton = (Button) findViewById(R.id.search_button);%0A%0A        searchButton.setOnClickListener(new View.OnClickListener() %7B%0A            @Override%0A            public void onClick(View v) %7B%0A%0A                /*Get text from EditText*/%0A                EditText bookEditText = (EditText) findViewById(R.id.search_field);%0A%0A                /*Get book name the user entered*/%0A                String bookName = bookEditText.getText().toString();%0A%0A                /*Create asyncTask and execute*/%0A                BookAsyncTask bookAsyncTask = new BookAsyncTask();%0A                bookAsyncTask.execute(QUERY_URL + bookName + MAX_RESULTS_PARAMETER);%0A            %7D%0A        %7D);%0A    %7D%0A%0A    private class BookAsyncTask extends AsyncTask%3CString,Void,List%3CBook%3E%3E%7B%0A%0A        @Override%0A        protected List%3CBook%3E doInBackground(String... urls)%7B%0A%0A            /*Check if first url is null or if there are no urls*/%0A            if (urls.length %3C 1 %7C%7C urls%5B0%5D == null)%7B%0A                return null;%0A            %7D%0A%0A            List%3CBook%3E books = QueryUtils.fetchBookData(urls%5B0%5D);%0A            return books;%0A        %7D%0A%0A        @Override%0A        protected void onPostExecute(List%3CBook%3E books)%7B%0A%0A            /*Clear adapter*/%0A            adapter.clear();%0A%0A            if(books != null && !books.isEmpty())%7B%0A                adapter.addAll(books);%0A            %7D%0A        %7D%0A%0A
 %0A    %7D%0A%0A

Add adapter and AsyncTask in Mainactivity