zoukankan      html  css  js  c++  java
  • 按键——Button事件监听器

    button_1.setOnClickListener(new View.OnClickListener() {           
       @Override
       public void onClick(View v) {
          String button_1_content=button_1 .getText().toString();
               //获得按键的内容,读取的数据来自android:text              
         editText=(EditText)findViewById(R.id.editText);
      
         textContent=editText .getText().toString();
                   
         text=textContent +button_1_content;
       /*
       *这里文本的输出内容必须是textContent+button_1_content
       *如果只把button_1_content赋值给text,
       *那么在按下按键1时会清除之前文本框中输入的内容,只显示一个数字1
       **/
      editText.setText(text );  
      editText.setSelection(text .length());
       /*
       *setSelection()的作用是定位光标
       *该句话的意思是光标的位置为当前字符串长度的后一个位置
       *注意:不能将光标的位置定位在当前长度的后面,即          
       *editText.setSelection(text.length()+1),这样会闪退
       **/
  • 相关阅读:
    C语言 常用单词
    导航菜单
    css3中的过渡(transition)
    HTML CSS 常用英语单词
    css基础
    XHTML基础
    MongoDB作为windows服务来安装-2
    MongoDB安装成windows 服务
    .NET平台MongoDB下使用JobStore存储Quartz.Net的Job,Trigger数据
    C# mongodb 类库
  • 原文地址:https://www.cnblogs.com/yedushusheng/p/4333893.html
Copyright © 2011-2022 走看看