admin管理员组

文章数量:1545253

最近看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:andro
    xmlns:tools="http://schemas.android/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <AutoCompleteTextView
        android:
        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:
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/btnLayout"
        android:layout_below="@+id/url" />

    <LinearLayout
        android:
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        andr

本文标签: 浏览器手机android