android - Call Method from one package to another -
I am beginning to be in this area. How can I access one package from one package to another?
For example:
adding packages; Public class surplus {int a, b, sum; Public int plus (int x, int y) {a = x; B = y; Yoga = A + B; Refund Amount; }} In my other package
package com.example.demoo; Public Class Main Activity ActionBarActivity Extensively Created on {@ Override Protected Zero (Bundled Saved Instance) {Super. SetContentView (R.layout.activity_main); Difference result; Addfunction addfunction = new Addfunction (); Results = addfunction.add (5, 10); Toast. Make text (getApplicationContext (), results, toast.lNGTH_LONG). Show (); }} shows it unfortunately the app is closed while running. Please help me solve it.
You should consider
First, you must add an import for the Addfunction class before the main activity class definition:
import Add more. Although you already have this because it will not be compiled otherwise.
Secondly, you might make it a makeText :
Static Toast Maketext (Reference Reference, Extreme Text, Inter Duration)
& nbsp; & Nbsp; & Nbsp; & Nbsp; Make a standard toast that has just one text view.
Note that the second parameter is a int first case that is referred to by a resource. And you are just giving the result of your calculation, which is probably an invalid resource ID.
You can try to create a message in the string object and pass it to maketext , like this:
string msg = "results:" + result; Toast. Make text (getApplicationContext (), msg, toast.lnn.gov_LOG). Show ();
Comments
Post a Comment