java - Calculate the distance between two points -
i tried following code.but gives 2 errors.i want calculate distance between 2 points formula line , display result in textview1. not know did make mistake in code?
cal.java
import android.view.view; import android.content.context; import java.lang.math; public class cal extends view { cal(context context){ super(context); } public double result; double parameter = ((10-80)^2) + ((15-90)^2); public void cal(){ result = math.sqrt(parameter); } }
mainactivity.java
import android.app.activity; import android.os.bundle; import android.widget.textview; public class mainactivity extends activity{ cal cal; textview textview; public void oncreate(bundle s){ super.oncreate(s); setcontentview(r.id.textview1); cal = new cal(this); textview.settext(cal).; } }
errors:
gradle: failure: build failed exception.
what went wrong: execution failed task ':www:compiledebug'.
compilation failed; see compiler error output details.
try: run --stacktrace option stack trace. run --info or --debug option more log output.
and
could not execute build using gradle distribution 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.
import android.app.activity; import android.os.bundle; import android.widget.textview; public class mainactivity extends activity{ cal cal; textview textview; public void oncreate(bundle s){ super.oncreate(s); setcontentview(r.layout.<your layout name>); // can not set id of view here cal = new cal(this); // object cal.cal(); textview.settext(""+ cal.result); // set value instead of view object } }
Comments
Post a Comment