Android 手机浏览器的开发

最近看android资料,随手写了个简单手机浏览器应用,该应用很简单,主要包括AutoCompleteTextView 、WebView、Button控件,但是涉及到了很多android开发常识,例如:权限管理、布局标题栏状态栏隐藏、开辟线程监听事件、子线程不能更新主线程UI等,下面介绍一下代码示例:

1,修改AndroidManifest.xml文件,首先添加上网和应用旋转权限, 如下:

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.SET_ORIENTATION"/>

在此也可以添加如下代码使应用全屏,即隐藏状态栏和标题栏

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
2, xml布局代码如下:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <AutoCompleteTextView
        android:id="@+id/url"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/url"
        android:inputType="textUri" 
        android:completionHint="@string/url"
        android:completionThreshold="1" />

    <WebView
        android:id="@+id/show"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/btnLayout"
        android:layout_below="@+id/url" />

    <LinearLayout
        android:id="@+id/btnLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        andr
  • 0
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值