I would like to show two views in a service context. One is a TextView, and the other is a class that I have developed extending the basic View class.
prompt.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mtPrompt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/background_dark"
android:text="@string/demoString"
android:textColor="@android:color/white"
android:minLines="2"
android:textSize="25dp" >
</TextView>
and input.xml:
<com.xxx.ime.sssView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/inputView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/translucent_gray"
android:cacheColorHint="@null" >
</com.xxx.ime.sssView>
in my onInitializeInterface() implementation I inflate them as follows:
sssView sv =
(sssView) getLayoutInflater().inflate(R.layout.input, null);
TextView tv =
(TextView) getLayoutInflater().inflate(R.layout.prompt, null);
I see the sssView, but not the TextView. Any ideas why?
Since one view is visible, I decided to use a ViewGroup (LinearLayout) to hold both of my views. In this case, I get an IllegalStateException thrown in InputMethodService.setInputView(), a function which I did not override. The error message says "The specified child already has a parent". I take it that this means that setInputView is tring to re-attach the child views in my LinearLayout. Can (and should) I try to prevent this by overriding setInputView. I guess I'll try and see what happens. – Aharon Manne Jul 11 '12 at 08:05