There is a side menu Expandable Navigation Drawer. To click something on an element, I used switch/case.
case 1: switch (childPosition) { case 0: break; case 1: break; case 2: break; case 3: break; default: break; } break; default: break; Where case 1 is the menu item is open, and case 0; case 1; case 2; case 3 case 0; case 1; case 2; case 3 case 0; case 1; case 2; case 3 - the subitem of the menu is open.
There is a fragment with markup in which the textview is located.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/selected_item" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/frag1_text"> </TextView> </LinearLayout> In this textview , the text should be removed from the string, depending on the clicked sub-element ( case ). Since I don’t have one fragment, I call it first in the case.
case 1: switch (childPosition) { case 0: fTrans.replace(R.id.frgmCont, frag1); break; default: break; } break; default: break; I prescribe in the fragment class:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment1, null); mSelectedItemView = (TextView) v.findViewById(R.id.selected_item); mSelectedItemView.setText(Html.fromHtml(getResources().getString(R.string.selected_item), null, new MyHtmlTagHandler())); return v; } } Now, when calling a fragment in case 0 — its markup with a TextView is called, which takes text from string.selected_item , calling the same fragment in case 1 (the second sub-element) string.selected_item same thing happens. The screen will display the same text from string.selected_item . But I need the text from string.txt_1 taken from the same TextView for example. Do not create the same for each case fragment. But also to write a line in the case:
mSelectedItemView = (TextView) v.findViewById(R.id.selected_item); mSelectedItemView.setText(Html.fromHtml(getResources().getString(R.string.selected_item), null, new MyHtmlTagHandler())); changing the address of the resource in each case: R.string.selected_item to R.string.txt_0 for case 1 and R.string.txt_1 for case 2 , etc. will not work. Then how to do to solve my problem. Thanks for the help!