在项目中设置android视图库

时间:2013-05-02 16:11:41

标签: java android

我正在尝试使用github中的Gauge View在我的新项目中 随库提供的示例应用程序完美无缺!

但是当我尝试将库包含到新项目中时(属性> buildpath>项目>(添加库项目)),将视图放在我的布局中并尝试在代码中获取对视图的引用抛出ClassNotFoundException

以下是我的布局:

<LinearLayout 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"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <org.codeandmagic.android.gauge.GaugeView
     android:id="@+id/gauge_view1"
     android:layout_width="match_parent"
     android:layout_height="0dp"
     android:layout_weight="1" />


</LinearLayout>

这是我的活动

package com.example.guagetest;

import org.codeandmagic.android.gauge.GaugeView;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    private GaugeView gauge;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        gauge = (GaugeView) findViewById(R.id.gauge_view1);
        gauge.setTargetValue(10);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

有人可以告诉我如何在新项目中导入和使用此视图。

我一直在尝试将其设置为一个新项目超过4个小时,就像在github页面上的示例项目中设置它一样。 但我没有运气。

有人请帮忙。

0 个答案:

没有答案