我想知道如果我應該使用資源XML文件來存儲所有可能的食譜,而不是使用硬編碼的ArrayList,問題是我不'知道如何從一個資源文件中使用我有方法調用...在Android XML資源文件中存儲字符串並引用它們
這裏是我想要什麼砍下版本:
int recipeNumber = b.getInt("RECIPE"); //This is taken from another activity
final TextView rowTextView = new TextView(this); //Create a textview
rowTextView.setText(R.string.recipeNumber); //This is what i am struggling with
howToLinearLayout.addView(rowTextView); //Add textview to linearlayout
我不知道要放什麼東西在部分引用我的資源文件。我知道我需要: rowTextView.setText(R,但我不知道會出現什麼之後
林將字符串存儲,這將是例如:。
<string name="1">One part Vodka, One part Coke</string>
<string name="2">One part Vodka, One part Lemonade</string>
這份名單將是相當長所以ID欣賞上存儲任何其他建議,裸記住我很新了這一點。
的配方號int是什麼字符串到TextView中被調用。
感謝您的幫助
好的,謝謝我會着眼於此 –