2017-05-04 11 views

答えて

1
@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    getMenuInflater().inflate(R.menu.menu,menu); 
    for (int i = 0; i < menu.size(); i++) { 
     if (i%2==0){ 
      //If it is even 
      menu.getItem(i).getActionView().setBackground(); 
     }else{ 
      //If it is odd 
      menu.getItem(i).getActionView().setBackground(); 
     } 
    } 
    return super.onCreateOptionsMenu(menu); 
} 
+0

メニューが便利な「actionViewClass'」はありますか? – dengyuhan

0

はあなたのcustom adapter getView()方法でこの方法を実装することができます -

if (position % 2 == 0) { 
rowView.setBackgroundColor(Color.parseColor("#A4A4A4")); 
} else { 
rowView.setBackgroundColor(Color.parseColor("#FFBF00")); 
} 

私はその後、私に教えてくださいされていない場合、これは、あなたを助けることを願っています。

関連する問題