久久久久久久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 自定義字符串格式的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我搜索了與我的問(wèn)題類似的每個(gè)問(wèn)題,但沒(méi)有得到解決.我的問(wèn)題是這樣的:

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

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

                  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

                  如您所見(jiàn),我想在用戶輸入時(shí)添加空格.我知道我必須使用 TextWatcher 但我所做的一切都沒(méi)有得到我想要的.

                  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());
                            }
                  
                               }});
                  
                      }
                  }
                  

                  通過(guò)這種方式,我只是設(shè)法在特定間隔的數(shù)字之間添加空格.

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

                  注意:我在edittext中添加了額外的功能,這樣就只能輸入數(shù)字,同時(shí)默認(rèn)只會(huì)彈出數(shù)字鍵盤.有關(guān)用戶輸入類型的更多信息,this 可能會(huì)對(duì)你有所幫助.

                  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.

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

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

                  相關(guān)文檔推薦

                  Get user#39;s current location using GPS(使用 GPS 獲取用戶的當(dāng)前位置)
                  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(如何檢測(cè)位置提供者?GPS 或網(wǎng)絡(luò)提供商)
                  Get current location during app launch(在應(yīng)用啟動(dòng)期間獲取當(dāng)前位置)
                  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>

                            主站蜘蛛池模板: 国产片一区二区三区 | 欧美一卡二卡在线 | 国产精品国产精品国产专区不卡 | 国产一区 | 日本网站免费在线观看 | 成人一级黄色毛片 | 成人免费视频播放 | 久久久久久一区 | 91精品一区 | 亚洲综合大片69999 | 亚洲视频在线观看 | 国产精品亚洲精品日韩已方 | 久久国产精品免费一区二区三区 | 特一级黄色毛片 | 特一级毛片 | 拍拍无遮挡人做人爱视频免费观看 | 九九九精品视频 | 一级片网址| 午夜小电影 | 日韩精品在线看 | 欧美一区二区在线观看 | 在线视频一区二区三区 | 日韩中文字幕av | 亚洲a视频 | 日韩电影免费在线观看中文字幕 | 性一区 | 日韩一二三区视频 | 天天综合天天 | 久久久精品久久久 | 色综合色综合色综合 | 亚洲精色| 国产成人精品福利 | 亚洲日本欧美日韩高观看 | 一区二区在线 | 欧美精品久久久久久久久老牛影院 | 成人三级网址 | 亚洲一区电影 | 日韩欧美一级精品久久 | 国产精品区一区二 | 亚洲欧洲精品一区 | 欧美另类视频 |