2016-06-23 3 views
0

내가 다른 패키지에서 자바 클래스와 기능을 만들어 방법을 호출 해요 ..안드로이드 액티비티에서 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*/ 
    } 
} 

주 - 당신은 또한 단지처럼에 반환 유형을 추가하여 생성자의 값을 반환 할 수 있습니다 행동 양식. 희망이 도움이됩니다. :)

관련 문제