當前位置: 首頁>>代碼示例>>Java>>正文


Java EditText.setOnFocusChangeListener方法代碼示例

本文整理匯總了Java中android.widget.EditText.setOnFocusChangeListener方法的典型用法代碼示例。如果您正苦於以下問題:Java EditText.setOnFocusChangeListener方法的具體用法?Java EditText.setOnFocusChangeListener怎麽用?Java EditText.setOnFocusChangeListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.EditText的用法示例。


在下文中一共展示了EditText.setOnFocusChangeListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initView

import android.widget.EditText; //導入方法依賴的package包/類
private void initView() {
    mChatTxt = (TextView) findViewById(R.id.app_watch_chattxt);
    mChatTxt.setOnClickListener(this);
    mHostTxt = (TextView) findViewById(R.id.app_watch_hosttxt);
    mHostTxt.setOnClickListener(this);
    mMessagesendlayout = (LinearLayout) findViewById(R.id.app_watch_msg_send_layout);
    mZhubolayout = (RelativeLayout) findViewById(R.id.app_watch_zhubo_layout);
    mChatzhubomsg = (RelativeLayout) findViewById(R.id.app_watch_chat_zhubo_msg);
    mDanmakuView = (IDanmakuView) findViewById(R.id.app_watch_danmakuview);
    mMessagesView = (RecyclerView) findViewById(R.id.app_watch_msg_receive_layout);
    mMessagesView.setLayoutManager(new LinearLayoutManager(this));
    mMessagesView.setAdapter(mAdapter);
    mEditMsg = (EditText) findViewById(R.id.app_watch_editimg);
    mEditMsg.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                showPopFormBottom();
            }
        }
    });
    mEditMsg.setOnClickListener(this);
}
 
開發者ID:lisnstatic,項目名稱:live_master,代碼行數:24,代碼來源:WatchLiveActivity.java

示例2: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);

    logEmailHint = (TextView) findViewById(R.id.logEmailHint);
    logEmail = (EditText) findViewById(R.id.logEmail);
    logEmailLine = (ImageView) findViewById(R.id.logEmailLine);
    logEmailCancel = (ImageView) findViewById(R.id.logEmailCancel);

    logPasswordHint = (TextView) findViewById(R.id.logPasswordHint);
    logPassword = (EditText) findViewById(R.id.logPassword);
    logPasswordLine = (ImageView) findViewById(R.id.logPasswordLine);
    logPasswordCancel = (ImageView) findViewById(R.id.logPasswordCancel);

    //For Focus
    logEmail.setOnFocusChangeListener(hasFocusListener);
    logPassword.setOnFocusChangeListener(hasFocusListener);

    //For TextChange
    logEmail.addTextChangedListener(textLengthListener);
    logPassword.addTextChangedListener(textLengthListener);

}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:25,代碼來源:LoginActivity.java

示例3: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    // check if there is already a username set in the past
    // this should be stored in the preferences
    // if this is the case then we can directly go on to the next activity.
    if (UserNameStorage.getUserName(this) == null) {
        setContentView(R.layout.user_configuration);
        EditText userNameInput = (EditText) findViewById(R.id.username);
        userNameInput.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if (!hasFocus) {
                    hideKeyboard(v);
                }
            }
        });
    } else {
        Intent myIntent = new Intent(UserConfigurationActivity.this, OverviewConnectionsActivity.class);
        myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
        UserConfigurationActivity.this.startActivity(myIntent);
    }
}
 
開發者ID:wkmeijer,項目名稱:CS4160-trustchain-android,代碼行數:25,代碼來源:UserConfigurationActivity.java

示例4: showHint

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * Función para mostrar un mensaje dentro del campo de texto (placeholder) cuando se haya recibido el foco.
 * @param et: EditText al que se le aplicará la función.
 * @param texto: Texto a mostrar.
 */
public static void showHint(final EditText et, final String texto){
    et.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            if(hasFocus){
                et.setHint(texto);
            }
            else{
                et.setHint("");
            }
        }
    });
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:19,代碼來源:EditTextValidations.java

示例5: initBottomView

import android.widget.EditText; //導入方法依賴的package包/類
private void initBottomView() {
        add = (Button) findViewById(R.id.btn_chat_bottom_add);
        emotion = (Button) findViewById(R.id.btn_chat_bottom_emotion);
        input = (EditText) findViewById(R.id.et_chat_bottom_input);
        speak = (Button) findViewById(R.id.btn_chat_bottom_speak);
        send = (Button) findViewById(R.id.btn_chat_bottom_send);
        voice = (Button) findViewById(R.id.btn_chat_bottom_voice);
        keyboard = (Button) findViewById(R.id.btn_chat_bottom_keyboard);
        l1_more = (LinearLayout) findViewById(R.id.l1_chat_bottom_more);
        mViewPager = (ViewPager) findViewById(R.id.vp_chat_bottom_emotion);
        r1_emotion = (RelativeLayout) findViewById(R.id.r1_chat_bottom_emotion);
        l1_add = (LinearLayout) findViewById(R.id.l1_chat_bottom_add);
        picture = (TextView) findViewById(R.id.tv_chat_bottom_picture);
        camera = (TextView) findViewById(R.id.tv_chat_bottom_camera);
        location = (TextView) findViewById(R.id.tv_chat_bottom_location);
        add.setOnClickListener(this);
        emotion.setOnClickListener(this);
        input.addTextChangedListener(this);
        input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View v, boolean hasFocus) {
                        if (hasFocus) {
                                LogUtil.e("聚焦");
                                scrollToBottom();
                                if (l1_more.getVisibility() == View.VISIBLE) {
                                        l1_more.setVisibility(View.GONE);
                                }
                        }
                }
        });
        voice.setOnClickListener(this);
        send.setOnClickListener(this);
        keyboard.setOnClickListener(this);
        location.setOnClickListener(this);
        picture.setOnClickListener(this);
        camera.setOnClickListener(this);
        speak.setOnTouchListener(this);
        mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
                @Override
                public void onRefresh() {
                        mSwipeRefreshLayout.setRefreshing(true);
                        BaseMessage message = mAdapter.getData(0);
                        LoadMessage(message);
                }
        });
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:47,代碼來源:ChatActivity.java

示例6: addEditTextAtIndex

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * 在特定位置插入EditText
 * @param index   位置
 * @param editStr EditText顯示的文字
 */
public void addEditTextAtIndex(final int index, CharSequence editStr) {
    EditText editText2 = createEditText("", EDIT_PADDING);
    editText2.setText(editStr);
    editText2.setOnFocusChangeListener(focusListener);
    allLayout.addView(editText2, index);
}
 
開發者ID:yangchong211,項目名稱:YCCustomText,代碼行數:12,代碼來源:HyperTextEditor.java

示例7: createEditText

import android.widget.EditText; //導入方法依賴的package包/類
private EditText createEditText(String hint, int Padding) {
    EditText editText = (EditText) inflater.inflate(R.layout.item_edittext, null);
    editText.setTag(viewTag++);
    editText.setOnFocusChangeListener(focusChangeListener);
    editText.setOnKeyListener(keyListener);
    editText.setPadding(dip2px(EDIT_PADDING_TOP), Padding, dip2px(EDIT_PADDING_TOP), 0);
    editText.setHint(hint);
    return editText;
}
 
開發者ID:appteam-nith,項目名稱:Nimbus,代碼行數:10,代碼來源:EditorView.java

示例8: NumberPicker

import android.widget.EditText; //導入方法依賴的package包/類
@SuppressWarnings({"UnusedDeclaration"})
public NumberPicker(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    setOrientation(VERTICAL);
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(R.layout.number_picker, this, true);
    mHandler = new Handler();
    InputFilter inputFilter = new NumberPickerInputFilter();
    mNumberInputFilter = new NumberRangeKeyListener();
    mIncrementButton = (NumberPickerButton) findViewById(R.id.increment);
    mIncrementButton.setOnClickListener(this);
    mIncrementButton.setOnLongClickListener(this);
    mIncrementButton.setNumberPicker(this);
    mDecrementButton = (NumberPickerButton) findViewById(R.id.decrement);
    mDecrementButton.setOnClickListener(this);
    mDecrementButton.setOnLongClickListener(this);
    mDecrementButton.setNumberPicker(this);

    mText = (EditText) findViewById(R.id.timepicker_input);
    mText.setOnFocusChangeListener(this);
    //mText.setFilters(new InputFilter[] {inputFilter});
    mText.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);

    if (!isEnabled()) {
        setEnabled(false);
    }
    
	TypedArray a = context.obtainStyledAttributes( attrs, R.styleable.numberpicker );
	mStart = a.getInt( R.styleable.numberpicker_startRange, DEFAULT_MIN );
	mEnd = a.getInt( R.styleable.numberpicker_endRange, DEFAULT_MAX );
	mWrap = a.getBoolean( R.styleable.numberpicker_wrap, DEFAULT_WRAP );
	mCurrent = 	a.getInt( R.styleable.numberpicker_defaultValue, DEFAULT_VALUE );
	mCurrent = Math.max( mStart, Math.min( mCurrent, mEnd ) );
	mText.setText( "" + mCurrent );
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:36,代碼來源:NumberPicker.java

示例9: newProjectDialog

import android.widget.EditText; //導入方法依賴的package包/類
private void newProjectDialog() {

        mProjectDialog = new LovelyCustomDialog(this, mDarkTheme ? R.style.EditTextTintThemeDark : R.style.EditTextTintTheme)
                .setView(R.layout.project_form)
                .setTopColor(mPrimaryColor)
                .setIcon(R.drawable.ic_notepad)
                .setListener(R.id.projectDoneButton, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        createProjectFromDialog();
                    }
                })
                .show();

        //get the views
        mProjectError = (TextView) mProjectDialog.findViewById(R.id.project_error_message);
        mProjectField = (EditText) mProjectDialog.findViewById(R.id.editProjectName);

        //hide error when text change
        mProjectField.addTextChangedListener(this);
        mProjectField.setHighlightColor(Color.LTGRAY);
        mProjectField.setOnFocusChangeListener(this);

        //request focus on the edit text
        if (mProjectField.requestFocus()) {
            mProjectDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        }

    }
 
開發者ID:IdeaTrackerPlus,項目名稱:IdeaTrackerPlus,代碼行數:30,代碼來源:MainActivity.java

示例10: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    regNameHint = (TextView) findViewById(R.id.regNameHint);
    regName = (EditText) findViewById(R.id.regName);
    regNameLine = (ImageView) findViewById(R.id.regNameLine);
    regNameCancel = (ImageView) findViewById(R.id.regNameCancel);

    regEmailHint = (TextView) findViewById(R.id.regEmailHint);
    regEmail = (EditText) findViewById(R.id.regEmail);
    regEmailLine = (ImageView) findViewById(R.id.regEmailLine);
    regEmailCancel = (ImageView) findViewById(R.id.regEmailCancel);

    regPasswordHint = (TextView) findViewById(R.id.regPasswordHint);
    regPassword = (EditText) findViewById(R.id.regPassword);
    regPasswordLine = (ImageView) findViewById(R.id.regPasswordLine);
    regPasswordCancel = (ImageView) findViewById(R.id.regPasswordCancel);


    //For Focus
    regName.setOnFocusChangeListener(hasFocusListener);
    regEmail.setOnFocusChangeListener(hasFocusListener);
    regPassword.setOnFocusChangeListener(hasFocusListener);

    //For TextChange
    regName.addTextChangedListener(textLengthListener);
    regEmail.addTextChangedListener(textLengthListener);
    regPassword.addTextChangedListener(textLengthListener);

}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:33,代碼來源:RegisterActivity.java

示例11: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add_collection);

    toolbar = (Toolbar) findViewById(R.id.toolbar1);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("Create a Collection");
    toolbar.setTitleTextColor(ContextCompat.getColor(context, R.color.white));

    collectionName = (EditText) findViewById(R.id.collectionName);
    collectionNameLine = (ImageView) findViewById(R.id.collectionNameLine);
    collectionNameCancel = (ImageView) findViewById(R.id.collectionNameCancel);

    description = (EditText) findViewById(R.id.description);
    descriptionLine = (ImageView) findViewById(R.id.descriptionLine);
    descriptionCancel = (ImageView) findViewById(R.id.descriptionCancel);

    tag = (EditText) findViewById(R.id.tag);
    tagLine = (ImageView) findViewById(R.id.tagLine);
    tagCancel = (ImageView) findViewById(R.id.tagCancel);

    //For Focus
    collectionName.setOnFocusChangeListener(hasFocusListener);
    description.setOnFocusChangeListener(hasFocusListener);
    tag.setOnFocusChangeListener(hasFocusListener);

    //For TextChange
    collectionName.addTextChangedListener(textLengthListener);
    description.addTextChangedListener(textLengthListener);
    tag.addTextChangedListener(textLengthListener);

}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:35,代碼來源:AddCollectionActivity.java

示例12: createEditText

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * 生成文本輸入框
 */
public EditText createEditText(String hint, int paddingTop) {
    EditText editText = (EditText) inflater.inflate(R.layout.hyper_edit_text, null);
    editText.setOnKeyListener(keyListener);
    editText.setTag(viewTagIndex++);
    editText.setPadding(0, paddingTop, 0, paddingTop);
    editText.setHint(hint);
    editText.setOnFocusChangeListener(focusListener);
    return editText;
}
 
開發者ID:yangchong211,項目名稱:YCCustomText,代碼行數:13,代碼來源:HyperTextEditor.java

示例13: setUp

import android.widget.EditText; //導入方法依賴的package包/類
/**
 * This function sets up the dialog with the proper values.  If the speedOff parameters
 * has a -1 value disable both spinners
 *
 * @param color - the color to set
 * @param speedOn - the flash time in ms
 * @param speedOff - the flash length in ms
 */
private void setUp(int color, int speedOn, int speedOff, boolean onOffChangeable) {
    mInflater = (LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = mInflater.inflate(R.layout.dialog_light_settings, null);

    mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
    mColorPanel = (LinearLayout) layout.findViewById(R.id.color_panel_view);
    mHexColorInput = (EditText) layout.findViewById(R.id.hex_color_input);
    mNewColor = (ColorPanelView) layout.findViewById(R.id.color_panel);
    mLightsDialogDivider = (View) layout.findViewById(R.id.lights_dialog_divider);
    mPulseSpeedOn = (Spinner) layout.findViewById(R.id.on_spinner);
    mPulseSpeedOff = (Spinner) layout.findViewById(R.id.off_spinner);

    mColorPicker.setOnColorChangedListener(this);
    mColorPicker.setColor(color, true);

    mHexColorInput.setOnFocusChangeListener(this);

    if (onOffChangeable) {
        PulseSpeedAdapter pulseSpeedAdapter = new PulseSpeedAdapter(
                R.array.notification_pulse_length_entries,
                R.array.notification_pulse_length_values,
                speedOn);
        mPulseSpeedOn.setAdapter(pulseSpeedAdapter);
        mPulseSpeedOn.setSelection(pulseSpeedAdapter.getTimePosition(speedOn));
        mPulseSpeedOn.setOnItemSelectedListener(mPulseSelectionListener);

        pulseSpeedAdapter = new PulseSpeedAdapter(R.array.notification_pulse_speed_entries,
                R.array.notification_pulse_speed_values,
                speedOff);
        mPulseSpeedOff.setAdapter(pulseSpeedAdapter);
        mPulseSpeedOff.setSelection(pulseSpeedAdapter.getTimePosition(speedOff));
        mPulseSpeedOff.setOnItemSelectedListener(mPulseSelectionListener);
    } else {
        View speedSettingsGroup = layout.findViewById(R.id.speed_title_view);
        speedSettingsGroup.setVisibility(View.GONE);
    }

    mPulseSpeedOn.setEnabled(onOffChangeable);
    mPulseSpeedOff.setEnabled((speedOn != 1) && onOffChangeable);

    setView(layout);
    setTitle(R.string.edit_light_settings);

    if (!getContext().getResources().getBoolean(
            com.android.internal.R.bool.config_multiColorNotificationLed)) {
        mColorPicker.setVisibility(View.GONE);
        mColorPanel.setVisibility(View.GONE);
        mLightsDialogDivider.setVisibility(View.GONE);
    }

    mReadyForLed = true;
    updateLed();
}
 
開發者ID:ric96,項目名稱:lineagex86,代碼行數:63,代碼來源:LightSettingsDialog.java

示例14: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.baking_config);
    rr = (EditText)findViewById(R.id.rootRoute);
    pn = (EditText)findViewById(R.id.packName);
    mPrefs = getApplicationContext().getSharedPreferences("FirstTime", 0);
    rr.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if(hasFocus){

            }else {
                //LOST FOCUS
                if(mPrefs.getInt("Tutorial",1)==1) {
                    new SimpleTooltip.Builder(v.getContext())
                            .anchorView(pn)
                            .text(R.string.pn)
                            .gravity(Gravity.BOTTOM)
                            .animated(true)
                            .transparentOverlay(false)
                            .build()
                            .show();
                }
            }
        }
    });


    if(mPrefs.getInt("Tutorial",1)==1) {
        new SimpleTooltip.Builder(this)
                .anchorView(rr)
                .text(R.string.path)
                .gravity(Gravity.BOTTOM)
                .animated(true)
                .transparentOverlay(false)
                .build()
                .show();
    }


}
 
開發者ID:olivatooo,項目名稱:ControlBaker,代碼行數:43,代碼來源:PreConfigure.java

示例15: onCreate

import android.widget.EditText; //導入方法依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);
        uname= (EditText) findViewById(R.id.editText1);
        upass= (EditText) findViewById(R.id.editText2);
        button= (ButtonProgressBar) findViewById(R.id.loginbutton);
        text= (TextView) findViewById(R.id.registerbutton);
        image= (CircleImageView) findViewById(R.id.imageView5);
        upass.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                if(hasFocus) {

                    final String focus=uname.getText().toString().trim().replace(" ","");
                    if (!TextUtils.isEmpty(focus)){

                        String sql="select username from login where username='"+focus+"'"+" or phone='"+focus+"'";
                        String url="http://www.shmilyz.com/ForAndroidHttp/select.action";
                        Map<String, String> maps=new HashMap<String, String>();
                        maps.put("uname",sql);
                        xutils.post(url, maps, new Xutils.XCallBack() {
                            @Override
                            public void onResponse(String result) {

                                try {

                                    JSONObject json = new JSONObject(result);
                                    String results = json.getString("result");
                                    JSONArray jsonArray=new JSONArray(results);
                                    JSONObject re=jsonArray.getJSONObject(0);
                                   String  aa=re.getString("username");
                                    String urls="http://www.shmilyz.com/headimage/"+aa+".jpg";

                                    Glide.with(LoginActivity.this)
                                            .load(urls)
                                            .error(R.mipmap.camera)
                                            .diskCacheStrategy( DiskCacheStrategy.NONE )
                                            .into(image);

                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }


                            }
                        });



                    }
                    else{

                    }

                    } else {
// 此處為失去焦點時的處理內容
                }
            }
        });
        init();
    }
 
開發者ID:Shmilyz,項目名稱:Swap,代碼行數:63,代碼來源:LoginActivity.java


注:本文中的android.widget.EditText.setOnFocusChangeListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。