Android studio开发-第一个应用

上效果图

1.先创建布局文件 firstbutton.xml

代码

 <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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="@+id/textView4"
android:layout_width="113dp"
android:layout_height="22dp"
android:layout_marginBottom="336dp"
android:text="这是第一个程序!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.472"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" /> <Button
android:id="@+id/button"
android:layout_width="89dp"
android:layout_height="47dp"
android:layout_marginStart="128dp"
android:layout_marginLeft="128dp"
android:layout_marginTop="50dp"
android:layout_marginEnd="167dp"
android:layout_marginRight="167dp"
android:text="放大"
android:onClick="bigger"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/txv"
tools:ignore="OnClick" /> <Button
android:id="@+id/confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="377dp"
android:layout_marginEnd="43dp"
android:layout_marginRight="43dp"
android:layout_marginBottom="86dp"
android:text="修改"
android:onClick="display"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/name"
app:layout_constraintTop_toTopOf="parent" /> <EditText
android:id="@+id/name"
android:layout_width="166dp"
android:layout_height="wrap_content"
android:layout_marginStart="75dp"
android:layout_marginLeft="75dp"
android:layout_marginTop="54dp"
android:layout_marginEnd="12dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="88dp"
android:ems=""
android:inputType="textPersonName"
android:hint="请输入要显示的字符"
android:text="(名称输入栏)"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/confirm"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button" /> <TextView
android:id="@+id/txv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="159dp"
android:layout_marginLeft="159dp"
android:layout_marginTop="36dp"
android:layout_marginEnd="197dp"
android:layout_marginRight="197dp"
android:text="哈哈"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView4" /> </android.support.constraint.ConstraintLayout>

修改java代码

插入代码

package com.demo.my.myapplication;

import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.firstbutton); } //添加布局
int size=30; // 按钮对应的 onclick 响应
public void bigger(View v){
TextView txv;
txv=(TextView) findViewById(R.id.txv); //根据ID找到对应的text对象
txv.setTextSize(++size); //修改对象的字符大小-size
} //另一个按钮对应的onclick响应
public void display(View v){
EditText name=(EditText) findViewById(R.id.name); //根据ID找到对应的text对象,并进行接下来的操作
TextView text2=(TextView) findViewById(R.id.txv);
text2.setText(name.getText().toString()); //设置字符 } }

Android studio开发-第一个应用的更多相关文章

  1. Android Studio开发第一篇QuickStart

    为什么把as的环境开发放在gradle里呢,因为eclipse里装gradle插件还是不够方便,as直接集成了,然后正好as也是大势所趋,学习一下正好. 看到右边Quick Start快速启动栏下面 ...

  2. 《Android Studio开发实战 从零基础到App上线》资源下载和内容勘误

    转载于:https://blog.csdn.net/aqi00/article/details/73065392 资源下载 下面是<Android Studio开发实战 从零基础到App上线&g ...

  3. windows平台下Android studio开发环境搭建教程

    最近,Google 已宣布,为了简化 Android 的开发力度,以重点建设 Android Studio 工具,到今年年底将停止支持Eclipse等其他集成开发环境 .而随着Android stud ...

  4. 使用 Android Studio 开发 widget 安卓桌面插件

    •What AppWidget 即桌面小部件,也叫桌面控件,就是能直接显示在Android系统桌面上的小程序: 这么说可能有点抽象,看图: 像这种,桌面上的天气.时钟.搜索框等等,都属于 APP Wi ...

  5. 使用Android Studio开发J2SE项目方法

    0.前言 最近因为要为项目开发一个底层的Java应用,所以非常偶然的遇到了这样一个问题,过去Eclipse有Java Project而现在手头使用Android Studio并不能直接建立Java应用 ...

  6. Android studio 开发环境搭建

    Android studio 开发环境搭建 一.环境: 下载java jdk:http://www.oracle.com/technetwork/cn/java/javase/downloads/jd ...

  7. 【Android 应用开发】Ubuntu 下 Android Studio 开发工具使用详解 (旧版本 | 仅作参考)

    . 基本上可以导入项目开始使用了 ... . 作者 : 万境绝尘 转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/21035637 ...

  8. Android Studio开发环境配置以及相关说明

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 前言 这里简单记录下在开发的时候使用的Android Studio开发环境版本以及相关注意事项. 一般来讲,每隔一段时间就要检查下Andr ...

  9. 【Android Studio安装部署系列】二、Android Studio开发环境搭建

    版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 Android Studio开发环境安装步骤 下载Android Studio 下载地址: http://www.wanandroi ...

随机推荐

  1. 一张图告诉你是须要 SQL 还是 Hadoop

    译序 非常多朋友问时下如火如荼的 Hadoop 是否适合引进我们自己的项目,什么时候用 SQL.什么时候用 Hadoop,它们之间怎样取舍?Aaron Cordova 用一张图来回答你这个问题,对于不 ...

  2. IIS6下PHP配置(转载)

    Windows 2003+IIS6+PHP5.4.10配置PHP支持空间的方法 (2013-01-10 16:48:56)标签: php it php环境 php配置 分类: PHP环境配置简介:一般 ...

  3. 【bzoj4245】[ONTAK2015]OR-XOR

    利用前缀和选m个区间等价于选m个数 从最高位开始找,如果这一位至少有m个0,则可以为0,该位为1的后面就不可以选了. 还要注意,最后一个数如果该位为1,那么这一位必须为1,然后要从62开始枚举,而不是 ...

  4. Windows10、ARM开发板、VMware虚拟机同时连接Internet

    前段时间有人遇到一些网络连接问题,让我帮忙处理,他想让ARM开发板连接外网,可以连接网络数据库,同时保证自己的电脑可以上网. 本来说直接可以连接一个路由器,分配一个内网IP给ARM就可以了,但是当时那 ...

  5. rabbitmq最大连接数(Socket Descriptors)

    RabbitMQ自带了显示能够接受的最大连接数,有2种比较直观的方式:1. rabbitmqctl命令. 1 2 3 4 5 6 7 8 9 10 11 12 <span style=" ...

  6. 【NOI 2007】 社交网络

    [题目链接] 点击打开链接 [算法] 首先,跑floyd,计算最短路和最短路径数 然后,计算答案,枚举k,s,t,若dist[s][k] + dist[k][t] = dist[s][t], 那么,点 ...

  7. bzoj1050

    最小生成树 其实这道题是最小生成树的变种,我们发现答案不一定在最小/最大生成树上,最短路算法也不可行,因为我们我们并不是希望最小值尽量的大,最大值尽量的小,这样不一定是最优的,那么我们枚举最小的边,然 ...

  8. 两个局域网(办公网-IDC)安全互通方案2:by GRE and linux server&深入理解GRE

    (0)gre的turnel的打通 1. 这个过程就是双方建立turnel的过程.           (1)局域网路由过程 1.主机A发送一个源为192.168.1.2,目的为10.1.1.2的包 ( ...

  9. python自动化测试学习笔记-10YAML

    之前学习的编写测试用例的方法,都是从excel中编写接口的测试用例,然后通过读取excel文件进行接口自动化测试,这种方式我们叫做数据驱动的方式,由于excel操作起来不灵活,无法实现关联关系的接口测 ...

  10. [笔试面试题] 3-C++关键字篇

    C/C++关键字篇   语言是编程的基础,掌握基本的语言知识是编程的前提条件.关键字是组成语言的最基本单位,对关键字的理解,有助于编写高质量的代码. 1 static(静态)变量有什么作用? 在函数体 ...