Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. at com.app2016.alexker.matchplanning.MatchPlanning.onCreateView(MatchPlanning.java:67)
  2.  
  3. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app2016.alexker.matchplanning/com.app2016.alexker.matchplanning.MainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class com.codepath.example.simpledrawapp.SimpleDrawingView
  4.  
  5. package com.app2016.alexker.matchplanning;
  6.  
  7. import android.content.Context;
  8. import android.graphics.Canvas;
  9. import android.graphics.Color;
  10. import android.graphics.Paint;
  11. import android.graphics.Path;
  12. import android.view.MotionEvent;
  13. import android.view.View;
  14. import android.util.AttributeSet;
  15.  
  16. /**
  17. * Created by AlexKer on 16-02-06.
  18. */
  19. public class SimpleDrawingView extends View {
  20. //set up initial paint color
  21. private final int paintColor = Color.BLACK;
  22. //defines paint and canvas
  23. private Paint drawPaint;
  24. //path
  25. private Path path = new Path();
  26.  
  27. @Override
  28. protected void onDraw(Canvas canvas) {
  29. canvas.drawPath(path, drawPaint);
  30. }
  31.  
  32. public SimpleDrawingView(Context context){
  33. super(context);
  34. setFocusable(true);
  35. setFocusableInTouchMode(true);
  36. setupPaint();
  37. }
  38.  
  39. public SimpleDrawingView(Context context, AttributeSet attrs){
  40. super(context, attrs);
  41. /*setFocusable(true);
  42. setFocusableInTouchMode(true);
  43. setupPaint();*/
  44. }
  45.  
  46. private void setupPaint() {
  47. drawPaint = new Paint();
  48. drawPaint.setColor(paintColor);
  49. drawPaint.setAntiAlias(true);
  50. drawPaint.setStrokeWidth(5);
  51. drawPaint.setStyle(Paint.Style.STROKE);
  52. drawPaint.setStrokeJoin(Paint.Join.ROUND);
  53. drawPaint.setStrokeCap(Paint.Cap.ROUND);
  54. }
  55.  
  56. // Get x and y and append them to the path
  57. public boolean onTouchEvent(MotionEvent event) {
  58. float pointX = event.getX();
  59. float pointY = event.getY();
  60. // Checks for the event that occurs
  61. switch (event.getAction()) {
  62. case MotionEvent.ACTION_DOWN:
  63. // Starts a new line in the path
  64. path.moveTo(pointX, pointY);
  65. break;
  66. case MotionEvent.ACTION_MOVE:
  67. // Draws line between last point and this point
  68. path.lineTo(pointX, pointY);
  69. break;
  70. default:
  71. return false;
  72. }
  73.  
  74. postInvalidate(); // Indicate view should be redrawn
  75. return true; // Indicate we've consumed the touch
  76. }
  77. }
  78.  
  79. @Override
  80. public View onCreateView(LayoutInflater inflater, ViewGroup container,
  81. Bundle savedInstanceState) {
  82. // Inflate the layout for this fragment
  83. View view = inflater.inflate(R.layout.fragment_match_planning, container, false);
  84. return view;
  85. }
  86.  
  87. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  88. xmlns:tools="http://schemas.android.com/tools"
  89. android:layout_width="match_parent"
  90. android:layout_height="match_parent"
  91. android:id="@+id/fragment_match_plan"
  92. android:orientation="vertical"
  93. android:gravity="center|top"
  94. tools:context="com.app2016.alexker.matchplanning.MatchPlanning"
  95. android:background="@drawable/field">
  96.  
  97. <!-- TODO: Update blank fragment layout -->
  98.  
  99. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  100. xmlns:tools="http://schemas.android.com/tools"
  101. android:layout_width="match_parent"
  102. android:layout_height="match_parent"
  103. tools:context=".MainActivity" >
  104.  
  105. <com.codepath.example.simpledrawapp.SimpleDrawingView
  106. xmlns:android="http://schemas.android.com/apk/res/android"
  107. android:id="@+id/SimpleDrawingView"
  108. android:layout_width="wrap_content"
  109. android:layout_height="wrap_content"
  110. android:layout_alignParentBottom="true"
  111. android:layout_alignParentLeft="true"
  112. android:layout_alignParentRight="true"
  113. android:layout_alignParentTop="true" />
  114.  
  115. </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement