Я пытаюсь создать программу с одним EditText, двумя кнопками (Google и Yahoo) и одним WebView. То, что я пытаюсь создать, - это поиск слова, набранного в EditText. Если пользователь нажимает на Google, текст в EditText автоматически будет искать в Google.com, а если пользователь нажимает Yahoo, текст в EditText автоматически будет искать на Yahoo.com. Пока Google уже работает. Может ли кто-нибудь помочь мне с Yahoo. СпасибоПоиск Google Google и Yahoo из EditText
package com.example.webbrowser3;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;
public class WebBrowser3 extends Activity implements OnClickListener {
Button google;
Button yahoo;
WebView WebView;
EditText search;
String url;
Intent intent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_browser3);
WebView = (WebView)findViewById(R.id.webview);
search = (EditText)findViewById(R.id.search);
google = (Button)findViewById(R.id.google);
google.setOnClickListener(this);
yahoo = (Button)findViewById(R.id.yahoo);
yahoo.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if (v.getId()==R.id.google)
{
intent = new Intent(Intent.ACTION_WEB_SEARCH);
url=search.getText().toString();
intent.putExtra(SearchManager.QUERY, url);
startActivity(intent);
}
else if (v.getId()==R.id.yahoo)
{
url=search.getText().toString();
WebView.loadUrl("http://www.yahoo.com" + url);
}
}
}