团队计划(4.27)

今天做了什么?

选择框的学习

源代码:

main

 1 package com.example.app2;
 2 
 3 import android.os.Bundle;
 4 import android.app.Activity;
 5 import android.view.View;
 6 import android.view.Menu;
 7 import android.widget.CheckBox;
 8 import android.view.View.OnClickListener;
 9 import android.widget.TextView;
10 /*
11  * 
12  *选择框
13  *
14  *
15 */
16 public class MainActivity extends Activity {
17 
18     @Override
19     protected void onCreate(Bundle savedInstanceState) {
20         super.onCreate(savedInstanceState);
21         setContentView(R.layout.activity_main);
22         
23         final TextView textView1 = (TextView) findViewById(R.id.textView1);
24         final CheckBox checkBox1 = (CheckBox) findViewById(R.id.checkBox1);
25         
26         checkBox1.setOnClickListener(new OnClickListener()
27         {
28 
29             @Override
30             public void onClick(View arg0) {
31                 if(checkBox1.isChecked())
32                 {
33                     textView1.setText("您已经同意了!");
34                 }
35                 else
36                 {
37                     textView1.setText("您未同意!");
38                 }
39             }
40             
41         }
42         );
43         
44     }
45 
46 
47     @Override
48     public boolean onCreateOptionsMenu(Menu menu) {
49         // Inflate the menu; this adds items to the action bar if it is present.
50         getMenuInflater().inflate(R.menu.main, menu);
51         return true;
52     }
53     
54 }

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="70dp"
18         android:text="@string/hello_world" />
19 
20     <CheckBox
21         android:id="@+id/checkBox1"
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="86dp"
27         android:text="同意" />
28 
29 </RelativeLayout>

截图:

明天计划:

学习单选框

困难:

</RelativeLayout>相对位置没有搞懂

解决:

这属于一种布局,根据相互之间的位置布局

原文地址:https://www.cnblogs.com/sisi-job/p/5474348.html