Got it sorted.
It seems that just returning a standard BaseInputConnection isn't enough to
make the TextView editable. I needed to use the following subclass of
BaseInputConnection. Thanks Daniel :)
class MyInputConnection extends BaseInputConnection {
private SpannableStringBuilder _editable;
TextView _textView;
public MyInputConnection(View targetView, boolean fullEditor) {
super(targetView, fullEditor);
_textView = (TextView) targetView;
}
public Editable getEditable() {
if (_editable == null) {
_editable = (SpannableStringBuilder) Editable.Factory.getInstance()
.newEditable("Placeholder");
}
return _editable;
}
public boolean commitText(CharSequence text, int newCursorPosition) {
_editable.append(text);
_textView.setText(text);
return true;
}
}
On Thu, Mar 31, 2011 at 8:19 PM, Rich E <[email protected]> wrote:
> As I said in reply, I am overriding onCreateInputConnection(), but I am now
> very sure that I am not setting the appropriate parameters in order to gain
> editing abilities in my view. Here are the methods I am using at the
> moment:
>
> @Override
>
> public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
>
> Log.d(TAG, "onCreateInputConnection");
>
> BaseInputConnection fic = new BaseInputConnection(this, true);
>
> outAttrs.actionLabel = null;
>
> outAttrs.label = "Test text";
>
> outAttrs.inputType = InputType.TYPE_CLASS_TEXT;
>
> outAttrs.imeOptions = EditorInfo.IME_ACTION_NEXT;
>
> return fic;
>
> }
>
> @Override
>
> public boolean onCheckIsTextEditor() {
>
> Log.d(TAG, "onCheckIsTextEditor");
>
> return true;
>
> }
>
> On Tue, Mar 29, 2011 at 3:54 AM, Dianne Hackborn <[email protected]>wrote:
>
>> On Mon, Mar 28, 2011 at 3:10 AM, Rich E <[email protected]> wrote:
>>
>>> Can you explain to me how I can 'listen' to these calls? This is exactly
>>> what I have been trying to achieve.
>>>
>>
>> As has already been said, you need to override onCreateInputConnection()
>> and return your own interface.
>>
>> --
>> Dianne Hackborn
>> Android framework engineer
>> [email protected]
>>
>> Note: please don't send private questions to me, as I don't have time to
>> provide private support, and so won't reply to such e-mails. All such
>> questions should be posted on public forums, where I and others can see and
>> answer them.
>>
>>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en