关于使用软键盘布局的InflateException

时间:2014-04-01 12:10:34

标签: android android-layout android-linearlayout android-softkeyboard

我正在使用帖子SoftKeyBoardListener并创建一个自定义类,但是当我在我的activity类中调用它时,所以获得异常

作为

04-01 15:45:28.105: E/AndroidRuntime(21534): java.lang.RuntimeException: Unable to start activity ComponentInfo{mypackage/mypackage.Settings}: android.view.InflateException: Binary XML file line #2: Error inflating class LinearLayoutThatDetectsSoftKeyboard

04-01 15:45:28.105: E/AndroidRuntime(21534):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)

布局

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayoutThatDetectsSoftKeyboard
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/settings"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@color/white" >


    </LinearLayoutThatDetectsSoftKeyboard>

我还在Manifest中定义如下

<activity
        android:name="mypackage.Settings"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="adjustResize" />

将其作为活动创建

LinearLayoutThatDetectsSoftKeyboard mainLayout = (LinearLayoutThatDetectsSoftKeyboard)findViewById(R.id.settings);
         mainLayout.setListener(this);

并且还实施了LinearLayoutThatDetectsSoftKeyboard.Listener

因此,如何引用将LinearLayout扩展为键盘显示/隐藏侦听器的活动的自定义类

1 个答案:

答案 0 :(得分:0)

在布局声明中提供完整的班级名称:

<your.package.name.LinearLayoutThatDetectsSoftKeyboard
... your layout params
/>