久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <legend id='GfWdi'><style id='GfWdi'><dir id='GfWdi'><q id='GfWdi'></q></dir></style></legend>

  • <i id='GfWdi'><tr id='GfWdi'><dt id='GfWdi'><q id='GfWdi'><span id='GfWdi'><b id='GfWdi'><form id='GfWdi'><ins id='GfWdi'></ins><ul id='GfWdi'></ul><sub id='GfWdi'></sub></form><legend id='GfWdi'></legend><bdo id='GfWdi'><pre id='GfWdi'><center id='GfWdi'></center></pre></bdo></b><th id='GfWdi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GfWdi'><tfoot id='GfWdi'></tfoot><dl id='GfWdi'><fieldset id='GfWdi'></fieldset></dl></div>

        <tfoot id='GfWdi'></tfoot>

        <small id='GfWdi'></small><noframes id='GfWdi'>

        • <bdo id='GfWdi'></bdo><ul id='GfWdi'></ul>

        如何使用按鈕從 EditText 中刪除最后一個字母?

        How to delete the last letter from EditText with button?(如何使用按鈕從 EditText 中刪除最后一個字母?)

          <i id='WnW5T'><tr id='WnW5T'><dt id='WnW5T'><q id='WnW5T'><span id='WnW5T'><b id='WnW5T'><form id='WnW5T'><ins id='WnW5T'></ins><ul id='WnW5T'></ul><sub id='WnW5T'></sub></form><legend id='WnW5T'></legend><bdo id='WnW5T'><pre id='WnW5T'><center id='WnW5T'></center></pre></bdo></b><th id='WnW5T'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WnW5T'><tfoot id='WnW5T'></tfoot><dl id='WnW5T'><fieldset id='WnW5T'></fieldset></dl></div>

              <tbody id='WnW5T'></tbody>
              • <bdo id='WnW5T'></bdo><ul id='WnW5T'></ul>
                <tfoot id='WnW5T'></tfoot>
              • <legend id='WnW5T'><style id='WnW5T'><dir id='WnW5T'><q id='WnW5T'></q></dir></style></legend>

                  <small id='WnW5T'></small><noframes id='WnW5T'>

                1. 本文介紹了如何使用按鈕從 EditText 中刪除最后一個字母?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我必須將 A 和 B 寫入編輯文本的按鈕.如果edittext中有內(nèi)容,如何使用Del"按鈕刪除最后一個字母?

                  I have to buttons that writes A and B to an edittext. If there is something in the edittext how can I delete the last letters with the "Del" button ?

                  我的布局:

                  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:tools="http://schemas.android.com/tools"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  tools:context=".MainActivity" >
                  
                  <Button
                  android:id="@+id/buttonb"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:layout_alignParentLeft="true"
                  android:layout_below="@+id/buttona"
                  android:text="@string/buttonb"
                  android:textSize="50sp"
                  android:textStyle="bold" />
                  
                  <Button
                  android:id="@+id/buttona"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:layout_alignParentLeft="true"
                  android:layout_centerVertical="true"
                  android:text="@string/buttona"
                  android:textSize="50sp"
                  android:textStyle="bold" />
                  
                  <Button
                  android:id="@+id/buttondel"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:layout_alignParentRight="true"
                  android:layout_centerVertical="true"
                  android:text="@string/buttondel"
                  android:textSize="50sp"
                  android:textStyle="bold" />
                  
                  <EditText
                  android:id="@+id/editText"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_alignParentLeft="true"
                  android:layout_alignParentTop="true"
                  android:ems="58"
                  android:textSize="20sp"
                  android:textStyle="bold"
                  android:inputType="text" >
                  
                  <requestFocus />
                  </EditText>
                  
                  </RelativeLayout>
                  

                  還有我的 java:

                  package com.koostamas.keyboard;
                  
                  import android.os.Bundle;
                  import android.view.View;
                  import android.view.View.OnClickListener;
                  import android.widget.Button;
                  import android.widget.EditText;
                  import android.app.Activity;
                  
                  public class MainActivity extends Activity implements OnClickListener {
                  
                  Button buttona, buttondel;
                  EditText editText;
                  
                  @Override
                  protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
                  setContentView(R.layout.activity_main);
                  editText = (EditText) findViewById(R.id.editText);
                  
                  addListenerOnButton();
                  }
                  
                  
                     public void addListenerOnButton() {
                  
                  buttona = (Button) findViewById(R.id.buttona);
                  buttona.setOnClickListener(this);
                  
                  buttondel = (Button) findViewById(R.id.buttonb);
                  buttondel.setOnClickListener(this);
                  
                  
                     }
                  
                  public void onClick(View v) {
                  switch(v.getId()) {
                      case R.id.buttona : 
                          Button buttona = (Button)v;
                      editText.setText(editText.getText().toString()+buttona.getText().toString());
                          break;
                      case R.id.buttondel :
                          String text = editText.getText().toString();
                          editText.setText(text.substring(0, text.length() - 1));
                          break;
                  
                  
                  
                  }
                  
                  }
                  
                  
                  }
                  

                  我該怎么做?提前感謝客棧.

                  How can I do it? Thanks inn advance.

                  推薦答案

                  你可以檢索EditText的文本,然后獲取該文本的sub-string并設(shè)置再次將該文本發(fā)送到 EditText 如下...

                  You can retrieve the text of EditText and then get the sub-string of that text and set again that text to EditText as below...

                  String text = editText.getText().toString();
                  editText.setText(text.substring(0, text.length() - 1));
                  

                  你也可以使用下面的過程....這樣會更有效率.

                  You can also use following procedure....it will be more efficient.

                  int length = editText.getText().length();
                  if (length > 0) {
                      editText.getText().delete(length - 1, length);
                  }
                  

                  您應(yīng)該使用 switch-case 如下...并按如下方式處理您的 nuttondel onclick()...

                  You should use switch-case as below...and handle your nuttondel onclick() as follows...

                  public class MainActivity extends Activity implements OnClickListener {
                  
                      Button buttona, buttonb;
                      Button buttonDel;
                      EditText editText;
                  
                      @Override
                      protected void onCreate(Bundle savedInstanceState) {
                  
                          super.onCreate(savedInstanceState);
                          setContentView(R.layout.activity_main);
                          editText = (EditText) findViewById(R.id.editText);
                  
                          addListenerOnButton();
                  
                      }
                  
                  
                     public void addListenerOnButton() {
                  
                      buttona = (Button) findViewById(R.id.buttona);
                      buttona.setOnClickListener(this);
                  
                      buttonb = (Button) findViewById(R.id.buttonb);
                      buttonb.setOnClickListener(this);
                  
                      buttonDel = (Button) findViewById(R.id.buttondel);
                      buttonDel.setOnClickListener(this);
                  
                  
                     }
                  
                      public void onClick(View v) {
                  
                         switch(v.getId()) {
                  
                            case R.id.buttona:
                                        editText.setText(editText.getText().toString()+buttona.getText().toString());
                                break;
                  
                            case R.id.buttonb:
                                        editText.setText(editText.getText().toString()+buttonb.getText().toString());
                                break;
                  
                            case R.id.buttondel:
                  
                                int length = editText.getText().length();
                                if (length > 0) {
                                    editText.getText().delete(length - 1, length);
                                }
                                break;
                         }
                  
                      }
                  
                  }
                  

                  這篇關(guān)于如何使用按鈕從 EditText 中刪除最后一個字母?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個隨機打亂數(shù)字的 int 數(shù)組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲為 int?)

                2. <tfoot id='Olyrg'></tfoot>
                3. <legend id='Olyrg'><style id='Olyrg'><dir id='Olyrg'><q id='Olyrg'></q></dir></style></legend>

                      <i id='Olyrg'><tr id='Olyrg'><dt id='Olyrg'><q id='Olyrg'><span id='Olyrg'><b id='Olyrg'><form id='Olyrg'><ins id='Olyrg'></ins><ul id='Olyrg'></ul><sub id='Olyrg'></sub></form><legend id='Olyrg'></legend><bdo id='Olyrg'><pre id='Olyrg'><center id='Olyrg'></center></pre></bdo></b><th id='Olyrg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Olyrg'><tfoot id='Olyrg'></tfoot><dl id='Olyrg'><fieldset id='Olyrg'></fieldset></dl></div>

                      <small id='Olyrg'></small><noframes id='Olyrg'>

                        <tbody id='Olyrg'></tbody>

                            <bdo id='Olyrg'></bdo><ul id='Olyrg'></ul>
                          • 主站蜘蛛池模板: 国产高清在线精品 | 无码日韩精品一区二区免费 | 日本又色又爽又黄又高潮 | 亚洲激情视频在线 | www.亚洲视频.com | 青娱乐一区二区 | 91久久久久久久久久久 | 综合一区| 超碰人人爱 | 国产精品亚洲一区 | 免费人成在线观看网站 | 国产99久久| 日韩精品1区2区3区 国产精品国产成人国产三级 | 国产精品久久久久aaaa樱花 | 欧美在线观看一区 | 久久综合一区 | 在线国产一区二区 | 亚洲成人av | 免费日韩网站 | 亚洲区中文字幕 | 少妇久久久 | 国产午夜高清 | 精品久久久久久 | 日日摸日日碰夜夜爽2015电影 | 波多野结衣二区 | 日韩成人免费视频 | 国产精品激情小视频 | 99精品久久 | 久久国内 | 久久久久国产 | 男人的天堂在线视频 | 久久久五月天 | 日韩免费一区二区 | 免费观看www7722午夜电影 | 国产视频1| 欧美亚洲高清 | 夜夜骚视频 | 性色综合| 国产精品1区 | 日日干夜夜操天天操 | 韩国电影久久 |