我正在尝试为 Android 实现卫星菜单并在 locat 上收到此错误:
Android android.view.InflateException: Binary XML file line #9: Error inflating class 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);
}
});
并在布局这些行:
<?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>
可能是什么???