我有一個Activity和非Activity類。如何從非活性類調用活動類中的方法如何調用非活動類的活動方法
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
DataClass dc = new DataClass();
dc.show();
}
public void call(ArrayList<String> arr) {
// Some code...
}
}
public class DataClass {
public void show(ArrayList<String> array) {
// Here I want to send this ArrayList values into the call
// method in activity class.
MainActivity act = new MainActivity();
act.call(array);
}
}
見也使用它http://stackoverflow.com/questions/19666572/how-to-call-a-method-in-another-activity-from-activity和http: //stackoverflow.com/questions/16653867/android-call-method-from-an-other-activity – RenniePet