vendredi 15 juillet 2016

the variable doesn't change accordingly [duplicate]

This question already has an answer here:

i have written following code, but the toast still shows 0.0 and the activity_level variable does not change accordingly. what is wrong??

public class ESFragment extends Fragment {
    double bmr;
    double activity_level;

    public ESFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.es_fragment, container, false);
        try {
            //some code ...
            //activity level (when one of image buttons related to activity status are selected, the activity level value changes
            if (activity_light.getContentDescription() == getString(R.string.ic_light_activity_active)) {
                activity_level = 1.2;
            } else if (activity_moderate.getContentDescription() == getString(R.string.ic_moderate_activity_active)) {
                activity_level = 1.4;
            }
            Toast.makeText(getContext(),activity_level + "",Toast.LENGTH_LONG).show();
        } catch (Exception e) {
            //...
        }
        return view;
    }
    ...
}

Aucun commentaire:

Enregistrer un commentaire