【随笔】Android界面与Html界面大致可以联系起来(学生管理界面)

将慢慢更新。。。慢慢摸索Android的xml布局标签与html布局标签的相似。

 1.xml里面的LinearLayout相当于html的div

因为RelativeLayout的布局相对来说比较自由,下面尝试在相对布局(RelativeLayout)xml下使用LinearLayout。

看代码时,可以把LinearLayout 看成div

<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"
>
    
    <LinearLayout 
        android:id="@+id/info"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">
        <TextView 
            android:id="@+id/xm"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="姓名:"
            android:textSize="18dp"/>
        <EditText 
            android:id="@+id/shuru_xm"
            android:layout_weight="0.7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
        <TextView 
            android:id="@+id/xh"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="学号:"
            android:textSize="18dp"/>
        <EditText 
            android:id="@+id/shuru_xh"
            android:layout_weight="1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </LinearLayout>
	
    <LinearLayout 
        android:id="@+id/xb_xuanze"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/info">
        <TextView
            android:id="@+id/xb"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="性别:"
            android:textSize="18dp"/>
        
        <RadioGroup 
            android:id="@+id/xb_group"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            >

            <RadioButton
                android:id="@+id/nanhai"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="男"
            android:textSize="18dp"/>

            <RadioButton
                android:id="@+id/nvhai"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="女" 
            	android:textSize="18dp"/>
        </RadioGroup>

    </LinearLayout>
    
	<LinearLayout 
	    android:id="@+id/mz_xuanze"
	    android:layout_width="fill_parent"
	    android:layout_height="wrap_content"
	    android:layout_below="@+id/xb_xuanze">
	    <TextView 
	        android:id="@+id/mz"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:text="民族:"
	        android:textSize="18sp"/>
	    <Spinner 
	        android:id="@+id/mz_lb"
	        android:layout_width="wrap_content"
	        android:layout_height="wrap_content"
	        android:textSize="18sp"/>
	</LinearLayout>

</RelativeLayout>

这里只是讲xml布局标签与html布局标签的div相似而已。可以根据这种方式来继续写学生管理界面。


为避免作业相似,改日附上网格布局学生管理界面、表格布局学生管理界面demo。

Python中,我们可以使用`pandas`处理Excel文件中的数据,并结合`requests`和`BeautifulSoup`等库来填充到网页表单。以下是一个基本的步骤: 1. **安装所需库**: 首先确保已安装`pandas`, `openpyxl` (用于读取Excel文件), `requests`, 和 `beautifulsoup4` 等库。如果还没有安装,可以在命令行中运行: ```bash pip install pandas openpyxl requests beautifulsoup4 ``` 2. **读取Excel数据**: 使用`pandas`库读取Excel文件中的数据,假设文件名为`data.xlsx`,工作表名称为`Sheet1`。 ```python import pandas as pd df_excel = pd.read_excel(&#39;data.xlsx&#39;, sheet_name=&#39;Sheet1&#39;) data_list = df_excel.values.tolist() # 将DataFrame转换成列表 ``` 3. **获取网页内容**: 使用`requests`库获取网页HTML内容,例如访问URL `http://example.com/form`。 ```python url = "http://example.com/form" response = requests.get(url) soup = BeautifulSoup(response.text, &#39;html.parser&#39;) # 解析HTML ``` 4. **填写网页表单**: 找到需要填充数据的目标输入字段,可能是`input`标签,然后遍历`data_list`填充数据。这里假设`<input>`标签的`name`属性就是对应的Excel列名。 ```python for row in data_list: for field, value in zip(soup.find_all(&#39;input&#39;, {&#39;name&#39;: True}), row): input_field = field[&#39;name&#39;] input_value = value field.value = input_value # 可能需要根据实际结构调整这一行,比如`field.attrs[&#39;value&#39;] = input_value` # 如果有复选框或下拉菜单,可能需要使用不同的方法 checkbox_fields = soup.find_all(&#39;input&#39;, {&#39;type&#39;: &#39;checkbox&#39;}) dropdown_fields = soup.find_all(&#39;select&#39;) for checkbox in checkbox_fields: checkbox.checked = value_from_excel对应值 # 选择对应值 # 更新选择的选项 for dropdown in dropdown_fields: dropdown.select_one(value_from_excel对应值) # 选择对应值 ``` 5. **提交表单**: 提交表单,如果有`submit`按钮,可以用类似的方式找到并触发它。 6. **处理响应**: 提交后可能会返回新的页面或HTTP状态码,根据需求处理结果。 ```python submit_button = soup.find(&#39;button&#39;, {&#39;name&#39;: &#39;submit&#39;}) if submit_button: form.submit() else: print("No submit button found.") response = requests.post(url, data=your_filled_data) # 如果是POST请求 ``` 请注意,实际操作中可能需要根据目标网站的具体HTML结构进行相应的调整。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值