久久久久久久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個數(shù)字時,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");

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

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

相關(guān)文檔推薦

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 位小數(shù)的數(shù)字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 99久久久无码国产精品 | 中文天堂在线一区 | 九九久久久久久 | 欧美一二三区 | 天堂在线中文字幕 | av日韩在线播放 | 69av片| 日本中文字幕视频 | 欧美日韩在线视频一区二区 | 日本不卡一区二区三区 | 国产91精品久久久久久久网曝门 | 日韩中文在线视频 | 亚洲精品成人在线 | 欧美电影免费观看 | 国产一级免费视频 | 精品av天堂毛片久久久借种 | 成年人在线播放 | 久久综合久久久 | 日韩一级黄色毛片 | 中文字幕在线第一页 | 国产欧美一区二区三区久久人妖 | 国产一在线 | av一二三区 | 国产精品中文在线 | 精品欧美乱码久久久久久1区2区 | 一区二区国产精品 | 精品欧美激情在线观看 | 欧美1区2区 | 一区二区三区视频 | 亚洲精品美女在线观看 | 少妇黄色 | 97操操 | 美女天天操 | 91高清视频在线观看 | 久久国产精品一区 | 国产网站在线免费观看 | 欧美精品免费观看二区 | 成人免费看黄网站在线观看 | 欧美日韩在线一区二区 | 欧美性生活一区二区三区 | 欧美亚州综合 |