/Code/src/com/game/ViewData/HowViewData.java

https://bitbucket.org/DeveloperUX/behaviortree · Java · 55 lines · 35 code · 9 blank · 11 comment · 0 complexity · 6e79491c7102cbdf2f0f9f8d5470898e MD5 · raw file

  1. package com.game.ViewData;
  2. import com.game.MessageHandler;
  3. import com.game.MsgType;
  4. import com.game.R;
  5. import com.game.MessageHandler.MsgReceiver;
  6. import android.app.Activity;
  7. import android.content.Context;
  8. import android.util.Log;
  9. import android.view.LayoutInflater;
  10. import android.view.View;
  11. import android.view.View.OnClickListener;
  12. import android.widget.Button;
  13. import android.widget.LinearLayout;
  14. /**
  15. * Specific view data class for the "How to play" screen.
  16. * @author Ying
  17. *
  18. */
  19. public class HowViewData extends ViewData
  20. {
  21. /**
  22. * @see ViewData createXMLView(Activity activity)
  23. */
  24. @Override
  25. public View createXMLView(Activity activity)
  26. {
  27. Log.i("HowViewData", "createXMLView");
  28. // Access xml layout
  29. LayoutInflater li = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  30. View xmlLayout = (View) li.inflate(R.layout.how, null);
  31. // Centers the text and makes it fit inside the column width
  32. LinearLayout centerLinerarLayout = (LinearLayout)xmlLayout.findViewById(R.id.how_layout_inner_scroll);
  33. this.Set80PercentWidth(activity, centerLinerarLayout);
  34. // Callback for the buttons
  35. Button okButton = (Button) xmlLayout.findViewById(R.id.ok_how_but);
  36. okButton.setOnClickListener(new OnClickListener()
  37. {
  38. @Override
  39. public void onClick(View v) {
  40. Log.i("ViewData", " Clicked OK button");
  41. MessageHandler.Get().Send(MsgReceiver.LOGIC,MsgType.BUTTON_CLICK, R.id.ok_how_but);
  42. }
  43. });
  44. return xmlLayout;
  45. }
  46. }