android - How to put different string resource for different activities with same layout ? -
In my Android project I want to use a layout which I have created many times. The problem is that there is 1 image view and 2 text views in it and I want to create 15 different pages (activities) but I want to use the same layout, but I do not know how string source and image view sources change Please. Is it possible to do this or should I have to make different layouts for all the activities?
android: text = "@ string / dlect1"
How to change it
android: text = "string / Dlect2 "
You can use string arrays in resources and drawable arrays, Number and it takes that index from the array
& lt; String-array name = "texts" & gt; & Lt; Items & gt; 1 & lt; / Item & gt; & Lt; Items & gt; 2 & lt; / Item & gt; & Lt; Items & gt; 3 & lt; / Item & gt; & Lt; Items & gt; 4 & lt; / Item & gt; & Lt; Items & gt; 5 & lt; / Item & gt; & Lt; Items & gt; 6 & lt; / Item & gt; & Lt; / String array & gt; & Lt; String-array name = "picture" & gt; & Lt; Items & gt; @ Drawable / 1 & lt; / Item & gt; ... & lt; / String-array & gt;
and from code
getResources (). GetStringArray (R.array.texts) [i]; . GetResources () getStringArray (R.array.images) [i];
Comments
Post a Comment