6月10号 作业 android应用开发详解 密码 用户 登录界面

package com.jack.check;

import android.accounts.Account;
import android.accounts.OnAccountsUpdateListener;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.method.KeyListener;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.View.OnClickListener;
import android.view.View.OnFocusChangeListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
public class CheckActivity extends Activity {
 private EditText myEdit1,myEdit2;
 private CheckBox cb1;
 private Button b1,b2;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        myEdit1=(EditText)findViewById(R.id.EditText01);
        myEdit2=(EditText)findViewById(R.id.EditText02);
        cb1=(CheckBox)findViewById(R.id.CheckBox01);
        b1=(Button)findViewById(R.id.Button01);
        b2=(Button)findViewById(R.id.Button02);
       
        myEdit1.setOnKeyListener(new OnKeyListener()
  {
   
   public boolean onKey(View v, int keyCode, KeyEvent event)
   {
    // TODO Auto-generated method stub
    myEdit1.setText("");
    return false;
   }
  });
       
        myEdit2.setOnKeyListener(new OnKeyListener()
  {
   
   public boolean onKey(View v, int keyCode, KeyEvent event)
   {
    // TODO Auto-generated method stub
    myEdit2.setText("");
    return false;
   }
  });
        myEdit1.setOnFocusChangeListener(new OnFocusChangeListener()
  {
   
   public void onFocusChange(View v, boolean hasFocus)
   {
    // TODO Auto-generated method stub
    Toast.makeText(getApplicationContext(), myEdit1.getText(),Toast.LENGTH_LONG );
   }
  });
        myEdit2.setOnFocusChangeListener(new OnFocusChangeListener()
  {
   
   public void onFocusChange(View v, boolean hasFocus)
   {
    // TODO Auto-generated method stub
    Toast.makeText(getApplicationContext(), myEdit1.getText(), Toast.LENGTH_LONG);
    
   }
  });
       
        cb1.setOnCheckedChangeListener(new OnCheckedChangeListener()
  {
   
   public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
   {
    // TODO Auto-generated method stub
    Toast.makeText(getApplicationContext(), cb1.isChecked()+"", Toast.LENGTH_LONG);
   }
  });
        b1.setOnClickListener(new OnClickListener()
  {
   
   public void onClick(View v)
   {
    // TODO Auto-generated method stub
    Toast.makeText(getApplicationContext(), b1.getText(), Toast.LENGTH_LONG);
   }
  });
  b2.setOnClickListener(new OnClickListener()
  {
   
   public void onClick(View v)
   {
    // TODO Auto-generated method stub
    Toast.makeText(getApplicationContext(), b2.getText(), Toast.LENGTH_LONG);
   }
  });
    }
}
       

·····························XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TableLayout
 android:id="@+id/TableLayout01"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content">
 <TableRow >
  <TextView
  android:id="@+id/TextView01"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="用户名称"
  />
  <EditText
  android:id="@+id/EditText01"
  android:text="admin"
  android:layout_width="fill_parent"
  android:scrollHorizontally="true"
  />
 </TableRow>
 <TableRow >
 <TextView
 android:id="@+id/TextView02"
 android:text="用户密码"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 />
 <EditText
 android:id="@+id/EditText02"
 android:text="123"
 android:password="true"
 android:layout_width="fill_parent"
 android:scrollHorizontally="true"
 />
 </TableRow>
 
 <TableRow >
 <TextView
 android:id="@+id/TextView03"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:text="自动登录"
 />
 <CheckBox
 android:text="check"
 android:id="@+id/CheckBox01"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 />
 
 </TableRow>
 <TableRow android:gravity="right" >
  <Button
  android:id="@+id/Button01"
  android:text="登录"
  />
  <Button
  android:id="@+id/Button02"
  android:text="取消"
  /> 
 
 </TableRow>
 
 
 </TableLayout>
</LinearLayout>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值