如何处理错误膨胀类?

时间:2014-10-21 05:30:05

标签: android android-progressbar

我在项目中添加了一个新的Progress bar lib。我通过maven添加了它。然后我使用了布局文件中的进度条。在运行App时,它会显示此错误。

 Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class com.github.castorflex.android.circularprogressbar.CircularProgressBar

这是我使用的图书馆https://github.com/castorflex/SmoothProgressBar

我的布局文件

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"
    tools:ignore="MergeRootFrame">

    <ListView
        android:id="@+id/feed_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.github.castorflex.android.circularprogressbar.CircularProgressBar

        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:indeterminate="true"
        android:id="@+id/progressBar"
        app:cpb_color="#FFee44"
        app:cpb_colors="@array/colors"
        app:cpb_rotation_speed="1.0"
        app:cpb_sweep_speed="1.0"
        app:cpb_stroke_width="4dp"
        app:cpb_min_sweep_angle="10"
        app:cpb_max_sweep_angle="300"
        />
</FrameLayout>

我的班级

public class VideoActivity extends Activity {

    private static final String TAG = "Mine";


    private static final int REQ_START_STANDALONE_PLAYER = 1;
    private static final int REQ_RESOLVE_SERVICE_MISSING = 2;

    public static final String DEVELOPER_KEY = "AIzaSyDcnoqJGI1872s";

    public ListView listView;
    private FeedListAdapter listAdapter;
    private List<FeedItem> feedItems;
    public String mvideoid;
    public String mstatus;
    ProgressBar progressBar;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feed_list);
        progressBar = (ProgressBar) findViewById(R.id.progressBar);
        progressBar.setVisibility(View.VISIBLE);
        listView = (ListView) findViewById(R.id.feed_list);
        feedItems = new ArrayList<FeedItem>();
        listAdapter = new FeedListAdapter(this, feedItems);
        listView.setAdapter(listAdapter);

         // making fresh volley request and getting json
        GsonRequest<FeedResult> gsonRequest = new GsonRequest<FeedResult>(URL_FEED, FeedResult.class,
                new Response.Listener<FeedResult>() {
                    @Override
                    public void onResponse(FeedResult response) {
                        feedItems = response.getFeedItems();
                        listAdapter.setData(feedItems);
                        listAdapter.notifyDataSetChanged();
                        progressBar.setVisibility(View.INVISIBLE);
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.d(TAG, "Error: " + error.getMessage());
                    }
                });


        // Adding request to volley request queue
        AppController.getInstance().addRequest(gsonRequest, TAG);
        getid();
    }
}

2 个答案:

答案 0 :(得分:1)

尝试替换为:

xmlns:app="http://schemas.android.com/apk/res/com.android.demo"

此值(com.android.demo)替换为您的包名称。

答案 1 :(得分:0)

如果您使用任何自定义组件,请使用相同的名称引用它,即

 import com.github.castorflex.android.circularprogressbar.CircularProgressBar;


    public class VideoActivity extends Activity {

     CircularProgressBar progressBar; 
    .
    .

      @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_feed_list);
            progressBar = (CircularProgressBar) findViewById(R.id.progressBar);
    .
    .
    .

您正在使用xml中不存在的默认值