2016-06-23 1 views
0

私は別のパッケージからJavaクラスで関数を作成することによって、方法でそれを呼び出すmは...AndroidクラスのJavaクラスへのアクセス方法はパッケージに入れてからですか?

private void drawRegressionLine() { 

    //Toast.makeText(MainActivity.this, "Regression line view ", Toast.LENGTH_SHORT).show(); 

    ArrayList<String> point = new ArrayList<String>(); 

    Algorithm algorithm = new MaxLikelihood() { 

    point = c.KNN(point); 
    plot(point); 
    };` 
+1

アクティビティコードを貼り付けて問題をより明確に記述してください。 –

答えて

0
package firstpackagename; 
import secondpackagename.*; /*add other necessary imports*/ 
public class MainActivity extends Activity {@ 
    Override public void onCreate(Bundle s) { 
     super.onCreate(s); 
     TheClassInOtherPackage X = new TheClassInOtherPackage(); /*If empty constructor used*/ 
     Object o = X.methodInOtherpackage(params1, params2, ....); /*Replace this with X.methodInOtherpackage(...) if method returns voids. Replace object o with the proper return type*/ 
    } 
} 

注 - あなたはまた、同じようにそれを戻り値の型を追加することにより、コンストラクタから値を返すことができますメソッド。お役に立てれば。 :)

関連する問題