Code example for EditText

Methods: getTextgetSelectionEndgetSelectionStart

0
        // Paste episode button 
        if (!TextUtils.isEmpty(itemTitle)) { 
            layout.findViewById(R.id.pasteTitle).setOnClickListener(new OnClickListener() { 
                @Override 
                public void onClick(View v) { 
                    int start = mMessageBox.getSelectionStart(); 
                    int end = mMessageBox.getSelectionEnd(); 
                    mMessageBox.getText().replace(Math.min(start, end), Math.max(start, end), 
                            itemTitle, 0, itemTitle.length()); 
                } 
            }); 
        } 
 
        // Clear button 
        layout.findViewById(R.id.textViewClear).setOnClickListener(new OnClickListener() { 
            @Override 
            public void onClick(View v) {
                mMessageBox.setText(null);
            } 
        });