为Android实现卫星菜单(充气异常:二进制XML文件行#9)

为Android实现卫星菜单(充气异常:二进制XML文件行#9),android,android-menu,Android,Android Menu,我正在尝试为Android实现卫星菜单,并在locat上收到此错误: Android Android.view.InflateException:二进制XML文件行#9:膨胀类com.example.uploadvideo.SatelliteMenu时出错 我在java文件中添加了以下行: SatelliteMenu menu = (SatelliteMenu) findViewById(R.id.menu); // Set from XML, possible to p

我正在尝试为Android实现卫星菜单,并在locat上收到此错误:

Android Android.view.InflateException:二进制XML文件行#9:膨胀类com.example.uploadvideo.SatelliteMenu时出错

我在java文件中添加了以下行:

    SatelliteMenu menu = (SatelliteMenu) findViewById(R.id.menu);

//        Set from XML, possible to programmatically set        
//        float distance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 170, getResources().getDisplayMetrics());
//        menu.setSatelliteDistance((int) distance);
//        menu.setExpandDuration(500);
//        menu.setCloseItemsOnClick(false);
//        menu.setTotalSpacingDegree(60);

        List<SatelliteMenuItem> items = new ArrayList<SatelliteMenuItem>();
        items.add(new SatelliteMenuItem(4, R.drawable.ic_1));
        items.add(new SatelliteMenuItem(4, R.drawable.ic_3));
        items.add(new SatelliteMenuItem(4, R.drawable.ic_4));
        items.add(new SatelliteMenuItem(3, R.drawable.ic_5));
        items.add(new SatelliteMenuItem(2, R.drawable.ic_6));
        items.add(new SatelliteMenuItem(1, R.drawable.ic_2));
//        items.add(new SatelliteMenuItem(5, R.drawable.sat_item));
        menu.addItems(items);        

        menu.setOnItemClickedListener(new SateliteClickedListener() {

            public void eventOccured(int id) {
                Log.i("sat", "Clicked on " + id);
            }
        });
SatelliteMenu菜单=(SatelliteMenu)findViewById(R.id.menu);
//从XML设置,可以通过编程方式设置
//浮动距离=TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,170,getResources().getDisplayMetrics());
//菜单.设置卫星距离((int)距离);
//菜单。设置扩展持续时间(500);
//menu.setCloseItemsOnClick(false);
//菜单。设置总间隔度(60);
列表项=新建ArrayList();
添加(新卫星项目(4,R.drawable.ic_1));
添加(新卫星项目(4,R.drawable.ic_3));
添加(新卫星项目(4,R.drawable.ic_4));
添加(新卫星项目(3,R.drawable.ic_5));
添加(新卫星项目(2,R.drawable.ic_6));
添加(新卫星项目(1,R.drawable.ic_2));
//添加(新卫星项目(5,R.drawable.sat_项目));
菜单.附加项(项目);
menu.setOnItemClickedListener(新的卫星ClickedListener(){
发生公共无效事件(int-id){
Log.i(“sat”,“点击”+id);
}
});
在这些行的布局中:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:sat="http://schemas.android.com/apk/res/com.example.uploadvideo"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <com.example.uploadvideo.SatelliteMenu  <!-- here the problem line 9 -->
        android:id="@+id/menu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|left" 
        android:layout_margin="8dp"
        sat:satelliteDistance="170dp"
        sat:mainImage="@drawable/ic_launcher"
        sat:totalSpacingDegree="90"
        sat:closeOnClick="true"
        sat:expandDuration="500"/>

</FrameLayout>


如果您在eclipse中包含了附属菜单项目(它是库项目),那么您需要使用库项目中指定的包名。如果要更改包名,则必须将库项目的src和res文件夹复制到项目中并相应重命名。 我建议您按原样使用(即像图书馆项目一样)。

solotuion:由于图书馆项目,这行“com.example.uploadvideo.SatelliteMenu”需要是“android.view.ext.SatelliteMenu”,并且需要清理项目。非常感谢。