I'm creating an android app in android studio and I need to pass a string array from one class to another. It doesn't seem to work thought, and I can't find what's actually wrong. I tried to do it with the constructor.
I will omit unnecessary code.
class MyFragment extends Fragment{
//I create a string array to pass on the other class
public String likeTitles[] ={"mazda","whynot","OHYEAAAaa","ok","1983198312893"};
public MainFragment(String s1[]){
s1= likeTitles;
}
}
public class List extends ListActivity{
String myStringArr[]=new String[5];
MainFragment myFrag = new MainFragment(myStringArr);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getListView().getContext(), android.R.layout.simple_list_item_1, myStingArr);
getListView().setAdapter(adapter);
}
I tried to use a string array from withing the class and it worked fine with my adapter, but this doesn't work.