• android之打开网页


    首先改写strings.xml文件

    代码如下:

    <resources>
    
        <string name="app_name">Intent应用</string>
        <string name="open_name">标准Action操作</string>
        <string name="menu_settings">Settings</string>
        <string name="title_activity_main">MainActivity</string>
    
    </resources>
    

      然后改写activity_main.xml文件

    代码如下:

    <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="打开网页"/>
    </LinearLayout>
    

      最后改写MainActivity类

    代码如下:

    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.parse("http://www.mldn.cn");
        		Intent it = new Intent();
        		it.setAction(Intent.ACTION_VIEW);
        		it.setData(uri);
        		MainActivity.this.startActivity(it);
        	}
        }
    }
    

      运行效果:

    态度决定高度,细节决定成败,
  • 相关阅读:
    C++结构体中sizeof
    sizeof()的用法
    XStream和Json
    省市联动
    ajax
    配置文件的读取
    JSP标签库
    字符串函数参数传入传出(去空格)
    字符串函数参数传入传出(字符串反转)
    opendir,readdir,closedir
  • 原文地址:https://www.cnblogs.com/lxk2010012997/p/3989164.html
Copyright © 2020-2023  润新知