I have the following part of my code:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.llanterna_fragment,
container, false);
ImageButton button = (ImageButton) view.findViewById(R.id.estrellaOn);
ImageButton button2 = (ImageButton) view.findViewById(R.id.estrellaOff);
button.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
switch (v.getId()){
case R.id.estrellaOn:
//Apretar mostramos texto
// Toast.makeText(getActivity(), "Activar flash!", Toast.LENGTH_SHORT).show();
//ocultamos estrella
// getView().setVisibility(View.GONE);
// estrellaOn.setVisibility(View.VISIBLE);
// estrellaOff.setVisibility(View.VISIBLE);
break;
case R.id.estrellaOff:
//Apretar mostramos texto
Toast.makeText(getActivity(), "Desactivar flash!", Toast.LENGTH_SHORT).show();
//mostramos estrella
estrellaOff.setVisibility(View.GONE);
break;
}
}
});
return view;
}
In the layout I created two images: Star On and Star Off
The idea is that when you click on the StarOn button, hide and show the one that is hidden. But I do not get it.
What am I doing wrong?
regards,