【问题标题】:android.view.InflateException: Binary XML file line #6: Error inflating class <unknown>android.view.InflateException: Binary XML file line #6: Error inflating class <unknown>
【发布时间】:2014-02-07 10:44:43
【问题描述】:

我是安卓新手。 我收到错误为 android.view.InflateException: Binary XML file line #6: Error inflating class 。早些时候,此活动运行良好。但是突然出现这个错误。多次清理项目。但是没用。

Xml 布局是:

<AbsoluteLayout 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=".FragDownloadSites" >

    <ExpandableListView
        android:id="@+id/lvDownloadSite"
        android:layout_width="fill_parent"
        android:layout_height="610dp"
        android:layout_x="0dp"
        android:layout_y="70dp" >
    </ExpandableListView>

    <TextView
        android:id="@+id/tvDownloadSiteMessage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="30dp"
        android:layout_y="21dp"
        android:text="Downloaded Sites"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <ImageButton
        android:id="@+id/btnDownloadSite"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_x="540dp"
        android:layout_y="10dp"
        android:src="@drawable/refresh" />

</AbsoluteLayout>

代码是:

package com.example.config;

import android.support.v4.app.Fragment;


public class FragDownloadSites extends Fragment implements SiteDataInterface {
    View rootView;
    ExpandableListView expListView;
    TextView tvMsg;
    ProgressDialog progress;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.frag_download_sites, container, false);

        progress = new ProgressDialog(rootView.getContext());
        progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progress.setCancelable(false);
        progress.setMessage("Loading...");

        tvMsg=(TextView)rootView.findViewById(R.id.tvDownloadSiteMessage);

        // get the listview
        expListView = (ExpandableListView)rootView.findViewById(R.id.lvDownloadSite);
        DisplaySiteData();

        return rootView;
    }

提前致谢。

【问题讨论】:

  • 什么是android:layout_x="0dp" android:layout_y="70dp"
  • 请不要使用已弃用的 AbsoluteLayout

标签: android


【解决方案1】:

此类在 API 级别 3 中已弃用。 请改用 FrameLayout、RelativeLayout 或自定义布局。

另外,绝对布局比其他类型的布局更不灵活且更难维护,并且 绝对定位在各种屏幕分辨率和纵横比的世界中并没有太大用处。

所以请使用其他布局。 这个答案可以帮助你吗...

谢谢

【讨论】:

    猜你喜欢
    • 2011-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多