Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to call method from OnClickListener.onClick method ?
    primarykey
    data
    text
    <pre><code>import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import java.net.URLEncoder; import com.google.gson.Gson; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.ImageButton; import android.widget.TextView; public class SampleActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ImageButton button = (ImageButton) findViewById(R.id.imageButton1); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { doSomething(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); } public void doSomething() throws Exception { EditText search2 = (EditText)findViewById(R.id.editText1); TextView urltext = (TextView)findViewById(R.id.textView1); String google = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;q="; String search = search2.toString() + "site:mysite.com"; String charset = "UTF-8"; URL url = new URL(google + URLEncoder.encode(search, charset)); Reader reader = new InputStreamReader(url.openStream(), charset); GoogleResults results = new Gson().fromJson(reader, GoogleResults.class); String voidurlresult = results.getResponseData().getResults().get(0).getUrl().toString(); urltext.setText(voidurlresult); } } </code></pre> <p>please take a look at the above code.....what's wrong with the code . When i click the button i get nothing. when i click the button i want to get the url of the first google result ...if someone can help me i will appreciate it</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload