How can I log the user's vote for their favorite game from the array in mGames?
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.view.ListView;
public class GameListActivity extends ListActivity {
public String[] mGames = {
"Age of Empires",
"Civilization",
"Minecraft",
"SimCity"
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game_list);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, mGames);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Log.d("List Item: ", "Clicked!");
}
public void sendVote(String game) {
VoteService.recordVote(game);
}
}
The helper method...sendVote(), will log the user's vote for their favorite game...How can i call the correct game from the list?
Aucun commentaire:
Enregistrer un commentaire