Open Web page of Android

Source: Internet
Author: User

First rewrite the Strings.xml file

The code is as follows:

<resources>    <string name= "App_name" >intent apps </string>    <string name= "Open_name" > Standard action action </string>    <string name= "menu_settings" >Settings</string>    <string name= " Title_activity_main ">MainActivity</string></resources>

Then rewrite the Activity_main.xml file

The code is as follows:

<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android"    xmlns:tools= "http// Schemas.android.com/tools "    android:orientation=" vertical "    android:layout_width=" Fill_parent    " android:layout_height= "Fill_parent" ><button     android:id= "@+id/mybut" android:layout_width= "Wrap_    Content "    android:layout_height=" wrap_content "    android:text=" open page "/></linearlayout>

Finally rewrite the Mainactivity class

The code is as follows:

Package Com.example.myclock;import Android.net.uri;import Android.os.bundle;import android.os.systemclock;import Android.os.vibrator;import Android.app.activity;import Android.app.service;import Android.content.Intent;import Android.view.menu;import Android.view.view;import Android.view.view.onclicklistener;import Android.widget.Button; Import Android.widget.chronometer;import Android.widget.chronometer.onchronometerticklistener;public class    Mainactivity extends Activity {private Button mybut = null;        @Override public void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);       Setcontentview (R.layout.activity_main);       This.mybut = (Button) Super.findviewbyid (r.id.mybut);    This.mybut.setOnClickListener (New Onclicklistenerlmpl ()); } Private class Onclicklistenerlmpl implements onclicklistener{public void OnClick (view view) {URI uri = Uri.par    SE ("http://www.mldn.cn");    Intent it = new Intent (); It.setaction (Intent.action_view);    It.setdata (URI);    MainActivity.this.startActivity (IT); }    }}

Operating effect:

Open Web page of Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.