zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    d3.js(v5.7)的比例尺以及坐标轴
    d3.js(v5.7)的node与数据匹配(自动匹配扩展函数)
    d3.js(v5.7)的attr()函数完善(添加obj支持)
    d3.js入门之DOM操作
    d3.js入门学习
    最近在写个人网站,忙碌中。。。
    构建vue项目(vue 2.x)时的一些配置问题(持续更新)
    Python之元组
    Python之列表
    Python之字符串
  • 原文地址:https://www.cnblogs.com/fyz666/p/6525915.html
Copyright © 2011-2022 走看看