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

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

    1. <legend id='rySMR'><style id='rySMR'><dir id='rySMR'><q id='rySMR'></q></dir></style></legend>
    2. <small id='rySMR'></small><noframes id='rySMR'>

      1. EditText 自定義字符串格式

        EditText custom string formatting(EditText 自定義字符串格式)
      2. <small id='TR1s5'></small><noframes id='TR1s5'>

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

                  <bdo id='TR1s5'></bdo><ul id='TR1s5'></ul>
                  <legend id='TR1s5'><style id='TR1s5'><dir id='TR1s5'><q id='TR1s5'></q></dir></style></legend>

                  本文介紹了EditText 自定義字符串格式的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我搜索了與我的問題類似的每個問題,但沒有得到解決.我的問題是這樣的:

                  I searched every question similar to my problem but didn't get it working. My problem is this:

                  我想在輸入時格式化 EditText 中的字符串.格式如下(始終是 19 位數字):

                  I want to format a string in EditText while typing. The format is this (it's always a 19 digit number):

                  012345 01 0123456789 0

                  如您所見,我想在用戶輸入時添加空格.我知道我必須使用 TextWatcher 但我所做的一切都沒有得到我想要的.

                  As you can see I want to add spaces when they are needed while the user is typing. I know that I have to use the TextWatcher but everything I do I don't get what i want.

                  編輯:

                  這是我上次嘗試的代碼:

                  Here is the code of my last try:

                          @Override
                          public void afterTextChanged(Editable s) {
                             if(s.length() == 7 || s.length() == 10 || s.length() == 21){
                                  editText.removeTextChangedListener(this);
                                  String newValue;
                                  newValue= s.insert((s.length()-1), " ").toString();
                                  //Log.d("AFTER",newValue);
                                  editText.setText(newValue);
                                  editText.setSelection(newValue.length());
                                  editText.addTextChangedListener(this);
                              }
                          }
                  

                  推薦答案

                  給你.

                  ma??in.xml:

                  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent">
                  <EditText 
                      android:id="@+id/editText"   
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:digits="0123456789"
                      android:inputType="number" />
                  </LinearLayout>
                  

                  MainActivity.java:

                  public class MainActivity extends Activity {
                  
                      int textlength = 0;
                       EditText editText;
                  
                      @Override
                      protected void onCreate(Bundle savedInstanceState) {
                          super.onCreate(savedInstanceState);
                          setContentView(R.layout.activity_main);
                  
                  
                           editText = (EditText)findViewById(R.id.editText);
                  
                              editText.addTextChangedListener(new TextWatcher()
                              {
                  
                               public void afterTextChanged(Editable s)
                               {
                  
                               }
                  
                               public void beforeTextChanged(CharSequence s, int start,
                                int count, int after)
                               {
                  
                               }
                  
                               public void onTextChanged(CharSequence s, int start,
                                int before, int count)
                               {
                  
                  
                                String text = editText.getText().toString();
                            textlength = editText.getText().length();
                  
                            if(text.endsWith(" "))          
                                return;
                  
                            if(textlength == 7 || textlength == 10 || textlength == 21)
                            {
                              editText.setText(new StringBuilder(text).insert(text.length()-1, " ").toString());
                                editText.setSelection(editText.getText().length());
                            }
                  
                               }});
                  
                      }
                  }
                  

                  通過這種方式,我只是設法在特定間隔的數字之間添加空格.

                  In this way, I have just managed to add spaces between the digits at particular intervals.

                  注意:我在edittext中添加了額外的功能,這樣就只能輸入數字,同時默認只會彈出數字鍵盤.有關用戶輸入類型的更多信息,this 可能會對你有所幫助.

                  Note: I have added extra features to the edittext, so that only numbers can be entered and at the same time the number keyboard only pops up by default. For more on the way for the type of user inputs, this might help you.

                  這篇關于EditText 自定義字符串格式的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當前位置)
                  IllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 拋出的 IllegalArgumentException)
                  How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新一次?)
                  How to detect Location Provider ? GPS or Network Provider(如何檢測位置提供者?GPS 或網絡提供商)
                  Get current location during app launch(在應用啟動期間獲取當前位置)
                  locationManager.getLastKnownLocation() return null(locationManager.getLastKnownLocation() 返回 null)

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

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

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

                            主站蜘蛛池模板: 国产蜜臀| 亚洲精品免费视频 | 99热在线免费 | 国产精品成人免费 | 成人精品一区二区三区中文字幕 | 久久成人亚洲 | 久久久久久免费毛片精品 | 亚洲精品 在线播放 | 99热这里都是精品 | 男女在线免费观看 | 成人在线电影在线观看 | 最新av在线网址 | 国产成人免费网站 | 黄视频国产 | 自拍偷拍亚洲欧美 | 日韩一区二区在线播放 | 中文字幕第一页在线 | 日本淫视频 | 羞羞视频网站免费观看 | 亚洲精品中文字幕在线观看 | 精品日本久久久久久久久久 | 一区二区视频 | 国产精品高潮呻吟久久 | 免费观看一区二区三区毛片 | 日韩免费高清视频 | 视频在线观看亚洲 | 黄色三级免费 | 国产精品久久久久久 | 欧美性吧 | 精品久久久久久久久久久下田 | 日韩一区三区 | 亚洲成人免费视频 | 羞羞视频在线观免费观看 | 成人乱人乱一区二区三区软件 | 91久久精品一区二区二区 | 亚洲精品国产综合区久久久久久久 | 亚洲精品久久区二区三区蜜桃臀 | 午夜激情一区 | 午夜视频在线免费观看 | 精品国产久 | 在线免费亚洲视频 |