• 团队计划(4.26)


    今天做了什么?

    学习一些android知识具体包括textviwe

    源代码:

    mainactivity

     1 package com.example.app01;
     2 
     3 import android.os.Bundle;
     4 import android.app.Activity;
     5 import android.view.Menu;
     6 import android.view.View;
     7 import android.widget.Button;
     8 import android.widget.EditText;
     9 import android.widget.TextView;
    10 import android.view.View.OnClickListener;
    11 
    12 /*
    13  * 
    14  *主要是text编辑还有输入,以及按钮的例子实践
    15  *
    16  *
    17 */
    18 public class MainActivity extends Activity {
    19 
    20     @Override
    21     protected void onCreate(Bundle savedInstanceState) {
    22         super.onCreate(savedInstanceState);
    23         setContentView(R.layout.activity_main);//这就是主程序和输出界面相关联的语句
    24         
    25         final TextView result = (TextView) findViewById(R.id.TextView02);
    26         Button button1 = (Button) findViewById(R.id.button1);
    27         final EditText editText1 = (EditText) findViewById(R.id.editText1);
    28         final EditText editText2 = (EditText) findViewById(R.id.editText2);
    29         
    30         button1.setOnClickListener(new OnClickListener()
    31         {
    32             @Override
    33             public void onClick(View arg0) {
    34                 int arg1 = Integer.parseInt(editText1.getText().toString());
    35                 int arg2 = Integer.parseInt(editText2.getText().toString());
    36                 int arg3 = arg1 + arg2;
    37                 result.append(String.valueOf(arg3));
    38             }
    39         });
    40     }
    41 
    42 
    43     @Override
    44     public boolean onCreateOptionsMenu(Menu menu) {
    45         // Inflate the menu; this adds items to the action bar if it is present.
    46         getMenuInflater().inflate(R.menu.main, menu);
    47         return true;
    48     }
    49     
    50 }

    layout

     1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     2     xmlns:tools="http://schemas.android.com/tools"
     3     android:layout_width="match_parent"
     4     android:layout_height="match_parent"
     5     android:paddingBottom="@dimen/activity_vertical_margin"
     6     android:paddingLeft="@dimen/activity_horizontal_margin"
     7     android:paddingRight="@dimen/activity_horizontal_margin"
     8     android:paddingTop="@dimen/activity_vertical_margin"
     9     tools:context=".MainActivity" >
    10 
    11     <TextView
    12         android:id="@+id/textView1"
    13         android:layout_width="wrap_content"
    14         android:layout_height="wrap_content"
    15         android:layout_alignParentTop="true"
    16         android:layout_centerHorizontal="true"
    17         android:layout_marginTop="100dp"
    18         android:text="小小计算机" />
    19 
    20     <EditText
    21         android:id="@+id/editText1"
    22         android:layout_width="wrap_content"
    23         android:layout_height="wrap_content"
    24         android:layout_below="@+id/textView1"
    25         android:layout_centerHorizontal="true"
    26         android:layout_marginTop="44dp"
    27         android:ems="10"
    28         android:inputType="phone"
    29         android:text="3" />
    30 
    31     <TextView
    32         android:id="@+id/TextView01"
    33         android:layout_width="wrap_content"
    34         android:layout_height="wrap_content"
    35         android:layout_below="@+id/editText1"
    36         android:layout_centerHorizontal="true"
    37         android:layout_marginTop="40dp"
    38         android:text="加" />
    39 
    40     <EditText
    41         android:id="@+id/editText2"
    42         android:layout_width="wrap_content"
    43         android:layout_height="wrap_content"
    44         android:layout_alignLeft="@+id/editText1"
    45         android:layout_below="@+id/TextView01"
    46         android:layout_marginTop="21dp"
    47         android:ems="10"
    48         android:inputType="phone"
    49         android:text="3" >
    50 
    51         <requestFocus />
    52     </EditText>
    53 
    54     <Button
    55         android:id="@+id/button1"
    56         android:layout_width="wrap_content"
    57         android:layout_height="wrap_content"
    58         android:layout_below="@+id/editText2"
    59         android:layout_centerHorizontal="true"
    60         android:layout_marginTop="36dp"
    61         android:text="yes" />
    62 
    63     <TextView
    64         android:id="@+id/TextView02"
    65         android:layout_width="wrap_content"
    66         android:layout_height="wrap_content"
    67         android:layout_alignLeft="@+id/editText2"
    68         android:layout_below="@+id/button1"
    69         android:layout_marginLeft="22dp"
    70         android:layout_marginTop="35dp"
    71         android:text="等于" />
    72 
    73 </RelativeLayout>

    效果:

    明天计划:

    选择框学习

    遇到的困难:

    输出和内部java文件连接无法实现

    最终:setContentView(R.layout.activity_main);//这就是主程序和输出界面相关联的语句

  • 相关阅读:
    初遇Citymaker (十七)
    初遇Citymaker (二十)
    初遇Citymaker (十三)
    初遇Citymaker (十九)
    jQuery easyui datagrid 编辑行试用! 冰糖
    thinkphp 启用 gzip 冰糖
    从《昭君出塞》看国人的历史观
    绍兴沈园 梦断香消四十年
    JVM内存模型、GC垃圾回收
    拆箱、装箱、为什么需要包装类型
  • 原文地址:https://www.cnblogs.com/sisi-job/p/5474319.html
Copyright © 2020-2023  润新知