Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's close, but a few things are in the wrong place or missing. The below code works -- I tried to make the minimum necessary alterations. You could load both versions into something like <a href="http://winmerge.org/downloads/" rel="noreferrer">WinMerge</a> to see exactly what changed.</p> <p>main.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/bgimage2" &gt; &lt;Button android:id="@+id/goButton" android:layout_width="150px" android:layout_height="wrap_content" android:text="@string/start" android:layout_x="80px" android:layout_y="21px" &gt;&lt;/Button&gt; &lt;/LinearLayout&gt; </code></pre> <p>GetURL.java:</p> <pre><code>import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.Toast; public class GetURL extends Activity { private Button goButton; String url = "http://www.yahoo.com"; Intent i = new Intent(Intent.ACTION_VIEW); Uri u = Uri.parse(url); Context context = this; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); goButton = (Button)findViewById(R.id.goButton); goButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v){ try { // Start the activity i.setData(u); startActivity(i); } catch (ActivityNotFoundException e) { // Raise on activity not found Toast.makeText(context, "Browser not found.", Toast.LENGTH_SHORT); } } }); } } </code></pre> <p>(You also need a <code>bgimage2.png</code> file in <code>/res/drawable/</code> and a <code>start</code> string in <code>/res/values/strings.xml</code>, of course).</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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