网络防火墙系统的实现(一)

本文详细介绍了基于Android2.3及以上版本的应用主界面设计过程,包括布局文件编写、功能模块划分等内容。主界面由模式选择及应用勾选两部分组成,并通过具体的XML代码示例展示了界面元素的布局方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

系统的功能模块大致分为两部分,分别是主界面和设置界面。而主界面又分为i选择模式和勾选应用两部分,设置界面又可细分为防火墙开关,日志开关,保存规则,退出,帮助和更多六部分。

运行环境要求:

  • 操作系统: Android手机基于Linux操作系统
  • 支持环境: Android2.3以上版本
  • 开发环境: Eclipse3.5 ADT0.95

1.编写布局文件

(1)首先编写主界面文件main.xml

    

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android: layout_width="fill_parent"  android: layout_height="fill_parent"
xmlns:android=“http://schemas.android.com/apk/res/android”
          android:orientation="vertical" android:duplicateParentState="false">
         <View android:layout_width="fill_width" android:layout_height="1sp"
                     android:background="#FFFFFFFF" />
         <LinearLayout android:layout_width="fill_parent" android: layout_height="wrap_content" android: padding="8sp">
                 <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/label_mode"
                           android:text="Mode:" android:textSize="20sp" android:clickable="true"></TextView>
         </LinearLayout>
         <View android:layout_width="fill_parent" android:layout_height="1sp" android:background="#FFFFFFFF"> />
         <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="3sp">
               <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/img_wifi"
                    android:src="@drawable/eth_wifi" android:clickable="false"
                    android:layout_alignParentLeft="true" android:paddingLeft="3sp"
                    android:paddingRight="10sp"></ImageView>
               <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/img_3g"
                    android:src="@drawable/eth_g" android:clickable="false"
                    android:layout_toRightOf="@id/img_wifi"></ImageView>
               <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/img_download"
                    android:src="@drawable/download" android:clickable="false"
                    android:layout_alignParentRight="true" android:paddingLeft="22sp"></ImageView>
               <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content"                                       
                    android:id="@+id/img_upload" android:layout_toLeftOf="@id/img_download"  
                    android:src="@drawable/upload" android:clickable="false"></ImageView>
        </RelativeLayout>
        <ListView android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:id="@+id/listview"></ListView>
</LinearLayout>
上述代码将整个主界面划分为了如下两个部分。

  • 上部分:显示模式和网络类型,其中模式分为黑名单模式和白名单模式两种。
  • 下部分:列表显示某种模式下的所有网络服务,并且在每种服务前面显示一个复选框按钮,通过按钮可以设置某种服务启用还是禁用。

下部分的列表功能是通过文件listitem.xml实现的,具体代码如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent" android:layout_height="fill_parent">
          <CheckBox android:layout_width="wrap_content"  android:layout_height="wrap_content" 
                    android:id="@+id/itemcheck_wifi" android:layout_alignParentLeft="true"></CheckBox> 
          <CheckBox android:layout_width="wrap_content"  android:layout_height="wrap_content" 
                    android:id="@+id/itemcheck_3g" android:layout_toRightOf="@id/itemcheck_wifi"></CheckBox>
          <TextView android:layout_width="match_parent"  android:layout_height="wrap_content" 
                    android:id="@+id/app_text" android:layout_toRightOf="@id/itemcheck_3g" android:text="uid:packages"
                    android:layout_centerVertical="true" android:paddingRight="80sp"></TextView>
          <TextView android:layout_height="wrap_content" android:id="@+id/download" android: layout_width="wrap_content" 
                    android: layout_alignParentRight="true" android: layout_centerVertical="true" android: paddingLeft="15sp"></TextView>
          <TextView android: layout_height="wrap_content" android:id="@+id/upload" android:layout_width="wrap_content"
                    android: layout_toLeftOf="@id/download" android:layout_centerVertical="true"></TextView>
</RelativeLayout>

  (2)编写帮助界面布局文件help_dialog.xml

<?xml version="1.0" encoding="utf-8" ?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="fill_parent"  android:layout_height="wrap_content">
         <ScrollView ximns: android="http://schemas.android.com/apk/res/android" 
               android:layout_width="fill_parent"  android:layout_height="fill_parent">
                    <TextView android:layout_height="fill_parent" android:layout_width="fill_parent"
                            android:text="@string/help_dialog_text"  android:padding="6dip" />
         </ScrollView>
</FrameLayout>

界面部分已经完成,下一篇博客将为大家奉上主程序文件。

未完待续。。。。。。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值