久久久久久久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中有內容,如何使用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并設置再次將該文本發送到 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);
                  }
                  

                  您應該使用 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;
                         }
                  
                      }
                  
                  }
                  

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

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

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 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>
                          • 主站蜘蛛池模板: 99在线免费观看视频 | 日日操av | 99国产精品久久久久老师 | 国产中文字幕亚洲 | www.夜夜骑 | 一区二区三区在线看 | 四虎成人精品永久免费av九九 | 免费看黄色小视频 | 精品久久视频 | 五月天综合影院 | 亚洲一区二区国产 | 日本粉嫩一区二区三区视频 | 最新超碰| 国产美女特级嫩嫩嫩bbb片 | 亚洲欧美一区二区三区1000 | 91网站在线观看视频 | 成人在线视频看看 | 精品国产区 | 97色在线视频 | www97影院| 91佛爷在线观看 | 精品一区二区三区91 | 婷婷综合久久 | 亚洲三区在线 | 欧美一区二区三区在线 | 日一日操一操 | 久在线 | 成人a免费 | 中文字幕一区二区三区四区五区 | 日韩成人性视频 | 亚洲成人免费av | 欧美三级在线 | 99精品国产一区二区三区 | 在线免费视频一区 | 人人草人人干 | 毛片网站在线观看 | 国产九九精品视频 | 国产一区二区精品在线观看 | 女同久久 | 99爱在线观看 | 国产分类视频 |