2014-02-12 70 views
0

喜的朋友我在程序追加SatelliteMenu像這樣SatelliteMenuItem文字與圖像inandroid

SatelliteMenuItem a1=new SatelliteMenuItem(4, R.drawable.ic_4); 

    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(a1); 
    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)); 
    menu.addItems(items); 

但問題是我不能夠設置文本與圖像SatelliteMenuItem。 請建議我如何在SatelliteMenuItem中添加文字圖像

在此先感謝。

+0

需要更改庫項目中的'SatelliteMenuItem'類... –

+0

如何更改此類或有任何其他庫? – deep

+0

不完全知道,但你需要將String參數添加到'SatelliteMenuItem的構造函數'然後添加這個字符串作爲菜單項文本....但我認爲在這個菜單圖標與文本沒有看起來更好...所以不需要添加文本如果不是非常需要... –

回答

0

你必須改變SatelliteMenuItem的構造一樣,因爲它是...

public SatelliteMenuItem(int id, int imgResourceId,String string) { 
    this.imgResourceId = imgResourceId; 
    this.string=string; 
    this.id = id; 
}  

public SatelliteMenuItem(int id, Drawable imgDrawable,String string) { 
    this.imgDrawable = imgDrawable; 
    this.string=string; 
    this.id = id; 
} 

它的庫SatelliteMenuItem。添加一個更多的參數爲String或Textview, 嘗試下面給出的這個類的一些方法。 可能會給你一些想法。