Android 学习笔记(一)新建第一个app

自学Android笔记(一)

一、学习目的

  1. 制作TCP通信手机APP
  2. 掌握基础UI控件的设计使用
  3. 掌握后台service进行TCP通信

二、UI控件基础以及Android studio初识

1、环境搭建

			1、官网下载安装JDK
			2、下载安装Android studio
			[参照网址](https://www.runoob.com/android/android-environment-setup.html)!

2、新建第一个Helloworld工程

新建第一个工程页面

文件及文件夹 解释说明
AndroidManifest 控制activity及我们看到的页面
activity 每一个页面就是一个activity
res->layout->.xml 页面活动布局文件
java->.class Android 活动程序文件
res 存储Android应用需要的源文件
drawable 存储所需要的一般图片文件
mipmap 存储应用程序启动文件

关于.xml活动页面布局文件的解释说明

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout      //确定页面的布局主题:constraintLayout、GridLayout、linerlayout等。       
    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">    //设置了tools:context 在manifest中设置相应主题的话就会在xml页面预览上发生变化,但是不会打包进apk中。

    <TextView
        android:layout_width="wrap_content"    //覆盖内容
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

对helloworld代码进行拓展***

  • 创建如下所示两个activity,并创建相应的java文件,需要注意的是:在manifest 注册activity活动
  • 第一个activity主要实现功能就是:填写IP地址的编辑文本框,点击连接网络按钮,跳转第二个activity,并利用bundle为存储介质传输IP的内容给第二个activity。
  • 主要学习内容:Intent、onClickListener、Bundle

上图第一个activity页面在这里插入图片描述
下面分别是xml代码和class代码

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">

    <TextView
        android:id
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值