/* * Copyright (C) 2016 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.datafrominternet; import android.content.Context; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity { private EditText mSearchBoxEditText; private TextView mUrlDisplayTextView; private TextView mSearchResultsTextView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mSearchBoxEditText = (EditText) findViewById(R.id.et_search_box); mUrlDisplayTextView = (TextView) findViewById(R.id.tv_url_display); mSearchResultsTextView = (TextView) findViewById(R.id.tv_github_search_results_json); } // TODO (2) Create a method called makeGithubSearchQuery // TODO (3) Within this method, build the URL with the text from the EditText and set the built URL to the TextView @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int itemThatWasClickedId = item.getItemId(); if (itemThatWasClickedId == R.id.action_search) { // TODO (4) Remove the Toast message when the search menu item is clicked Context context = MainActivity.this; String textToShow = "Search clicked"; Toast.makeText(context, textToShow, Toast.LENGTH_SHORT).show(); // TODO (5) Call makeGithubSearchQuery when the search menu item is clicked return true; } return super.onOptionsItemSelected(item); } }