首页 > 其他分享 >app的简单创建:

app的简单创建:

时间:2023-10-05 23:31:39浏览次数:37  
标签:__ 创建 app void 简单 import android public

新建虚拟手机:

app的简单创建:_android

效果:

app的简单创建:_ide_02

res->layout->activity_main.xml:

app的简单创建:_android_03

点击code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">


    <LinearLayout
        android:layout_height="200dp"
        android:layout_width="match_parent"
        android:layout_marginTop="150dp"
        android:background="#dddddd"
        android:orientation="vertical">


        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="用户登录"
            android:textAlignment="center"
            android:textSize="20dp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:paddingLeft="50dp"
            android:paddingRight="50dp">

            <TextView
                android:layout_width="60dp"
                android:layout_height="match_parent"
                android:gravity="center"
                android:text="用户名" />

            <EditText
                android:id="@+id/txt_user"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:inputType="text"
                android:singleLine="true"
                android:textSize="14dp" />


        </LinearLayout>


        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:paddingLeft="50dp"
            android:paddingRight="50dp">

            <TextView
                android:layout_width="60dp"
                android:layout_height="match_parent"
                android:gravity="center"
                android:text="密码" />

            <EditText
                android:id="@+id/txt_pwd"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:inputType="textPassword"
                android:singleLine="true"
                android:textSize="14dp" />


        </LinearLayout>


        <LinearLayout
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="50dp">

            <Button
                android:id="@+id/btn_login"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="10dp"
                android:text="登录"/>

            <Button
                android:id="@+id/btn_reset"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="重置"/>

        </LinearLayout>

    </LinearLayout>

</LinearLayout>

Logcat:

app的简单创建:_android_04

package com.example.demo;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    public   Button btnLogin;
    public Button btnReset;
    public TextView txtUser, txtPwd;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

       initView();
       //绑定事件
        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e("事件", "点击登录");
            }
        });

        btnReset.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e("事件", "点击登录");
            }
        });


    }
    public void initView(){
        btnLogin = findViewById(R.id.btn_login);
        btnReset = findViewById(R.id.btn_reset);

        txtUser = findViewById(R.id.txt_user);
        txtPwd = findViewById(R.id.txt_pwd);
    }
}

简单功能:

重置:

app的简单创建:_ide_05

app的简单创建:_xml_06

 public void doReset(){
        //清空输入框
        txtUser.setText("");
        txtPwd.setText("");
    }

登录功能:

引入模块:

implementation ("com.squareup.okhttp3:okhttp:4.9.1")

app的简单创建:_xml_07

这里:

app的简单创建:_ide_08

记得要下载:

app的简单创建:_xml_09

给权限:
<uses-permission android:name="android.permission.INTERNET"/>

app的简单创建:_xml_10

这里我搞了一个flask项目,不能用127.0.0.1

from flask import Flask, request

app = Flask(__name__)


@app.route("/login", methods=['GET', 'POST'])
def login():
    print(request.form)
    user = request.form.get('user')
    pwd = request.form.get('pwd')
    return "OOOK"


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=8000)

    

https://blog.csdn.net/lw_zhaoritian/article/details/121291067

app的简单创建:_ide_11

报错:

not permitted by network security policy

https://blog.csdn.net/qq_33401954/article/details/102617018

效果:

app的简单创建:_xml_12

app的简单创建:_ide_13

标签:__,创建,app,void,简单,import,android,public
From: https://blog.51cto.com/u_16172166/7718232

相关文章

  • 【计算几何】codeforces上面的一点简简单单的计算几何入门题
    开篇碎碎念我真的好喜欢开篇碎碎念啊(可恶真的是太话痨啦)最近有在cf上面写写题,唔不过还没上百题,过两天就可以写百题纪念啦,也还没上青,陌陌菜菜,陌陌在努力变强捏。cf1850GTheMorningStartag:用map进行维护,斜率与坐标的关系题目链接:G.TheMorningStar题意:找到一个点,使另一......
  • servlet在web项目的基本创建(我的第一篇博客,用来试试水的)
    下面这个是要写在WEB-INf的web.xml里面用来注册你要用的servlet类的<servlet>//这个用来注册servlet标签     <servlet-name>TestServlet</servlet-name>//你要用的servlet类的名字     <servlet-class>cn.com.TestServlet</servlet-class>//完整的类名(其实......
  • 办公小程序-创建
       配置tomcat:server:tomcat:uri-encoding:UTF-8threads:max:200min-spare:30connection-timeout:5000msport:8080servlet:context-path:/emos-wx-api配置mysql数据源:spring:datasource:type:com.......
  • 实验1 C语言输入输出和简单程序编写
    1.实验任务1 task1_1源代码:1#include<stdio.h>2#include<stdlib.h>3intmain()4{5printf("0\n");6printf("<H>\n");7printf("II\n");8printf("0\n");9prin......
  • uniapp微信小程序如何处理input输入空格问题?
    第一种方法用input组件自带的@input事件使用@input事件绑定变量用trim修剪掉前端和末尾的空格后用replace替换空格为空把处理过的值赋给自己<inputtype="text"class=""v-model="certNo"placeholder="请输入您的证书编号"@blur="certNo=certNo.trim().replace(/\s+/g,''......
  • uniapp微信小程序如何处理input输入空格问题?
    第一种方法用input组件自带的@input事件使用@input事件绑定变量用trim修剪掉前端和末尾的空格后用replace替换空格为空把处理过的值赋给自己<inputtype="text"class=""v-model="certNo"placeholder="请输入您的证书编号"@blur="certNo=certNo.trim().replace(/\s+/g,''......
  • Bean 的作用域有哪些?如何在 Spring 中创建 Bean?
    Bean的作用域有哪些?在Spring中,Bean的作用域定义了Bean实例的生命周期和可见性。Spring定义了以下五种作用域:1、singleton:单例模式,一个Bean容器中只存在一个实例。2、prototype:每次请求都会创建一个新的实例。3、request:每个HTTP请求都会创建一个新的实例。4、ses......
  • 有关于Mysql的简单问题及示例(增删改查 一对一 多对多 左外连接 右外链接)
    Mysql1、请自行设计表并针对该表练习最基本的增删改查且写出示例代码建立表格class其中有属性nameidgenderinterest表格建立完成向表中插入数据插入数据完成尝试删除表中id=101的数据删除数据成功尝试修改表中id为102的数据修改成功2、请问什么是一对多?请自......
  • 【解决了一个小问题】terraform apply 的时候出现访问 localhost 出错
    作者:张富春(ahfuzhang),转载时请注明作者和引用链接,谢谢!cnblogs博客zhihuGithub公众号:一本正经的瞎扯有这样一段terraform的部署脚本:provider"kubernetes"{config_path="~/.kube/config_dir/k8s.yaml"}执行terraformapply的时候报这样的错误:│Error:G......
  • 实验1_c语言输入输出和简单程序应用编程
    实验一1-1#include<stdio.h>intmain(){printf("O\n");printf("<H>\n");printf("II\n");printf("O\n");printf("<H>\n");printf("II\n");......