title: MVVM: how to pass a resources string from view model to view?
body: <p>I want to display a text in my view. However, the text is not dependent of "data" from my model I can display directly but depends on a state enum. Dependent of the state I want to display a pre-defined text in my string resources file.</p>
  
  <p>For example, I have the following enum in the model layer:</p>
  
  <pre><code>enum class GreetingType
  {
      GREETING_FIRST_TIME,
      WELCOME_BACK,
      GOODBYE
  }
  </code></pre>
  
  <p>In my strings.xml I have the respective strings:</p>
  
  <pre><code>R.string.greeting_first_time
  R.string.welcome_back
  R.string.goodbye
  </code></pre>
  
  <p>My question is: How should the interface between view model and view look like? Should I pass:</p>
  
  <ol>
  <li>the enum (e.g. <code>GreetingType.GOODBYE</code>)</li>
  <li>the resource ID (e.g. <code>R.string.goodbye</code>)</li>
  <li>the resolved string (e.g. <code>context.resources.getString(R.string.goodbye</code>)</li>
  </ol>
  
  <p>Each approach seems to have downsides:</p>
  
  <ul>
  <li>With 1. and 2. I need the mapping logic in the view.</li>
  <li>With 3. I need <code>context</code> in the view model, which I would like to avoid.</li>
  </ul>
  
  <p>Is there a recommended approach? </p>
  
  <p>Can I achieve both:</p>
  
  <ul>
  <li>Keep the view dumb (by avoiding if/else)</li>
  <li>Keep the view model clean of the Android Framework (i.e. use <code>ViewModel</code> instead of <code>AndroidViewModel</code>)?</li>
  </ul>
  
  <p>The examples I found only deal with data being displayed directly.</p>