Right, so my problem is that I have 18 spinners containing 43 options for a user to select. I want each option to change a link on a different page in order for the user to look at a pdf regarding that option. I have got the shared preferences to work to share the selection and I'm now implementing my if/else if statements but if I do use if/else statements, I will end up with 43 for each spinner and then 43 for each spinner after, ending up me needing to implement over 700 if statements and there has to be an easier way of implementing my idea that I don't know about. Here is a code sample:
if (spinnerValue == 1)
{
TextView textView =(TextView)findViewById(R.id.textViewWeb1);
textView.setClickable(true);
textView.setMovementMethod(LinkMovementMethod.getInstance());
String text = "<a href='http://ift.tt/1SpmNmU'>Unit 1: Communication and Employability Skills for IT</a>";
textView.setText(Html.fromHtml(text));
}
else if (spinnerValue == 2){
TextView textView =(TextView)findViewById(R.id.textViewWeb1);
textView.setClickable(true);
textView.setMovementMethod(LinkMovementMethod.getInstance());
String text = "<a href='http://ift.tt/1TeCQ3K'>Unit 2: Computer Systems</a>";
textView.setText(Html.fromHtml(text));
}
else if (spinnerValue == 3){
TextView textView =(TextView)findViewById(R.id.textViewWeb1);
textView.setClickable(true);
textView.setMovementMethod(LinkMovementMethod.getInstance());
String text = "<a href='http://ift.tt/1Sn9cth'>Unit 3: Information Systems</a>";
textView.setText(Html.fromHtml(text));
}
So at the end of this, there will be 43 if (spinnervalue == 1 through 43) and 18 spinnervalues. I am very new to java and android studio so any help or guidance perhaps with an explanation with this is much appreciated.
Aucun commentaire:
Enregistrer un commentaire