2013-04-25 55 views
0

建立一個衛星菜單我已經指出朝着這個項目位置:在我的項目

https://github.com/siyamed/android-satellite-menu

在下載看起來是巨大的。但我無法在我的應用程序中獲得簡單的版本。我已經添加了提供給我的項目的.jar,它出現在dependsancys中。我遇到的問題是xml文件。它是這樣提供的:

<?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/android.view.ext" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <android.view.ext.SatelliteMenu 
     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> 

SO上的另一篇文章說將包類型更改爲您自己的包。所以,我把它改爲:

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

但我仍然得到這個錯誤的XML文件:

Multiple annotations found at this line: 
    - error: No resource identifier found for attribute 'satelliteDistance' in package 
    'android.view.ext' 
    - error: No resource identifier found for attribute 'mainImage' in package 'android.view.ext' 
    - error: No resource identifier found for attribute 'closeOnClick' in package 
    'android.view.ext' 
    - error: No resource identifier found for attribute 'expandDuration' in package 
    'android.view.ext' 
    - error: No resource identifier found for attribute 'totalSpacingDegree' in package 
    'android.view.ext' 

我試圖改變這裏也包減速:

<android.view.ext.SatelliteMenu 
    android:id="@+id/menu" 

和其中一個的組合。但我只是不斷收到同樣的錯誤。

我在做什麼錯?

回答

2

變化

xmlns:sat="http://schemas.android.com/apk/res/android.view.ext 

xmlns:sat="http://schemas.android.com/apk/res-auto" 

這應該工作,爲我工作雖然。

不要忘記清理您的項目。

0
SatelliteMenu menu = (SatelliteMenu) findViewById(R.id.satelliteMenu1); 
    float distance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 170, getResources().getDisplayMetrics()); 
    //The distance of items from the center button 
    menu.setSatelliteDistance((int) distance); 
    //The duration of expand and collapse operations in milliseconds. 
    menu.setExpandDuration(300); 
    menu.setCloseItemsOnClick(true); 
    //The degree between the first and the last item. 
    menu.setTotalSpacingDegree(120); 

    List<SatelliteMenuItem> items = new ArrayList<SatelliteMenuItem>(); 
    items.add(new SatelliteMenuItem(6, R.drawable.ic_action_search)); 
    items.add(new SatelliteMenuItem(5, R.drawable.ic_action_search)); 
    items.add(new SatelliteMenuItem(4, R.drawable.ic_action_search)); 
    items.add(new SatelliteMenuItem(3, R.drawable.ic_action_search)); 
    items.add(new SatelliteMenuItem(2, R.drawable.ic_action_search)); 
    items.add(new SatelliteMenuItem(1, R.drawable.ic_action_search)); 
    menu.addItems(items); 

從項目屬性中添加衛星菜單作爲庫。然後,您將在自定義和庫視圖中將衛星菜單拖放到xml文件中。然後把上面的代碼放到你的java文件中,它實際上爲衛星菜單設置了數據。