【问题标题】:Trying to add a fragment from another library - android尝试从另一个库添加片段 - android
【发布时间】:2014-01-20 14:39:20
【问题描述】:

我正在尝试添加以下库:

https://github.com/infospace/android_oauth2_webview

到我的项目,但我收到一个错误:

Class is not a View android.support.v4.app.Fragment

(我还更新了库和我的项目的 v4 支持库) 这是我的项目主页:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"

tools:context=".MainActivity" >
<android.support.v4.app.Fragment
    android:id="@+id/webview"
    android:name="com.infospace.android.oauth2.AuthenticationFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     />

我做错了什么?

提前致谢, 丁。

【问题讨论】:

    标签: android fragment feedly


    【解决方案1】:

    如果您从支持库中包含Fragments,则需要使用FragmentActivity 而不是Activity

    【讨论】:

    • 起初是片段给了我:“错误膨胀类片段”,直到我看到stackoverflow.com/questions/11873794/…任何其他想法?
    • @dinbrca:对不起,我的回答错了;我看到这个答案在一个类似的问题上被接受,并且不假思索地复制了它。你在使用 FragmentActivity 这个布局膨胀了吗?
    • No.. 该库使用 Fragment 而不是 FragmentActivity。虽然 - 我试图手动将它从 Fragment 转换为 FragmentActivity 并得到另一个错误..
    • @dinbrca:如果您使用支持库中的Fragments,则需要将Activitys 转换为FragmentActivitys。
    • 我已经尝试从片段转换为 FragmentActivity.. 它给了我“类不是视图 android.support.v4.app.FragmentActivity”
    猜你喜欢
    • 1970-01-01
    • 2013-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多