Java Code Examples for android.widget.EditText#setOnClickListener()

The following examples show how to use android.widget.EditText#setOnClickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MeiziActivity.java    From styT with Apache License 2.0 7 votes vote down vote up
private void initView() {

        editText = (EditText) findViewById(R.id.mainEditText10);
        listView = (ListView) findViewById(R.id.api_id_views_listview);
        itemAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_activated_1, ContantValue.viewItem);
        listView.setAdapter(itemAdapter);
        listView.setOnItemClickListener(this);

        editText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String comment = editText.getText().toString().trim();
                if (TextUtils.isEmpty(comment)) {
                    //a.setError("内容不能为空");
                    return;
                }

                ToastUtil.show(MeiziActivity.this, "复制成功", Toast.LENGTH_SHORT);
                ClipboardManager manager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                manager.setText(comment);
            }
        });
    }
 
Example 2
Source File: BasicActivity.java    From letv with Apache License 2.0 6 votes vote down vote up
protected void beautyEditText(final EditText mEditText, String hintStr, TextWatcher mTextWatcher) {
    mEditText.setHint(hintStr);
    mEditText.setHintTextColor(Color.parseColor("#1e0d0d0d"));
    mEditText.setTextColor(Color.parseColor("#0d0d0d"));
    SDKUtils.setBackground(mEditText, this.crMgmt.getDrawable("uac_input", true));
    mEditText.setTextSize(16.0f);
    if (mTextWatcher != null) {
        mEditText.addTextChangedListener(mTextWatcher);
    }
    mEditText.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mEditText.setSelection(mEditText.length());
            mEditText.requestFocus();
            mEditText.setFocusable(true);
        }
    });
}
 
Example 3
Source File: MaterialSearchView.java    From talk-android with MIT License 6 votes vote down vote up
private void initiateView() {
    LayoutInflater.from(mContext).inflate(R.layout.search_view, this, true);
    mSearchLayout = findViewById(R.id.search_layout);

    mSearchTopBar = (RelativeLayout) mSearchLayout.findViewById(R.id.search_top_bar);
    mSuggestionsListView = (ListView) mSearchLayout.findViewById(R.id.suggestion_list);
    mSearchSrcTextView = (EditText) mSearchLayout.findViewById(R.id.searchTextView);
    mBackBtn = (ImageButton) mSearchLayout.findViewById(R.id.action_up_btn);
    mEmptyBtn = (ImageButton) mSearchLayout.findViewById(R.id.action_empty_btn);
    mTintView = mSearchLayout.findViewById(R.id.transparent_view);

    mSearchSrcTextView.setOnClickListener(mOnClickListener);
    mBackBtn.setOnClickListener(mOnClickListener);
    mEmptyBtn.setOnClickListener(mOnClickListener);
    mTintView.setOnClickListener(mOnClickListener);

    allowVoiceSearch = false;

    initSearchView();

    mSuggestionsListView.setVisibility(GONE);
}
 
Example 4
Source File: BasicActivity.java    From DynamicCalendar with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_basic);
    mImageGenerator = new ImageGenerator(this);
    mDateEditText = (EditText) findViewById(R.id.txtDateEntered);
    mDisplayGeneratedImage = (ImageView) findViewById(R.id.imgGenerated);

    mImageGenerator.setIconSize(50, 50);
    mImageGenerator.setDateSize(30);
    mImageGenerator.setMonthSize(10);

    mImageGenerator.setDatePosition(42);
    mImageGenerator.setMonthPosition(14);

    mImageGenerator.setDateColor(Color.parseColor("#3c6eaf"));
    mImageGenerator.setMonthColor(Color.WHITE);

    mImageGenerator.setStorageToSDCard(true);

    // Pop up Date picker on pressing the editText
    mDateEditText.setOnClickListener(setDate);


}
 
Example 5
Source File: MessageActivity.java    From restcomm-android-sdk with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_message);

   Toolbar toolbar = (Toolbar) findViewById(R.id.message_toolbar);
   setSupportActionBar(toolbar);
   toolbar.setTitle(getTitle());

   ActionBar actionBar = getSupportActionBar();
   if (actionBar != null) {
      // Show the Up button in the action bar.
      actionBar.setDisplayHomeAsUpEnabled(true);
   }

   listFragment = (MessageFragment) getSupportFragmentManager().findFragmentById(R.id.message_list);

   alertDialog = new AlertDialog.Builder(MessageActivity.this, R.style.SimpleAlertStyle).create();

   btnSend = (ImageButton) findViewById(R.id.button_send);
   btnSend.setOnClickListener(this);
   txtMessage = (EditText) findViewById(R.id.text_message);
   txtMessage.setOnClickListener(this);
   lblOngoingCall = findViewById(R.id.resume_call);
   lblOngoingCall.setOnClickListener(this);

   fullPeer = getIntent().getStringExtra(RCDevice.EXTRA_DID);
   // keep on note of the current peer we are texting with
   currentPeer = getIntent().getStringExtra(RCDevice.EXTRA_DID).replaceAll("^sip.?:", "").replaceAll("@.*$", "");
   setTitle(currentPeer);
}
 
Example 6
Source File: SearchPreference.java    From SearchPreference with MIT License 5 votes vote down vote up
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    EditText searchText = (EditText) holder.findViewById(R.id.search);
    searchText.setFocusable(false);
    searchText.setInputType(InputType.TYPE_NULL);
    searchText.setOnClickListener(this);

    if (hint != null) {
        searchText.setHint(hint);
    }

    holder.findViewById(R.id.search_card).setOnClickListener(this);
    holder.itemView.setOnClickListener(this);
    holder.itemView.setBackgroundColor(0x0);
}
 
Example 7
Source File: FormAdapter.java    From SSForms with GNU General Public License v3.0 5 votes vote down vote up
private void setDatePickerInputLayout(final EditText editText, final int position, final LinearLayout layoutRow) {
    editText.setFocusableInTouchMode(false);

    editText.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editText.requestFocus();
            InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
        }
    });

    layoutRow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            clickedPosition = position;
            DatePickerDialog datePickerDialog = new DatePickerDialog(mContext,
                    date,
                    mCalendarCurrentDate.get(Calendar.YEAR),
                    mCalendarCurrentDate.get(Calendar.MONTH),
                    mCalendarCurrentDate.get(Calendar.DAY_OF_MONTH));

            // this could be used to set a minimum date
            // datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);

            // display the picker
            datePickerDialog.show();
        }
    });

}
 
Example 8
Source File: RealTimeUpdateSearchBox.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
private void init(AttributeSet attrs, int defStyle) {
    // Load attributes
    final TypedArray a = getContext().obtainStyledAttributes(
            attrs, R.styleable.lingju, defStyle, 0);
    LayoutInflater.from(getContext()).inflate(R.layout.search_online_box, this);
    mLlRoot = findViewById(R.id.ll_root);
    edit = (EditText) findViewById(R.id.sob_search_edit);
    stateBt = (ImageButton) findViewById(R.id.sob_state_bt);
    animate = AnimationUtils.loadAnimation(getContext(), R.anim.start_up_loading);
    animate.setInterpolator(new LinearInterpolator());
    drawable = (LevelListDrawable) stateBt.getDrawable();
    edit.addTextChangedListener(searhWatcher);
    edit.setOnEditorActionListener(editorActionListener);
    edit.setOnClickListener(editorClickListener);
    stateBt.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (stateBt.getVisibility() == View.VISIBLE && drawable.getLevel() == 1) {
                edit.setText("");
                stateBt.setVisibility(View.INVISIBLE);
            }
        }
    });
    edit.setHint(a.getString(R.styleable.lingju_hint));
    // edit.setHintTextColor(getResources().getColor(R.color.navi_search_box_color));
    edit.setHintTextColor(a.getColor(R.styleable.lingju_hintColor, getResources().getColor(R.color.navi_search_box_color)));
    edit.setTextColor(a.getColor(R.styleable.lingju_textColor, getResources().getColor(R.color.ksw_md_solid_disable)));
    mLlRoot.setBackgroundColor(a.getColor(R.styleable.lingju_search_background, getResources().getColor(R.color.green_style)));
    //edit.setTextSize(a.getFloat(com.android.internal.R.styleable.TextView_textSize,12));

    a.recycle();
}
 
Example 9
Source File: TypeFaceActivity.java    From DynamicCalendar with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_type_face);
    mImageGenerator = new ImageGenerator(this);
    mDateEditText = (EditText) findViewById(R.id.txtDateEntered);
    mDisplayGeneratedImage = (ImageView) findViewById(R.id.imgGenerated);

    mImageGenerator.setIconSize(50, 50);
    mImageGenerator.setDateSize(30);
    mImageGenerator.setMonthSize(10);

    mImageGenerator.setDatePosition(42);
    mImageGenerator.setMonthPosition(14);

    mImageGenerator.setDateColor(Color.parseColor("#009688"));
    mImageGenerator.setMonthColor(Color.WHITE);

    mImageGenerator.setStorageToSDCard(true);

    mImageGenerator.setDateTypeFace("Roboto-Light.ttf");
    mImageGenerator.setMonthTypeFace("Ubuntu-R.ttf");

    // Pop up Date picker on pressing the editText
    mDateEditText.setOnClickListener(setDate);


}
 
Example 10
Source File: PhoneNumberActivity.java    From android-credentials with Apache License 2.0 5 votes vote down vote up
PhoneNumberUi(View root, String activityTitle) {
    title = (TextView) root.findViewById(R.id.phone_number_title);
    phoneField = (EditText) root.findViewById(R.id.phone_number_field);
    submit = (Button) root.findViewById(R.id.phone_number_submit);
    phoneFocus = new FocusControl(phoneField);

    title.setText(activityTitle);
    submit.setOnClickListener(this);
    phoneField.setOnClickListener(this);
    setSubmitEnabled(true);
}
 
Example 11
Source File: editsUtils.java    From Color-picker-library with GNU General Public License v3.0 5 votes vote down vote up
static void initializeEditTextTouchListeners(EditText... editTexts) {

        for (final EditText edt : editTexts) {
            edt.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    edt.getText().clear();
                }
            });
        }
    }
 
Example 12
Source File: ChatActivity.java    From CoolChat with Apache License 2.0 5 votes vote down vote up
private void initViews() {
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
    recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
    LinearLayoutManager layoutManager = new LinearLayoutManager(ChatActivity.this);
    //layoutManager.setStackFromEnd(true);
    recyclerView.setLayoutManager(layoutManager);
    adapter = new ChatAdapter(ChatActivity.this, chatListData);
    recyclerView.setAdapter(adapter);
    edit_input = (EditText) findViewById(R.id.edit_input);
    edit_input.addTextChangedListener(textWatcher);
    edit_input.setOnClickListener(this);
    text_unread_msg = (TextView) findViewById(R.id.text_unread_msg);

    layout_multi = (LinearLayout) findViewById(R.id.layout_multi);
    imgbtn_send = (ImageButton) findViewById(R.id.imgbtn_send);
    imgbtn_send.setClickable(false);

    checkbox_audio = (CheckBox) findViewById(R.id.checkbox_audio);
    checkbox_emoji = (CheckBox) findViewById(R.id.checkbox_emoji);
    checkbox_gallery = (CheckBox) findViewById(R.id.checkbox_gallery);
    checkbox_video = (CheckBox) findViewById(R.id.checkbox_video);
    checkbox_more = (CheckBox) findViewById(R.id.checkbox_more);

    checkbox_audio.setOnCheckedChangeListener(this);
    checkbox_emoji.setOnCheckedChangeListener(this);
    checkbox_video.setOnCheckedChangeListener(this);
    checkbox_gallery.setOnCheckedChangeListener(this);
    checkbox_more.setOnCheckedChangeListener(this);

    text_unread_msg.setOnClickListener(this);
    imgbtn_send.setOnClickListener(this);

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            initMoreChatData(chatType, chatId);
        }
    });
}
 
Example 13
Source File: SearchView.java    From LLApp with Apache License 2.0 5 votes vote down vote up
private void initViews() {
    etInput = (EditText) findViewById(R.id.search_et_input);
    ivDelete = (ImageView) findViewById(R.id.search_iv_delete);
    btnBack = (Button) findViewById(R.id.search_btn_back);
    lvTips = (ListView) findViewById(R.id.search_lv_tips);

    lvTips.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            //set edit text
            String text = lvTips.getAdapter().getItem(i).toString();
            etInput.setText(text);
            etInput.setSelection(text.length());
            //hint list view gone and result list view show
            lvTips.setVisibility(View.GONE);
            notifyStartSearching(text);
        }
    });

    ivDelete.setOnClickListener(this);
    btnBack.setOnClickListener(this);

    etInput.addTextChangedListener(new EditChangedListener());
    etInput.setOnClickListener(this);
    etInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                lvTips.setVisibility(GONE);
                notifyStartSearching(etInput.getText().toString());
            }
            return true;
        }
    });
}
 
Example 14
Source File: CardForm.java    From android-card-form with MIT License 4 votes vote down vote up
private void setListeners(EditText editText) {
    editText.setOnFocusChangeListener(this);
    editText.setOnClickListener(this);
    editText.addTextChangedListener(this);
}
 
Example 15
Source File: ChatActivity.java    From MaterialQQLite with Apache License 2.0 4 votes vote down vote up
@SuppressLint("NewApi")
    private void initView() {
    //    m_txtName = (TextView)findViewById(R.id.chat_txtName);
        m_lvMsg = (ListView)findViewById(R.id.chat_lvMsg);
        swipeRefreshLayout_chat= (PullRefreshLayout) findViewById(R.id.swipeRefreshLayout_chat);
        m_btnFace = (ImageButton)findViewById(R.id.chat_btnFace);
    //    m_btnMore = (ImageButton)findViewById(R.id.chat_btnMore);
        m_edtMsg = (EditText) findViewById(R.id.chat_edtMsg);
        m_btnSend = (Button) findViewById(R.id.chat_btnSend);
        m_faceBar = findViewById(R.id.chat_facebar);
        m_vpFace = (ViewPager)findViewById(R.id.chat_vpFace);
        m_dotBar = (LinearLayout) findViewById(R.id.chat_dotbar);



        m_btnFace.setOnClickListener(this);
        m_edtMsg.setOnClickListener(this);
        m_btnSend.setOnClickListener(this);

        if (m_nType != IS_GROUP)
          //  m_txtName.setText(m_strBuddyName);
            m_txtName=m_strBuddyName;
        else
         //   m_txtName.setText(m_strGroupName);
        m_txtName=m_strGroupName;

        initChatMsgListView();	// 初始化聊天消息列表框
        initFaceBar();			// 初始化表情栏

        m_nCurFacePage = 0;
        m_vpFace.setCurrentItem(1);

        toolbar = (Toolbar) findViewById(R.id.toolbar_chat);
        toolbar.setNavigationIcon(R.drawable.qqicon);
        toolbar.setTitle(m_txtName);

        setSupportActionBar(toolbar);
        toolbar.setNavigationOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        chat_inputbar= (LinearLayout) findViewById(R.id.chat_inputbar);

        toolbar.setBackgroundColor(color_theme);
        chat_inputbar.setBackgroundColor(color_theme);

        // 去除 ListView 上下边界蓝色或黄色阴影
//		ListView actualListView = m_lvMsg.getRefreshableView();
//		if (Integer.parseInt(Build.VERSION.SDK) >= 9) {
//			actualListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
//        }
    }
 
Example 16
Source File: ScheduleCallActivity.java    From fake-call-lollipop with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_schedule_call);

    callType = (RadioGroup)findViewById(R.id.callTypeRadioGroup);

    voiceInput = (EditText)findViewById(R.id.voiceFileInput);

    voiceInput.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);

            intent.setType("audio/*");

            startActivityForResult(intent, FILE_SELECT);

        }
    });

}
 
Example 17
Source File: SaveDialog.java    From odyssey with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create the dialog to save an object of the current type.
 */
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the Builder class for convenient dialog construction
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

    // read arguments to identify type of the object which should be saved
    Bundle mArgs = getArguments();
    final OBJECTTYPE type = OBJECTTYPE.values()[mArgs.getInt(ARG_OBJECTTYPE)];

    String dialogTitle = "";
    String editTextDefaultTitle = "";

    if (type != null) {
        // set textfield titles according to type
        switch (type) {
            case PLAYLIST:
                dialogTitle = getString(R.string.dialog_save_playlist);
                editTextDefaultTitle = getString(R.string.default_playlist_title);
                break;
            case BOOKMARK:
                dialogTitle = getString(R.string.dialog_create_bookmark);
                editTextDefaultTitle = getString(R.string.default_bookmark_title);
                break;
        }
    }

    // create edit text for title
    final EditText editTextTitle = new EditText(builder.getContext());
    editTextTitle.setText(editTextDefaultTitle);
    // Add a listener that just removes the text on first clicking
    editTextTitle.setOnClickListener(v -> {
        if (!mFirstClick) {
            editTextTitle.setText("");
            mFirstClick = true;
        }
    });
    builder.setView(editTextTitle);

    builder.setMessage(dialogTitle).setPositiveButton(R.string.dialog_action_save, (dialog, id) -> {
        // accept title and call callback method
        String objectTitle = editTextTitle.getText().toString();
        mSaveCallback.onSaveObject(objectTitle, type);
    }).setNegativeButton(R.string.dialog_action_cancel, (dialog, id) -> {
        // User cancelled the dialog dont save object
        getDialog().cancel();
    });
    // Create the AlertDialog object and return it
    return builder.create();
}
 
Example 18
Source File: StringWidget.java    From commcare-android with Apache License 2.0 4 votes vote down vote up
public StringWidget(Context context, FormEntryPrompt prompt, boolean secret, boolean inCompactGroup) {
    super(context, prompt, inCompactGroup);
    mAnswer = (EditText)LayoutInflater.from(getContext()).inflate(getAnswerLayout(), this, false);
    mAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontSize);
    mAnswer.setOnClickListener(this);

    mAnswer.addTextChangedListener(this);

    //Let's see if we can figure out a constraint for this string
    try {
        addAnswerFilter(new InputFilter.LengthFilter(guessMaxStringLength(prompt)));
    } catch (UnpivotableExpressionException e) {
        //expected if there isn't a constraint that does this
    }

    this.secret = secret;

    if (!secret) {
        // capitalize the first letter of the sentence
        mAnswer.setKeyListener(new TextKeyListener(Capitalize.SENTENCES, false));
    }
    setTextInputType(mAnswer);

    if (!secret) {
        mAnswer.setSingleLine(false);
    }

    if (prompt != null) {
        mReadOnly = prompt.isReadOnly();
        IAnswerData value = prompt.getAnswerValue();
        if (value != null) {
            mAnswer.setText(value.getDisplayText());
        }

        if (mReadOnly) {
            if (value == null) {
                mAnswer.setText("---");
            }
            mAnswer.setBackgroundDrawable(null);
            mAnswer.setFocusable(false);
            mAnswer.setClickable(false);
        }
    }

    if (isInCompactMode()) {
        addToCompactLayout(mAnswer);
    } else {
        addView(mAnswer);
    }
}
 
Example 19
Source File: HY_Hybrid.java    From test-samples with Apache License 2.0 4 votes vote down vote up
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.hy_layout);

    inputMethodManager = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);

    fl_urlPanel = (FrameLayout) findViewById(R.id.hy_fl_urlPanel);
    wv_webView = (WebView) findViewById(R.id.hy_wv_webview);
    pb_loading = (ProgressBar) findViewById(R.id.hy_pb_loading);
    et_url = (EditText) findViewById(R.id.hy_et_url);
    ib_loadUrl = (ImageButton) findViewById(R.id.hy_ib_loadUrl);
    ib_navigateBackward = (ImageButton) findViewById(R.id.hy_ib_navigateBack);
    ib_navigateForward = (ImageButton) findViewById(R.id.hy_ib_navigateForward);

    et_url.setOnClickListener(this);
    ib_loadUrl.setOnClickListener(this);
    ib_navigateBackward.setOnClickListener(this);
    ib_navigateForward.setOnClickListener(this);

    et_url.setOnFocusChangeListener(this.onFocusChangeListener);

    // setting WebView
    {
        WebSettings webSettings = wv_webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        wv_webView.setWebViewClient(this.webViewClient);
    }

    // enable WebView debugging - for Appium to be able to switch to WebView context
    setWebContentsDebuggingEnabled(true);

    // don't auto-pop keyboard
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    // setting presets
    setNavigationButtons();

    ib_loadUrl.performClick();

}
 
Example 20
Source File: List12.java    From codeexamples-android with Eclipse Public License 1.0 3 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    setContentView(R.layout.list_12);
    
    mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mStrings);
    
    setListAdapter(mAdapter);
    
    mUserText = (EditText) findViewById(R.id.userText);

    mUserText.setOnClickListener(this);
    mUserText.setOnKeyListener(this);
}