Android实验报告.pdf





《Android实验报告.pdf》由会员分享,可在线阅读,更多相关《Android实验报告.pdf(8页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1/8 创建一个名为“登录页面”的布局文件,该文件用于展示登录信息。程序界面如以下图所示:package com.example.mylayout1;import android.app.Activity;import android.content.Context;import android.content.Intent;import android.content.SharedPreferences;import android.os.Bundle;import android.view.Menu;import android.view.View;import android.widge
2、t.EditText;import android.widget.Toast;public class Activity01 extends Activity EditText name;EditText pass;protected void onCreate(Bundle savedInstanceState)super.onCreate(savedInstanceState);setContentView(R.layout.myline);name=(EditText)findViewById(R.id.editText1);pass=(EditText)findViewById(R.i
3、d.editText2);public void click(View view)Intent intent1=new Intent(this,Mylayout1MainActivity.class);startActivity(intent1);public void click1(View view)SharedPreferences sf1=getSharedPreferences(account,Context.MODE_PRIVATE);String name1=sf1.getString(name,);String pass1=sf1.getString(pass,);String
4、 name2=name.getText().toString();String pass2=pass.getText().toString();if(name1.equals(name2)&pass1.equals(pass2)Intent intent2=new Intent(this,Textview1.class);intent2.putExtra(name,name1);intent2.putExtra(pass,pass1);startActivity(intent2);else String co=您的用户名或密码错误;Toast.makeText(this,co.toString
5、(),1000).show();private SharedPreferences getSharedPreference()return null;2/8 创建一个名为“注册页面”的布局文件,该文件用于展示登录信息。程序界面如以下图所示:package com.example.mylayout1;import android.os.Bundle;import android.app.Activity;import android.content.Intent;import android.content.SharedPreferences;3/8 import android.content
6、.SharedPreferences.Editor;import android.view.Menu;import android.view.View;import android.widget.CheckBox;import android.widget.EditText;import android.widget.RadioButton;import android.widget.RadioGroup;import android.widget.Spinner;import android.widget.TextView;public class Mylayout1MainActivity
7、 extends Activity EditText uname;EditText upass;RadioButton radio1;RadioButton radio2;RadioGroup group1;String sex;String name;String pass;CheckBox box1;CheckBox box2;CheckBox box3;CheckBox box4;String str1;String str2;String str3;String str4;Spinner sp;String sp1;Override protected void onCreate(Bu
8、ndle savedInstanceState)super.onCreate(savedInstanceState);setContentView(R.layout.mylayout1_main);group1=(RadioGroup)findViewById(R.id.radioGroup1);uname=(EditText)findViewById(R.id.editText2);upass=(EditText)findViewById(R.id.editText3);box1=(CheckBox)findViewById(R.id.checkBox1);box2=(CheckBox)fi
9、ndViewById(R.id.checkBox2);box3=(CheckBox)findViewById(R.id.checkBox3);box4=(CheckBox)findViewById(R.id.checkBox4);sp=(Spinner)findViewById(R.id.spinner1);Override public boolean onCreateOptionsMenu(Menu menu)/Inflate the menu;this adds items to the action bar if it is present.getMenuInflater().infl
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Android 实验 报告

限制150内