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

所有 EditTexts 上的 EditText setOnFocusChangeListener

EditText setOnFocusChangeListener on all EditTexts(所有 EditTexts 上的 EditText setOnFocusChangeListener)
本文介紹了所有 EditTexts 上的 EditText setOnFocusChangeListener的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有幾個 EditText 字段,我想用 setOnFocusChangeListener 將它們保存到 SQLiteDatabase.我是否必須為每個單獨設置一個 onFocusChangeListener,或者是否有某種包羅萬象的方法?(getActivity().findViewByID 因為這是一個片段)

I have several EditText fields which I want to save to the SQLiteDatabase with setOnFocusChangeListener. Do I have to set an onFocusChangeListener on each one individually, or is there a catch-all of some sort? (getActivity().findViewByID because this is a fragment)

final TextView txtName = (TextView)getActivity().findViewById(R.id.clientHeader);
final TextView txtCompany = (TextView)getActivity().findViewById(R.id.txtContactCompany);       
final TextView txtPosition = (TextView)getActivity().findViewById(R.id.txtContactPosition);     


txtName.setOnFocusChangeListener(new OnFocusChangeListener() {          
    public void onFocusChange(View v, boolean hasFocus) {
        if(!hasFocus) {
            saveThisItem(txtClientID.getText().toString(), "name", txtName.getText().toString());
        }
    }
});


txtCompany.setOnFocusChangeListener(new OnFocusChangeListener() {          
    public void onFocusChange(View v, boolean hasFocus) {
        if(!hasFocus) {
            saveThisItem(txtClientID.getText().toString(), "company", txtCompany.getText().toString());
        }
    }
});

txtPosition.setOnFocusChangeListener(new OnFocusChangeListener() {          
    public void onFocusChange(View v, boolean hasFocus) {
        if(!hasFocus) {
            saveThisItem(txtClientID.getText().toString(), "position", txtPosition.getText().toString());
        }
    }
});

就像...有沒有辦法讓 ArrayList <EditText > 的 EditText 視圖,將指針(抱歉,不確定如何)分配給現有的 editTexts 并將 onFocusChangeListener 設置為整個數組列表?或者,甚至,遍歷 ArrayList 并將 onFocusChangeListener 設置為每個成員?

Like... is there some way to have a ArrayList < EditText > of EditText Views, assign a pointer (sorry, not sure how) to the existing editTexts and set the onFocusChangeListener to the whole arraylist? Or, even, iterate through the ArrayList and set the onFocusChangeListener to each member?

或者一種檢測任何 onFocusChangeListener 事件的方法,并將所有數據保存到數據庫中,而不管事件發生在什么 EditText 上?

Or a way to detect ANY onFocusChangeListener events, and just save all data to the database, regardless of what EditText the even occurred on?

推薦答案

好吧,你可以讓你的活動實現 OnFocusChangeListener.這樣,您的所有更改都將在該方法上進行,但您必須通過使用 v.getId() 獲取視圖 ID 來檢查哪個視圖更改了焦點并進行相應處理.

Well, you could have your activity implement OnFocusChangeListener. That way, all your changes will be on that one metho,d but you will have to check which view changed focus by getting the view id with v.getId() and handle accordingly.

@Override
public void onFocusChange(View v, boolean hasFocus) {
    switch(v.getId()){
    case r.id.editText1:
    break;

    ...etc
    }
}

這篇關于所有 EditTexts 上的 EditText setOnFocusChangeListener的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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問題)
主站蜘蛛池模板: 男女国产视频 | 亚洲av一级毛片 | 国产色网站 | 亚洲精品片| www.国产精 | av激情在线 | 人妖一区| 欧美亚洲高清 | 日韩三级 | 婷婷丁香在线视频 | 欧美另类视频 | 久久久日韩精品一区二区三区 | 国产乱码精品一区二区三区中文 | 欧美色综合一区二区三区 | 在线国产一区 | 国产欧美精品一区二区三区 | 久草在线视频中文 | 久久久久久国产精品 | 精品成人免费一区二区在线播放 | 黄色国产视频 | 精品一二三区在线观看 | 国产精品久久久久久久久久不蜜臀 | 影音先锋中文字幕在线观看 | 国产高清精品一区二区三区 | 国内精品久久久久 | 亚洲精品一区在线 | 国产欧美精品区一区二区三区 | 日日做夜夜爽毛片麻豆 | 伊人精品一区二区三区 | 免费久久99精品国产婷婷六月 | 99精品国自产在线 | 狠狠操狠狠操 | 国产激情综合五月久久 | 色综合99| 中文字幕第90页 | 美女视频h| 日本韩国电影免费观看 | 国产高清在线视频 | 欧美一区视频 | 中文在线一区二区 | 黄网站在线观看 |