Day7 - TextView(一)

TextView喜虾密东西勒??
其实就是程序一开始"Hello World!"那个元件
主要是做文字显示用
今天就来看TextView的基本用法

开始

  • 一开始先到xml档Design页面,我们可以看到左下角有一个Component Tree的栏位,里面会显示目前拉的元件有那些,这里会看一个我们今天介绍的TextView在里面,点击它右边Attributes栏会变成所点选TextView的各种属性,可以在这里进行修改
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769DgefP4cSHP.png
    或是
  • 到xml档的Code页面,找到TextView元件进行设计
    https://ithelp.ithome.com.tw/upload/images/20210914/201417690LklGmATuw.png

修改文字内容

  • 方法一: 在Design页面点选TextView元件後,在Attributes栏找到text的属性,直接修改text的值
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769K1xxP6ebwm.png
    执行结果:
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769inWqqdrLby.png
  • 方法二: 到Code页面找到TextView元件,把 android:text="" 後面引号里改成想显示的文字
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769QwA9CY3X6K.png
    执行结果:
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769inWqqdrLby.png
  • 方法三: 透过程序码修改文字。先设定好TextView的id,然後到java档打程序码
    设定id
    (Design页面)
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769LELjJAvfzS.png
    (Code页面)
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769CQKvuQHydj.png
    到MainActivity.java
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769UzEWMWlIzG.png
    下面那行透过findViewById去抓TextView的元件(後面R.id.xxx,xxx为你刚刚设的id)
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769JxMzsqZFUz.png
    下面就是设定我要的文字拉
    https://ithelp.ithome.com.tw/upload/images/20210914/201417692DH1ZsvcMK.png
    执行结果:
    https://ithelp.ithome.com.tw/upload/images/20210914/20141769efaAOgs2fI.png

<<:  [Day03] Vue i18n - Message Format Syntax

>>:  Day 6【React】阿嬷你怎麽没感觉?

Day 19 民生公共物联网资料应用竞赛,产品设计讨论过程分享

来找设计师一起 side project,前後端 / UIUX 皆可ㄛ。配对单连结: https:...

Day 24 - Sticky Nav

前言 JS 30 是由加拿大的全端工程师 Wes Bos 免费提供的 JavaScript 简单应用...

【HTML】标记?标签?HTML元素?

【前言】 本系列为个人前端学习之路的学习笔记,在过往的学习过程中累积了很多笔记,如今想藉着IT邦帮忙...

【Day 21】阵列的程序范例与字串介绍

今天我们来看一个简单的程序: #include<stdio.h> int main(){...

Day 5 - TiDB架构

TiDB里头的TiDB,听起来有点饶舌,为了避免混淆,後面会加个server来做区别。TiDB se...