mardi 10 mars 2015

Android Fragment , ActionBar


Vote count:

0





I want to add an Image of button in the action bar of a fragment. I want that this button could be shown only for one fragment but not for the other fragments. i wrote in the fragment code:




@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.activity_carte_fragment, container, false);

actionbar=getActivity().getActionBar();
LinearLayout layout=new LinearLayout(getActivity());
layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));
layout.setOrientation(LinearLayout.HORIZONTAL);
layout.setGravity(LinearLayout.VERTICAL);
ImageView add=new ImageView(getActivity());
add.setImageResource(R.drawable.add);
layout.addView(add);
actionbar.setCustomView(layout);



But nothing is shown!




asked 1 min ago







Android Fragment , ActionBar

Aucun commentaire:

Enregistrer un commentaire