我试图将 OnClickListener 添加到它由数组中的值生成的按钮中,但我没有这样做,这里有什么建议吗?
long lprice = Long.parseLong(searchId.getText().toString());
List<String> buttonNameOne = dbc.getItemNameRbPrice(lprice);
List<String> buttonPriceOne = dbc.getPriceRbPrice(lprice);
List<String> buttonDateOne = dbc.getCurrentDateRbPrice(lprice);
for(int i = 0 ; i < buttonNameOne.size() ; i ++)
{
Button btn = new Button(this);
btn.setId(2000+i);
btn.setText(buttonNameOne.get(i) + i);
linearButton.addView(btn, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
Log.v("Value of element "+i, buttonNameOne.get(i));
Log.v("Value of element "+i, buttonPriceOne.get(i));
Log.v("Value of element "+i, buttonDateOne.get(i));
}