Here is my code:
public void showScore(Player winner)
{
view.runOnUiThread(new Runnable()
{
public void run()
{
String scored = view.getString(R.string.scored_a_goal);
String score = view.getString(R.string.score);
Toast.makeText(view,winner.name+" "+view.getString(R.string.scored_a_goal),Toast.LENGTH_SHORT).show();
}
});
}
Now everything is fine except for I cannot access winner(of type Player) from inside the Runnable, what is the work around for this?
Just define
winnerasfinal Player winnerand this code should work. Hope this helps.