Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- at com.app2016.alexker.matchplanning.MatchPlanning.onCreateView(MatchPlanning.java:67)
- 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
- package com.app2016.alexker.matchplanning;
- import android.content.Context;
- import android.graphics.Canvas;
- import android.graphics.Color;
- import android.graphics.Paint;
- import android.graphics.Path;
- import android.view.MotionEvent;
- import android.view.View;
- import android.util.AttributeSet;
- /**
- * Created by AlexKer on 16-02-06.
- */
- public class SimpleDrawingView extends View {
- //set up initial paint color
- private final int paintColor = Color.BLACK;
- //defines paint and canvas
- private Paint drawPaint;
- //path
- private Path path = new Path();
- @Override
- protected void onDraw(Canvas canvas) {
- canvas.drawPath(path, drawPaint);
- }
- public SimpleDrawingView(Context context){
- super(context);
- setFocusable(true);
- setFocusableInTouchMode(true);
- setupPaint();
- }
- public SimpleDrawingView(Context context, AttributeSet attrs){
- super(context, attrs);
- /*setFocusable(true);
- setFocusableInTouchMode(true);
- setupPaint();*/
- }
- private void setupPaint() {
- drawPaint = new Paint();
- drawPaint.setColor(paintColor);
- drawPaint.setAntiAlias(true);
- drawPaint.setStrokeWidth(5);
- drawPaint.setStyle(Paint.Style.STROKE);
- drawPaint.setStrokeJoin(Paint.Join.ROUND);
- drawPaint.setStrokeCap(Paint.Cap.ROUND);
- }
- // Get x and y and append them to the path
- public boolean onTouchEvent(MotionEvent event) {
- float pointX = event.getX();
- float pointY = event.getY();
- // Checks for the event that occurs
- switch (event.getAction()) {
- case MotionEvent.ACTION_DOWN:
- // Starts a new line in the path
- path.moveTo(pointX, pointY);
- break;
- case MotionEvent.ACTION_MOVE:
- // Draws line between last point and this point
- path.lineTo(pointX, pointY);
- break;
- default:
- return false;
- }
- postInvalidate(); // Indicate view should be redrawn
- return true; // Indicate we've consumed the touch
- }
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View view = inflater.inflate(R.layout.fragment_match_planning, container, false);
- return view;
- }
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:id="@+id/fragment_match_plan"
- android:orientation="vertical"
- android:gravity="center|top"
- tools:context="com.app2016.alexker.matchplanning.MatchPlanning"
- android:background="@drawable/field">
- <!-- TODO: Update blank fragment layout -->
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".MainActivity" >
- <com.codepath.example.simpledrawapp.SimpleDrawingView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/SimpleDrawingView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:layout_alignParentRight="true"
- android:layout_alignParentTop="true" />
- </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement