i try to create BottomBar with this video
But, i have an existing project, with few class already implement, and when i try to change AppCompatActivity by Fragment, my old method/class are inaccessible
an excract of old class :
public class ChoixFormulaire extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView=inflater.inflate(R.layout.activity_choix_formulaire,container,false);
return rootView;
}
public void formJ(View v){
Intent i = new Intent(ChoixFormulaire.this,RechercheJournalier.class);
startActivity(i);
}
public void formP(View v){
Intent i = new Intent(ChoixFormulaire.this,FormulaireRecherche.class);
startActivity(i);
}
public void retourF(View v){
Intent i = new Intent(ChoixFormulaire.this,RechercheDuJour.class);
startActivity(i);
}
But, the fort this part :
(ChoixFormulaire.this,RechercheJournalier.class);
(ChoixFormulaire.this,FormulaireRecherche.class);
(ChoixFormulaire.this,RechercheDuJour.class);
I have this error :
"Cannot resolve constructor 'Intent(com.appli.cci.ports2a.Recherches.ChoixFormulaire, java.lang.Class<com.appli.cci.ports2a.Recherches.RecherchesJournalier>)'
Intents need to be created with the parent activity or the application context.So You need to use your Fragment's Parent Activity Context
Intent intent = new Intent(getActivity(),MyClass.class);
you need you pass array from first activity like this :-
Bundle bundle=new Bundle();
bundle.putStringArray(key, new String[]{value1, value2});
Intent i=new Intent(context, Class);
i.putExtras(bundle);
you can get array from other activity like this
Bundle bundle=this.getIntent().getExtras();
String[] array=bundle.getStringArray(key);
you are not using context properly check this.
public void formJ(View v){
Intent i = new Intent(getActivity(),RechercheJournalier.class);
startActivity(i);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.