Я пытаюсь изменить текст в TextView на основе строки предыдущего представления с Listview.Изменить Textview на основе String
По какой-то причине он продолжает возвращать ошибку. Вот мой код:
public class LyricsFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
/** Inflating the layout country_details_fragment_layout to the view object v */
View v = inflater.inflate(R.layout.learnlyrics, null);
/** Getting the textview object of the layout to set the details */
TextView tv = (TextView) v.findViewById(R.id.learnsong);
Bundle b = getArguments();
tv.setText("Details of " + Country.name[b.getInt("position")]);
int position = b.getInt("position");
String s = b.getInt("position");
if (s.startsWith("Pretty Hurts")) {
tv.setText("[Intro]\\nHarvey Keitel: Ms. Third Ward, your first question -- what is your aspiration in life?\\n" +
"Beyoncé: Oh, my aspiration in life would be to be happy\\n\\n[Verse 1]\\nMama said, you're a pretty girl\\n " +
"What's in your head it doesn't matter\\nBrush your hair, fix your teeth\\nWhat you wear is all that matters\\n\\n[Pre-Hook]\\nJust another stage\\nPageant the pain away\\nThis time I'm gonna take the crown\\nWithout falling down, down\\n\\n[Hook]\\nPretty hurts\\nWe shine the light on whatever's worse\\nPerfection is the disease of a nation\\nPretty hurts, pretty hurts\\nWe shine the light on whatever's worse\\nTryna fix something\\nBut you can't fix what you can't see\\nIt's my soul that needs the surgery\\n\\n[Verse 2]\\nBlonder hair, flat chest\\nTV says bigger is better\\nSouth beach, sugar free\\nVogue says thinner is better\\n\\n[Pre-Hook + Hook]\\n\\n[Bridge]\\nAin’t got no doctor or pill that can take the pain away\\nThe pain's inside\\nAnd nobody frees you from your body\\nIt's the soul, its the that needs surgery\\nIt's the soul that needs surgery\\nPlastic smiles and denial can only take you so far\\nThen you break when the fake facade leaves you in the dark\\nYou left a shattered mirror\\nAnd the shards of a beautiful girl\\n\\n[Hook]\\n\\n[Outro]\\nWhen you're alone all by yourself\\nAnd you're lying in your bed\\nReflection stares right into you\\nAre you happy with yourself?\\nIt's just a way to masquerade\\nThe illusion has been shed\\nAre you happy with yourself?\\nAre you happy with yourself?\\nYes\\n");
}
return v;
}
}
Существо ошибки:
String s = b.getInt("position");
В качестве нового разработчика Android, я не знаю, почему? Пожалуйста помоги.
попробовать 'указатель на строку = String.valueOf (b.getInt («позиция»));' – JonasCz
Спасибо за ответ так быстро. Ошибка больше не существует, но текст по-прежнему не изменяется :( – HalesEnchanted
Вы видите что-нибудь в LogCat? Где находятся данные в вашем 'Bundle b = getArguments();' from? – JonasCz