public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus){
relativeLayout1.setBackground(getResources().getDrawable(R.drawable.beijing2));
relativeLayout2.setBackground(getResources().getDrawable(R.drawable.beijing));
}
}
});
mPasswordEdit.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus)
//设置背景图片,为Text用户框和密码框点击显示
relativeLayout1.setBackground(getResources().getDrawable(R.drawable.beijing));
relativeLayout2.setBackground(getResources().getDrawable(R.drawable.beijing2));
}
}
});
//监听用户框,点击用户框的反应
tuPian.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mUserNameEdit.setText("");
}
});
//密码框监听,点击密码框起的反应
tuPian2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mPasswordEdit.setText("");
}
});
onebutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String userName = mUserNameEdit.getText().toString();
String Password = mPasswordEdit.getText().toString();
//判定,如果用户名好人密码为空,就弹出提示框
if(userName.equals("") || Password.equals("")){
Toast.makeText(Denglu.this, "用户名或者不能为空", Toast.LENGTH_SHORT).show();
}
else if(!userName.equals("fengzi") || !Password.equals("123456")){
Toast.makeText(Denglu.this, "用户名和密码不一致", Toast.LENGTH_SHORT).show();
}
else{
Toast.makeText(Denglu.this, "登录成功", Toast.LENGTH_SHORT).show();
//登陆成功后自动转为下一个Activty,使所转到的页面字体参数发生变化
//定义参数
String Message="一辆大众和一辆宝马7系正在等红灯,突然一辆QQ发疯似的开来";
String Message2="可能有很多人不理解它的用法,文档里说的也不太清楚,其实很简单,看下面";
//跳转的页面为Framellayout
Intent intent=new Intent(Denglu.this,Framellayout.class);
Bundle bundle=new Bundle();
bundle.putString("key",Message);
bundle.putString("key2",Message2);
intent.putExtras(bundle);
//启动
startActivity(intent);
}
}
});
---------------------------------------------------------------------------------------------------------------------------------------------------------
//所跳转到的Activty
public class Framellayout extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.framelayout);
//用intent获取
Intent intent=getIntent();
Bundle bundle=intent.getExtras();
//用字符串接收传过来的参数
String s=bundle.getString("key");
String s2=bundle.getString("key2");
//改变本窗口集体哪个id的参数值
TextView textView=(TextView)findViewById(R.id.one_1);
TextView textView1=(TextView)findViewById(R.id.one_2);
//改变本窗口文本参数值
textView.setText(s);
textView1.setText(s2);
}
}