Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add item in array list of android [closed]

I want to add value getting from text view of android to an existing array list.e.g. my current array list contain values Cricket,Football and by text view I want to add hockey in array list at last position ..then my array list become Cricket ,football,hockey. My array list of cricket and football is coming from previous activity. But now it add only cricket and football but does not add hockey How can I do it?

 resultArrGame+=resultArrGame.add(txtGame.getText().toString());
like image 423
shrutipawar111 Avatar asked Mar 20 '13 12:03

shrutipawar111


2 Answers

This will definitely work for you...

ArrayList<String> list = new ArrayList<String>();

list.add(textview.getText().toString());
list.add("B");
list.add("C");
like image 90
Mitul Goti Avatar answered Sep 17 '22 20:09

Mitul Goti


You're trying to assign the result of the add operation to resultArrGame, and add can either return true or false, depending on if the operation was successful or not. What you want is probably just:

resultArrGame.add(txt.Game.getText().toString());
like image 21
Rickard Avatar answered Sep 17 '22 20:09

Rickard