当前位置: 首页>>代码示例>>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;未经允许,请勿转载。