Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mainEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {}
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {}
- @Override
- public void afterTextChanged(Editable editable) {
- if (editable.length() > 1 && (editable.charAt(editable.length() - 1) == '\n')) {
- String name = mainEditText.getText().toString().trim();
- if (name.length() > 0)
- updateNames(name);
- }
- }
- });
- private void updateNames(String name) {
- name = capitilise(name);
- // Take what was typed into the EditText and use in TextView
- mainTextView.setText(name + " is learning Android development bitches!");
- // Also add that value to the list shown in the Listview
- mNameList.add(name);
- mArrayAdapter.notifyDataSetChanged();
- // Remove content from EditText
- mainEditText.setText("");
- // The text you'd like to share has changed, and you need to update
- setShareIntent();
- }
- @Override
- public void onClick(View view) {
- String name = mainEditText.getText().toString().trim();
- if (name.length() > 0) {
- updateNames(name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement