android各种控件的事件监听及举例

来源:互联网 发布:python硬件编程 编辑:程序博客网 时间:2024/05/22 04:56

下面是各种常用控件的事件监听的使用

①EditText(编辑框)的事件监听---OnKeyListener

②RadioGroup、RadioButton(单选按钮)的事件监听---OnCheckedChangeListener

③CheckBox(多选按钮)的事件监听---OnCheckedChangeListener

④Spinner(下拉列表)的事件监听---OnItemSelectedListener

⑤Menu(菜单)的事件处理---onMenuItemSelected

⑥Dialog(对话框)的事件监听---DialogInterface.OnClickListener()

至于Button的事件监听,可以在上一篇博客中看到。

第一个例子:EditText的事件监听


[java] view plaincopyprint?
  1. <SPAN style="FONT-SIZE: 18px">package org.hualang.eventtest2;  
  2.   
  3. import android.app.Activity;  
  4. import android.os.Bundle;  
  5. import android.view.KeyEvent;  
  6. import android.view.View;  
  7. import android.widget.EditText;  
  8. import android.widget.TextView;  
  9.   
  10. public class EventTest2 extends Activity {  
  11.     /** Called when the activity is first created. */  
  12.     private TextView mytext;  
  13.     private EditText edittext;  
  14.     @Override  
  15.     public void onCreate(Bundle savedInstanceState) {  
  16.         super.onCreate(savedInstanceState);  
  17.         setContentView(R.layout.main);  
  18.         mytext = (TextView)findViewById(R.id.mytext);  
  19.         edittext = (EditText)findViewById(R.id.edittext);  
  20.         /** 
  21.          * 设置当EditText为空,则提示“请输入账号” 
  22.          * 在配置文件main.xml中可以用android:hint="请输入账号"来实现 
  23.          */  
  24.         edittext.setHint("请输入账号");  
  25.         //下面为EditText事件监听  
  26.         edittext.setOnKeyListener(new EditText.OnKeyListener()  
  27.         {  
  28.   
  29.             @Override  
  30.             public boolean onKey(View arg0, int arg1, KeyEvent arg2) {  
  31.                 //得到文字,显示在TextView中  
  32.                 mytext.setText("内容:"+edittext.getText().toString());  
  33.                 return false;  
  34.             }  
  35.               
  36.         });  
  37.     }  
  38. }</SPAN>  


main.xml

[java] view plaincopyprint?
  1. <SPAN style="FONT-SIZE: 18px"><?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7. <TextView    
  8.     android:layout_width="fill_parent"   
  9.     android:layout_height="wrap_content"   
  10.     android:id="@+id/mytext"  
  11.     />  
  12. <EditText  
  13.     android:id="@+id/edittext"  
  14.     android:layout_width="fill_parent"  
  15.     android:layout_height="wrap_content"  
  16.     android:textSize="10pt"  
  17. />  
  18. </LinearLayout></SPAN>  

第二个例子:单选按钮的事件监听处理

[java] view plaincopyprint?
  1. <SPAN style="COLOR: #000000">package org.hualang.eventtest;  
  2.   
  3. import android.app.Activity;  
  4. import android.os.Bundle;  
  5. import android.view.Gravity;  
  6. import android.widget.RadioButton;  
  7. import android.widget.RadioGroup;  
  8. import android.widget.Toast;  
  9.   
  10. public class EventTest3 extends Activity {  
  11.     /** Called when the activity is first created. */  
  12.     private RadioGroup group;  
  13.     private RadioButton radio1,radio2,radio3,radio4;  
  14.     @Override  
  15.     public void onCreate(Bundle savedInstanceState) {  
  16.         super.onCreate(savedInstanceState);  
  17.         setContentView(R.layout.main);  
  18.           
  19.         group = (RadioGroup)findViewById(R.id.radiogroup1);  
  20.         radio1 = (RadioButton)findViewById(R.id.button1);  
  21.         radio2 = (RadioButton)findViewById(R.id.button2);  
  22.         radio3 = (RadioButton)findViewById(R.id.button3);  
  23.         radio4 = (RadioButton)findViewById(R.id.button4);  
  24.           
  25.         group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {  
  26.               
  27.             @Override  
  28.             public void onCheckedChanged(RadioGroup group, int checkedId) {  
  29.                 // TODO Auto-generated method stub  
  30.                 if (checkedId == radio2.getId())  
  31.                 {  
  32.                     showMessage("正确答案:" + radio2.getText()+",恭喜你,答对了");  
  33.                 }  
  34.                 else  
  35.                 {  
  36.                     showMessage("对不起,虽然很多,但不是公认的最多");  
  37.                 }  
  38.             }  
  39.         });  
  40.     }  
  41.     public void showMessage(String str)  
  42.     {  
  43.         Toast toast = Toast.makeText(this, str, Toast.LENGTH_SHORT);  
  44.         toast.setGravity(Gravity.TOP, 0220);  
  45.         toast.show();  
  46.     }  
  47. }  
  48. <STRONG><SPAN style="FONT-SIZE: 24px; COLOR: #ff0000">main.xml</SPAN>  
  49. </STRONG></SPAN><PRE class=java name="code"><?xml version="1.0" encoding="utf-8"?>  
  50. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  51.     android:orientation="vertical"  
  52.     android:layout_width="fill_parent"  
  53.     android:layout_height="fill_parent"  
  54.     >  
  55.     <TextView  
  56.         android:id="@+id/mytextview"  
  57.         android:layout_width="fill_parent"  
  58.         android:layout_height="wrap_content"  
  59.         android:text="哪个城市的美女最多?"  
  60.     />  
  61.     <RadioGroup  
  62.         android:id="@+id/radiogroup1"  
  63.         android:layout_width="wrap_content"  
  64.         android:layout_height="wrap_content"  
  65.         android:orientation="vertical"  
  66.     >  
  67.         <RadioButton  
  68.             android:id="@+id/button1"  
  69.             android:layout_width="wrap_content"  
  70.             android:layout_height="wrap_content"  
  71.             android:text="杭州"  
  72.         />  
  73.         <RadioButton  
  74.             android:id="@+id/button2"  
  75.             android:layout_width="wrap_content"  
  76.             android:layout_height="wrap_content"  
  77.             android:text="重庆"  
  78.         />  
  79.         <RadioButton  
  80.             android:id="@+id/button3"  
  81.             android:layout_width="wrap_content"  
  82.             android:layout_height="wrap_content"  
  83.             android:text="成都"  
  84.         />  
  85.         <RadioButton  
  86.             android:id="@+id/button4"  
  87.             android:layout_width="wrap_content"  
  88.             android:layout_height="wrap_content"  
  89.             android:text="香港"  
  90.         />  
  91.     </RadioGroup>  
  92. </LinearLayout>  
  93. <STRONG><SPAN style="COLOR: #ff0000">第三个例子:复选框的事件处理</SPAN></STRONG>  
  94. package org.hualang.eventtest4;  
  95.   
  96. import android.app.Activity;  
  97. import android.os.Bundle;  
  98. import android.view.Gravity;  
  99. import android.view.View;  
  100. import android.widget.Button;  
  101. import android.widget.CheckBox;  
  102. import android.widget.CompoundButton;  
  103. import android.widget.CompoundButton.OnCheckedChangeListener;  
  104. import android.widget.Toast;  
  105.   
  106. public class EventTest4 extends Activity {  
  107.     /** Called when the activity is first created. */  
  108.     private CheckBox ch1,ch2,ch3,ch4,ch5;  
  109.     private Button mybutton;  
  110.     @Override  
  111.     public void onCreate(Bundle savedInstanceState) {  
  112.         super.onCreate(savedInstanceState);  
  113.         setContentView(R.layout.main);  
  114.           
  115.         mybutton = (Button)findViewById(R.id.mybutton);  
  116.         ch1 = (CheckBox)findViewById(R.id.check1);  
  117.         ch2 = (CheckBox)findViewById(R.id.check2);  
  118.         ch3 = (CheckBox)findViewById(R.id.check3);  
  119.         ch4 = (CheckBox)findViewById(R.id.check4);  
  120.         ch5 = (CheckBox)findViewById(R.id.check5);  
  121.           
  122.         ch1.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener()  
  123.         {  
  124.   
  125.             @Override  
  126.             public void onCheckedChanged(CompoundButton arg0, boolean arg1) {  
  127.                 // TODO Auto-generated method stub  
  128.                 if(ch1.isChecked())  
  129.                 {  
  130.                     showMessage("你选择了"+ch1.getText());  
  131.                 }  
  132.             }  
  133.               
  134.         });  
  135.         ch2.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener()  
  136.         {  
  137.   
  138.             @Override  
  139.             public void onCheckedChanged(CompoundButton arg0, boolean arg1) {  
  140.                 // TODO Auto-generated method stub  
  141.                 if(ch3.isChecked())  
  142.                 {  
  143.                     showMessage("你选择了"+ch2.getText());  
  144.                 }  
  145.             }  
  146.               
  147.         });  
  148.         ch3.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener()  
  149.         {  
  150.   
  151.             @Override  
  152.             public void onCheckedChanged(CompoundButton arg0, boolean arg1) {  
  153.                 // TODO Auto-generated method stub  
  154.                 if(ch3.isChecked())  
  155.                 {  
  156.                     showMessage("你选择了"+ch3.getText());  
  157.                 }  
  158.             }  
  159.               
  160.         });  
  161.         ch4.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener()  
  162.         {  
  163.   
  164.             @Override  
  165.             public void onCheckedChanged(CompoundButton arg0, boolean arg1) {  
  166.                 // TODO Auto-generated method stub  
  167.                 if(ch4.isChecked())  
  168.                 {  
  169.                     showMessage("你选择了"+ch4.getText());  
  170.                 }  
  171.             }  
  172.               
  173.         });  
  174.         ch5.setOnCheckedChangeListener(new CheckBox.OnCheckedChangeListener()  
  175.         {  
  176.   
  177.             @Override  
  178.             public void onCheckedChanged(CompoundButton arg0, boolean arg1) {  
  179.                 // TODO Auto-generated method stub  
  180.                 if(ch5.isChecked())  
  181.                 {  
  182.                     showMessage("你选择了"+ch5.getText());  
  183.                 }  
  184.             }  
  185.               
  186.         });  
  187.           
  188.         mybutton.setOnClickListener(new Button.OnClickListener()  
  189.         {  
  190.   
  191.             @Override  
  192.             public void onClick(View arg0) {  
  193.                 // TODO Auto-generated method stub  
  194.                 int num = 0;  
  195.                 if(ch1.isChecked())  
  196.                 {  
  197.                     num++;  
  198.                 }  
  199.                 if(ch2.isChecked())  
  200.                 {  
  201.                     num++;  
  202.                 }  
  203.                 if(ch3.isChecked())  
  204.                 {  
  205.                     num++;  
  206.                 }  
  207.                 if(ch4.isChecked())  
  208.                 {  
  209.                     num++;  
  210.                 }  
  211.                 if(ch5.isChecked())  
  212.                 {  
  213.                     num++;  
  214.                 }  
  215.                   
  216.                 showMessage("谢谢参与,您一共选择了"+num+"项");  
  217.                   
  218.             }  
  219.               
  220.         });  
  221.     }  
  222.       
  223.   
  224.       
  225.     public void showMessage(String str)  
  226.     {  
  227.         Toast toast = Toast.makeText(this, str, Toast.LENGTH_SHORT);  
  228.         toast.setGravity(Gravity.TOP, 0220);  
  229.         toast.show();  
  230.     }  
  231. }  
  232. <SPAN style="FONT-SIZE: 24px; COLOR: #ff0000">main.xml</SPAN>  
  233. <?xml version="1.0" encoding="utf-8"?>  
  234. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  235.     android:orientation="vertical"  
  236.     android:layout_width="fill_parent"  
  237.     android:layout_height="fill_parent"  
  238.     >  
  239.     <TextView    
  240.         android:layout_width="fill_parent"   
  241.         android:layout_height="wrap_content"   
  242.         android:text="你喜欢哪些智能手机系统"  
  243.         />  
  244.     <CheckBox  
  245.         android:id="@+id/check1"  
  246.         android:layout_width="fill_parent"  
  247.         android:layout_height="wrap_content"  
  248.         android:text="苹果 ios"  
  249.     />  
  250.     <CheckBox  
  251.         android:id="@+id/check2"  
  252.         android:layout_width="fill_parent"  
  253.         android:layout_height="wrap_content"  
  254.         android:text="谷歌 Android"  
  255.     />  
  256.     <CheckBox  
  257.         android:id="@+id/check3"  
  258.         android:layout_width="fill_parent"  
  259.         android:layout_height="wrap_content"  
  260.         android:text="RIM BlackBerry"  
  261.     />  
  262.     <CheckBox  
  263.         android:id="@+id/check4"  
  264.         android:layout_width="fill_parent"  
  265.         android:layout_height="wrap_content"  
  266.         android:text="微软 Windows phone 7"  
  267.     />  
  268.     <CheckBox  
  269.         android:id="@+id/check5"  
  270.         android:layout_width="fill_parent"  
  271.         android:layout_height="wrap_content"  
  272.         android:text="诺基亚 symbian"  
  273.     />  
  274.     <Button  
  275.         android:id="@+id/mybutton"  
  276.         android:layout_width="fill_parent"  
  277.         android:layout_height="wrap_content"  
  278.         android:text="确定"  
  279.     />  
  280.   
  281. </LinearLayout>  
  282.   
  283. <SPAN style="COLOR: #ff0000"><STRONG>第四个例子:Spinner下拉菜单的事件处理</STRONG></SPAN>  
  284. package org.hualang.eventtest5;  
  285.   
  286. import android.app.Activity;     
  287. import android.os.Bundle;     
  288. import android.view.View;     
  289. import android.widget.AdapterView;     
  290. import android.widget.ArrayAdapter;     
  291. import android.widget.Spinner;     
  292. import android.widget.TextView;     
  293.     
  294. public class EventTest5 extends Activity {     
  295.     /** Called when the activity is first created. */    
  296.     private static final String[] citys={"杭州","北京","成都","大连","深圳","南京"};     
  297.     private TextView text;     
  298.     private Spinner spinner;     
  299.     private ArrayAdapter<String> adapter;     
  300.     @Override    
  301.     public void onCreate(Bundle savedInstanceState) {     
  302.         super.onCreate(savedInstanceState);     
  303.         setContentView(R.layout.main);     
  304.         text=(TextView)findViewById(R.id.text);     
  305.         spinner=(Spinner)findViewById(R.id.spinner);     
  306.              
  307.         //将可选内容与ArrayAdapter连接     
  308.         adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,citys);     
  309.         //设置下拉列表风格     
  310.         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);     
  311.         //将adapter添加到spinner中     
  312.         spinner.setAdapter(adapter);     
  313.         //添加Spinner事件监听     
  314.         spinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener()     
  315.         {     
  316.     
  317.             @Override    
  318.             public void onItemSelected(AdapterView<?> arg0, View arg1,     
  319.                     int arg2, long arg3) {     
  320.                 // TODO Auto-generated method stub     
  321.                 text.setText("你所在的城市是:"+citys[arg2]);     
  322.                 //设置显示当前选择的项     
  323.                 arg0.setVisibility(View.VISIBLE);     
  324.             }     
  325.     
  326.             @Override    
  327.             public void onNothingSelected(AdapterView<?> arg0) {     
  328.                 // TODO Auto-generated method stub     
  329.                      
  330.             }     
  331.                  
  332.         });     
  333.     }     
  334. }    
  335.   
  336. <SPAN style="FONT-SIZE: 24px; COLOR: #ff0000">main.xml</SPAN>  
  337. <?xml version="1.0" encoding="utf-8"?>     
  338. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
  339.     android:orientation="vertical"    
  340.     android:layout_width="fill_parent"    
  341.     android:layout_height="fill_parent"    
  342.     >     
  343. <TextView       
  344.     android:id="@+id/text"    
  345.     android:layout_width="fill_parent"      
  346.     android:layout_height="wrap_content"      
  347.     android:text="您所在的城市"    
  348.     />     
  349. <Spinner     
  350.     android:id="@+id/spinner"    
  351.     android:layout_width="wrap_content"    
  352.     android:layout_height="wrap_content"    
  353.     android:layout_centerHorizontal="true"    
  354. />     
  355. </LinearLayout>  
  356.   
  357. <STRONG><SPAN style="COLOR: #ff0000">第五个例子:Menu(菜单)的事件处理</SPAN></STRONG>   
  358. </PRE><BR>  
  359. <PRE class=java name="code">package org.hualang.eventtest6;  
  360.   
  361. import android.app.Activity;  
  362. import android.os.Bundle;  
  363. import android.view.Menu;  
  364. import android.view.MenuInflater;  
  365. import android.view.MenuItem;  
  366. import android.widget.Toast;  
  367.   
  368. public class EventTest6 extends Activity {  
  369.     /** Called when the activity is first created. */  
  370.     @Override  
  371.     public void onCreate(Bundle savedInstanceState) {  
  372.         super.onCreate(savedInstanceState);  
  373.         setContentView(R.layout.main);  
  374.     }  
  375.   
  376.     @Override  
  377.     public boolean onCreateOptionsMenu(Menu menu) {  
  378.         // TODO Auto-generated method stub  
  379.         MenuInflater inflater = getMenuInflater();  
  380.         //设置menu界面为res/menu/menu.xml  
  381.         inflater.inflate(R.menu.menu, menu);  
  382.         return true;  
  383.     }  
  384.   
  385.     @Override  
  386.     public boolean onMenuItemSelected(int featureId, MenuItem item) {  
  387.         //得到当前选中的MenuItem的ID  
  388.         int itemId = item.getItemId();  
  389.         switch(itemId)  
  390.         {  
  391.         case R.id.apple:  
  392.             Toast toast = Toast.makeText(this"这是苹果", Toast.LENGTH_SHORT);  
  393.             toast.show();  
  394.             break;  
  395.         case R.id.banana:  
  396.             Toast toast2 = Toast.makeText(this"这是香蕉", Toast.LENGTH_SHORT);  
  397.             toast2.show();  
  398.             break;  
  399.         case R.id.exit:  
  400.             EventTest6.this.finish();  
  401.             break;  
  402.         }  
  403.         return true;  
  404.     }  
  405.       
  406.       
  407. }</PRE><BR>  
  408. <SPAN style="FONT-SIZE: 24px; COLOR: #ff0000">main.xml</SPAN><BR>  
  409. <?xml version="1.0" encoding="utf-8"?><BR>  
  410. <menu xmlns:android="http://schemas.android.com/apk/res/android"><BR>  
  411.     <item android:id="@+id/apple"<BR>  
  412.         android:title="苹果"<BR>  
  413.     /><BR>  
  414.     <item android:id="@+id/banana"<BR>  
  415.         android:title="香蕉"<BR>  
  416.         /><BR>  
  417.     <item android:id="@+id/exit"<BR>  
  418.         android:title="退出"<BR>  
  419.         /><BR>  
  420. </menu><BR>  
  421. <SPAN style="COLOR: #ff0000"><STRONG>第六个例子:对话框的事件处理</STRONG></SPAN><BR>  
  422. package org.hualang.dialog;<BR>  
  423. <BR>  
  424. import android.app.Activity;<BR>  
  425. import android.app.AlertDialog;<BR>  
  426. import android.app.Dialog;<BR>  
  427. import android.app.ProgressDialog;<BR>  
  428. import android.content.DialogInterface;<BR>  
  429. import android.content.DialogInterface.OnClickListener;<BR>  
  430. import android.os.Bundle;<BR>  
  431. import android.view.LayoutInflater;<BR>  
  432. import android.view.View;<BR>  
  433. <BR>  
  434. public class MainActivity extends Activity {<BR>  
  435.     /** Called when the activity is first created. */<BR>  
  436.     ProgressDialog myDialog;<BR>  
  437.     @Override<BR>  
  438.     public void onCreate(Bundle savedInstanceState) {<BR>  
  439.         super.onCreate(savedInstanceState);<BR>  
  440.         setContentView(R.layout.main);<BR>  
  441.         <BR>  
  442.         Dialog dialog = new AlertDialog.Builder(MainActivity.this)<BR>  
  443.         .setTitle("登录提示")<BR>  
  444.         .setMessage("这里需要登录")<BR>  
  445.         .setPositiveButton("确定"new DialogInterface.OnClickListener() {<BR>  
  446.             <BR>  
  447.             @Override<BR>  
  448.             public void onClick(DialogInterface dialog, int which) {<BR>  
  449.                 // TODO Auto-generated method stub<BR>  
  450.                 LayoutInflater factory = LayoutInflater.from(MainActivity.this);<BR>  
  451.                 final View DialogView = factory.inflate(R.layout.dialog, null);<BR>  
  452.                 AlertDialog dlg = new AlertDialog.Builder(MainActivity.this)<BR>  
  453.                 .setTitle("登录框")<BR>  
  454.                 .setView(DialogView)<BR>  
  455.                 .setPositiveButton("确定"new DialogInterface.OnClickListener() {<BR>  
  456.                     <BR>  
  457.                     @Override<BR>  
  458.                     public void onClick(DialogInterface dialog, int whichButton) {<BR>  
  459.                         // TODO Auto-generated method stub<BR>  
  460.                         myDialog = ProgressDialog.show(MainActivity.this"请等待...""正在为你登录"true);<BR>  
  461.                         new Thread()<BR>  
  462.                         {<BR>  
  463.                             public void run()<BR>  
  464.                             {<BR>  
  465.                                 try<BR>  
  466.                                 {<BR>  
  467.                                     sleep(3000);<BR>  
  468.                                 }catch(Exception e)<BR>  
  469.                                 {<BR>  
  470.                                     e.printStackTrace();<BR>  
  471.                                 }finally<BR>  
  472.                                 {<BR>  
  473.                                     myDialog.dismiss();<BR>  
  474.                                 }<BR>  
  475.                             }<BR>  
  476.                         }.start();<BR>  
  477.                     }<BR>  
  478.                 }).setNegativeButton("取消",<BR>  
  479.                         new DialogInterface.OnClickListener() {<BR>  
  480.                             <BR>  
  481.                             @Override<BR>  
  482.                             public void onClick(DialogInterface dialog, int which) {<BR>  
  483.                                 // TODO Auto-generated method stub<BR>  
  484.                                 MainActivity.this.finish();<BR>  
  485.                             }<BR>  
  486.                         }).create();<BR>  
  487.                 dlg.show();<BR>  
  488.             }<BR>  
  489.         }).setNeutralButton("退出"new DialogInterface.OnClickListener() {<BR>  
  490.             <BR>  
  491.             @Override<BR>  
  492.             public void onClick(DialogInterface dialog, int which) {<BR>  
  493.                 // TODO Auto-generated method stub<BR>  
  494.                 MainActivity.this.finish();<BR>  
  495.             }<BR>  
  496.         }).create();<BR>  
  497.         dialog.show();<BR>  
  498.     <BR>  
  499.     }<BR>  
  500. }<BR>  
  501. <SPAN style="FONT-SIZE: 24px; COLOR: #ff0000">xml文件</SPAN><BR>  
  502. <?xml version="1.0" encoding="utf-8"?><BR>  
  503. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<BR>  
  504.     android:orientation="vertical"<BR>  
  505.     android:layout_width="fill_parent"<BR>  
  506.     android:layout_height="fill_parent"<BR>  
  507.     ><BR>  
  508.     <TextView  <BR>  
  509.         android:id="@+id/username"<BR>  
  510.         android:layout_width="wrap_content" <BR>  
  511.         android:layout_height="wrap_content"<BR>  
  512.         android:layout_marginLeft="20dip"<BR>  
  513.         android:layout_marginRight="20dip" <BR>  
  514.         android:text="账号"<BR>  
  515.         android:gravity="left"<BR>  
  516.         android:textAppearance="?android:attr/textAppearanceMedium"<BR>  
  517.     /><BR>  
  518.       <EditText<BR>  
  519.           android:id="@+id/myusername"<BR>  
  520.           android:layout_height="wrap_content"<BR>  
  521.           android:layout_width="fill_parent"<BR>  
  522.           android:layout_marginLeft="20dip"<BR>  
  523.           android:layout_marginRight="20dip"<BR>  
  524.           android:scrollHorizontally="true"<BR>  
  525.           android:autoText="false"<BR>  
  526.           android:capitalize="none"<BR>  
  527.           android:gravity="fill_horizontal"<BR>  
  528.           android:textAppearance="?android:attr/textAppearanceMedium"<BR>  
  529.       /><BR>  
  530.       <TextView<BR>  
  531.           android:id="@+id/password"<BR>  
  532.           android:layout_width="fill_parent"<BR>  
  533.           android:layout_height="wrap_content"<BR>  
  534.           android:layout_marginLeft="20dip"<BR>  
  535.           android:layout_marginRight="20dip"<BR>  
  536.           android:text="密码"<BR>  
  537.           android:gravity="left"<BR>  
  538.           android:textAppearance="?android:attr/textAppearanceMedium"<BR>  
  539.       /><BR>  
  540.       <EditText<BR>  
  541.           android:id="@+id/mypassword"<BR>  
  542.           android:layout_width="fill_parent"<BR>  
  543.           android:layout_height="wrap_content"<BR>  
  544.           android:layout_marginLeft="20dip"<BR>  
  545.           android:layout_marginRight="20dip"<BR>  
  546.           android:scrollHorizontally="true"<BR>  
  547.           android:autoText="false"<BR>  
  548.           android:capitalize="none"<BR>  
  549.           android:gravity="fill_horizontal"<BR>  
  550.           android:password="true"<BR>  
  551.       /><BR>  
  552. </LinearLayout><BR>  
  553. <P></P>  
  554. <PRE></PRE>  
  555. <STRONG><SPAN style="COLOR: #ff0000"><BR>  
  556. <BR>  
  557. </SPAN></STRONG>  
  558. <P></P>  
  559. <P></P>  
  560. <P><SPAN style="FONT-SIZE: 18px"><BR>  
  561. </SPAN></P>  
  562. <P><SPAN style="FONT-SIZE: 18px"><BR>  
  563. </SPAN></P>  
  564. <SPAN style="FONT-SIZE: 18px"><BR>  
  565. </SPAN><BR>