package com.pavan.googleautocompletion;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;
import com.android.volley.Request.Method;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;

public class MainActivity extends Activity {
	String url;
	private static final String TAG_RESULT = "predictions";
	JSONObject json;

	AutoCompleteTextView auto_tv;
	ArrayList<String> names;
	ArrayAdapter<String> adapter;
	String browserKey = "YOUR API KEY";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		auto_tv = (AutoCompleteTextView) findViewById(R.id.searchAutoComplete);
		auto_tv.setThreshold(0);

		names = new ArrayList<String>();

		auto_tv.addTextChangedListener(new TextWatcher() {

			public void afterTextChanged(Editable s) {

			}

			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {

			}

			public void onTextChanged(CharSequence s, int start, int before,
					int count) {

				if (s.toString().length() <= 3) 
				{	
					names = new ArrayList<String>();
					
				}

			}
		});

	}


}
