• android初体验


    今天看了一会安卓的书,对安卓有了一些粗浅的了解。

    首先xml文件是对界面进行布局的所以在做一个apk之前需要对apk文件进行编辑。

    第二string.xml这个文件是对字符资源进行存储的。

    附上关键代码:

    <TextView
    android:id="@+id/question"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/question"
    android:textSize="30dp"
    android:gravity="center_horizontal" />

    <Button
    android:id="@+id/truebutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20dp"
    android:layout_gravity="center_horizontal"
    android:text="@string/true_button" />

    <Button
    android:id="@+id/falsebutton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textSize="20dp"
    android:layout_gravity="center_horizontal"
    android:text="@string/false_button" />

    <string name="app_name">My Application</string>
    <string name="true_button">喜欢</string>
    <string name="false_button">不喜欢</string>
    <string name="question">你喜欢我吗?</string>

    true_button=(Button) findViewById(R.id.truebutton);
    true_button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Toast toast=Toast.makeText(getApplicationContext(),"你特么瞎啊!!",Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER,0,0);
    toast.show();
    }
    });
    //true
    false_button=(Button) findViewById(R.id.falsebutton);
    false_button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Toast toast=Toast.makeText(getApplicationContext(),"你真有眼光!!",Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER,0,0);
    toast.show();
    }
    });

     附上demo下载地址:https://files.cnblogs.com/files/fyz666/pro1.apk

  • 相关阅读:
    初级工程师该如何去学习,如何去研发开关电源?
    CentOS-pam认证机制简介
    Linux-密码复杂度限制
    如何写一个简单的webserver(一):最简实现
    MySQL5.6绿色版安装(mysql-5.6.24-winx64.zip)
    Linux忘记roo密码的解决办法
    Linux中的netstat命令详解
    WireShark抓包分析(二)
    Wireshark抓取TCP包分析
    Wireshark 基本介绍和学习 TCP 三次握手
  • 原文地址:https://www.cnblogs.com/fyz666/p/6525915.html
Copyright © 2020-2023  润新知