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

android如何將EditText光標設置到其文本的末尾

android how to set the EditText Cursor to the end of its text(android如何將EditText光標設置到其文本的末尾)
本文介紹了android如何將EditText光標設置到其文本的末尾的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

用戶必須輸入他的手機號碼,手機號碼必須是10個號碼,我使用TextWatcher來做到這一點,像這樣

The user has to enter his mobile number, the mobile number has to be 10 numbers, I used TextWatcher to do that, like this

et_mobile.addTextChangedListener(new TextWatcher() {

    @Override
    public void onTextChanged(CharSequence s, int start, int before,
            int count) {
        // TODO Auto-generated method stub

    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {
        // TODO Auto-generated method stub

    }

    @Override
    public void afterTextChanged(Editable s) {
        // TODO Auto-generated method stub
        if (et_mobile.getText().toString().length() > 10) {
            et_mobile.setText(et_mobile.getText().toString()
                    .subSequence(0, 10));
            tv_mobileError.setText("Just 10 Number");
        }else{
            tv_mobileError.setText("*");
        }
    }
});

但問題是當用戶輸入第11個數字時,edittext的光標從文本的開頭開始,我希望它仍然在末尾,怎么辦?

but the problem is when the user enters the 11th number, the cursor of the edittext starts from the beginning of the text, I want it to still at the end, how?

推薦答案

你有兩個選擇,都應該工作:

You have two options, both should work:

一)

editText.setText("Your text");
editText.setSelection(editText.getText().length());

b)

editText.setText("");    
editText.append("Your text");

這篇關于android如何將EditText光標設置到其文本的末尾的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 99福利视频 | 一区二区三区视频在线播放 | 9999精品视频 | 亚洲影视一区 | 三级在线观看 | 久久免费毛片 | 三级视频在线播放 | 精品久久视频 | 美日韩一区 | 国产精品suv一区二区 | 日本黄色录像 | 在线观看国产一区 | 欧美日韩精品在线 | 欧美激情精品 | 国产无遮挡又黄又爽免费网站 | 午夜性福利| 欧美国产在线观看 | 欧美性猛交xxxx黑人猛交 | 欧美日韩在线观看一区二区 | av日韩在线播放 | 一区二区在线免费观看 | 免费黄色在线 | 久久一区二区三区四区 | av高清不卡 | 欧美精品一区二区三区四区 | 毛片精品 | 国产成人精品一区二区三区在线 | 中文字幕综合网 | 性猛交xxxx富婆老太婆 | 日日操日日射 | 日韩高清中文字幕 | www.超碰 | 四虎8848| 国产日韩在线播放 | 国产精品成人一区 | 日韩中文字幕精品 | 日韩成人高清 | 超碰免费在线观看 | 亚洲精品国产精品乱码不卡 | 一级黄色片免费观看 | 久久久久久国产精品 |