I want to put ArrayList on onClick method. But it tell me i should change arraylist to final(i will put something in there so can't). how should i put arraylist in it!?
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView txt1;
Button btn1;
ArrayList <String> shop= new ArrayList <String>();
impshop(shop);
txt1 =(TextView)findViewById(R.id.tv1);
btn1 =(Button)findViewById(R.id.button1);
btn1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Random ran = new Random();
int choose = ran.nextInt(shop.size());
txt1.setText(shop.get(choose));
}});
}
can i onClick(View v,ArrayList shop) ?