我在我的应用程序UI中使用GitHub FlatUI类。我已经使用FlatButtons
成功生成了布局,现在我想为这些按钮设置监听器。如FlatUI示例代码中所述,我将活动中的按钮定义为:
flatButtons.add((FlatButton) findViewById(R.id.buttonCat));
当然,我为所有
FlatButtons
声明了一个数组:private ArrayList<FlatButton> flatButtons = new ArrayList<FlatButton>();
我的问题是如何为该按钮设置监听器?
buttonCat
是xml Layout中我FlatButton的button id
,所以我想我应该在我的活动类中的某个地方定义一个新的FlatButton
,并引用buttonCat
。但是如何? 最佳答案
FlatButton button = (FlatButton) findViewById(R.id.buttonCat);
button.setOnClickListener(your_listener_here);