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

如何在 EditText 上應(yīng)用 Textchange 事件

How to Apply the Textchange event on EditText(如何在 EditText 上應(yīng)用 Textchange 事件)
本文介紹了如何在 EditText 上應(yīng)用 Textchange 事件的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時(shí)送ChatGPT賬號(hào)..

我開發(fā)了一個(gè)簡單的應(yīng)用程序,例如減法、加法.在這個(gè)應(yīng)用程序中,我使用了三個(gè) EditText,一個(gè)用于回答,另外兩個(gè)用于提問.我想計(jì)算關(guān)于文本更改事件的問題的答案.但是,當(dāng)我在這兩個(gè)上應(yīng)用文本更改事件時(shí),事件會(huì)發(fā)生但無法正常工作.因?yàn)楫?dāng)我在問題的第一個(gè) EditText 中輸入文本時(shí),事件發(fā)生但它拋出了這個(gè)異常:

I developed one simple app, like subtraction, addition. In this app I use three EditTexts, one for answer and other two for question. I want to calculate the answer of question on text change event. But when I apply the text change event on both of this the event occur but not properly work. Because when I enter in the text in first EditText of question the event occur but it throws this exception:

07-03 16:39:48.844: E/EduApp Log :=>(12537): Error In Text change Event java.lang.NumberFormatException: unable to parse '' as integer

我該怎么辦?我將 TextWatcher 用于文本更改事件.

What do I do? I use the TextWatcher for text change event.

txtOne.addTextChangedListener(this);
txtTwo.addTextChangedListener(this);

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) {}  

推薦答案

我認(rèn)為您收到了導(dǎo)致此問題的空字符串 " ".確保從 EditText 中獲得非空字符串.

I think you are receiving empty String " " which is causing this problem. Make sure you get a non-empty String from your EditText.

考慮到您的 EditText 沒有輸入任何值,并且您試圖獲取它的值并將其轉(zhuǎn)換為 int,您將遇到這種問題.

Consider your EditText doesn't have any value typed in, and you are trying to get its value and convert into int you will run into this kind of problem.

edittext.addTextChangedListener(new TextWatcher() {

    public void onTextChanged(CharSequence s, int start, int before,
            int count) {
            if(!s.equals("") ) { 
                //do your work here 
            }
    }



    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {

    }

    public void afterTextChanged(Editable s) {

    }
});

還可以查看此鏈接以獲取更多想法,

Also check this link for more idea,

https://stackoverflow.com/a/3377648/603744

這篇關(guān)于如何在 EditText 上應(yīng)用 Textchange 事件的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

Cut, copy, paste in android(在android中剪切、復(fù)制、粘貼)
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(更改光標(biāo)在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 成年网站在线观看 | 亚洲精品大片 | 欧美福利| 成人av片在线观看 | 又爽又黄axxx片免费观看 | 一级片片 | 青青草网 | 精品免费观看 | caoporn免费| 在线看一区二区 | 国产成人精品免费视频大全最热 | 日韩久久网 | 一区二区三区在线电影 | 波多野结衣亚洲 | 久久99成人 | 久久精品中文字幕 | 欧美激情视频网站 | 久久精品久久久久久 | 久久精品免费 | 成人免费视频7777777 | 日本在线视频中文字幕 | 国产欧美精品一区二区 | 久久久久久国产精品 | 免费av播放 | 香蕉一区二区 | 男女在线免费观看 | 天天综合网91 | 精品久久久一区 | 日韩一二区| 中文字幕a√ | 日本黄色一级视频 | 一区二区三区在线 | 亚洲成人观看 | 欧美成人精品一区二区男人看 | 日本免费一区二区三区四区 | 久久久久国产精品一区 | 高清视频一区二区三区 | 一区二区三区高清 | 久久精品小短片 | 精品欧美一区二区在线观看欧美熟 | 99综合在线 |