Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 服务显示视图GetLayoutFlater_Android_Android Service_Android Inflate - Fatal编程技术网

Android 服务显示视图GetLayoutFlater

Android 服务显示视图GetLayoutFlater,android,android-service,android-inflate,Android,Android Service,Android Inflate,我想在服务上下文中显示两个视图。一个是TextView,另一个是我开发的扩展基本视图类的类。 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"

我想在服务上下文中显示两个视图。一个是TextView,另一个是我开发的扩展基本视图类的类。 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>

我看到了sssView,但没有看到TextView。知道为什么吗?

这不是一个很好的答案,但它是一个解决方案。我所需要做的不是拥有两个独立的视图,而是从TextView而不是view继承sssView。然后我膨胀了一个视图,并使用重力将文本放置在我想要的位置。

是否将两者都设置为setContentView?否,因为我在软键盘上工作的示例没有调用setContentView。为了打那个电话,我必须推断活动,这听起来不对。休息后继续调查这个。。。由于一个视图可见,因此我决定使用视图组线性布局来保存这两个视图。在本例中,我在InputMethodService.setInputView中抛出了一个IllegalStateException,我没有重写该函数。错误消息表示指定的子级已具有父级。我认为这意味着setInputView试图在我的LinearLayout中重新附加子视图。我可以也应该尝试通过重写setInputView来防止这种情况。我想我会试试看会发生什么。用不做任何事情的函数覆盖setInputView可以避免异常,但会使我的IME完全不可见。如果我删除子视图,然后调用super.setInputView呢?这也没有帮助,返回到包含两个独立视图的版本,每个视图都独立膨胀。在软键盘示例中,有一个键盘视图和一个画布,其中似乎包含我找不到的所有候选内容。在任何情况下,都可以对两个UI实体进行充气。
<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>
 sssView sv = 
        (sssView) getLayoutInflater().inflate(R.layout.input, null);
 TextView tv = 
        (TextView) getLayoutInflater().inflate(R.layout.prompt, null);