mardi 19 mai 2015

How to display and hide layouts based on conditions?

I looking for a logic to crack this condition given below.I have a set of eight questions.I made each layout for each questions and answers.ll1 contains question 1 and answers,ll2 contains question 2 and answers ,similarly ll3 upto ll8 contains question 3 to question 8 and their answers.If I enter age(agenum),I have to check for below conditions and display only those questions which I want.Moreover i have to show only two questions in the screen.So when i click next another two questions should come.

if(agenum < 1.5)
    {
        ll2.setVisibility(LinearLayout.GONE);
        ll3.setVisibility(LinearLayout.GONE);
        ll7.setVisibility(LinearLayout.GONE);
        ll8.setVisibility(LinearLayout.GONE);
    }

    else if(agenum<2.5)
    {
        ll7.setVisibility(LinearLayout.GONE);

    }


    else if(agenum <= 4)
    {
        ll8.setVisibility(LinearLayout.GONE);

    }

So if I have given the age as 1,in my first screen question 1 and question 4 should be asked.Similarly based on the above condition next questions should come.So if I given age 2 ,in the first screen question 1 and question 2 should be asked.

Aucun commentaire:

Enregistrer un commentaire