title: How to Get R.string in ViewModel Class of DataBinding in Android
body: <p>I am currently using <code>databinding</code> for my android application project. I want to set the <code>error</code> message on my <code>CustomTextView</code> from <code>R.string.txtOldPassWordError</code> and set it up from another class called <code>ViewModelClass</code>.</p>
  
  <p><strong>Here is my XML code</strong></p>
  
  <pre><code>&lt;com.horseproject.widget.CustomEditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_gravity="center_vertical"
      android:layout_marginTop="@dimen/dp_20"
      android:drawablePadding="@dimen/dp_10"
      android:hint="@string/enter_old_password"
      android:inputType="textPassword"
      android:lines="1"
      android:text="@={ChangePasswordVM.userOldPassword}"
      android:textColorHint="@color/gray_text"
      app:drawableLeftCompat="@drawable/ic_password_lock"
      app:drawableTintCompat="@color/gray_app"
      app:error="@{ChangePasswordVM.userOldPasswordError}" /&gt;
  </code></pre>
  
  <p><strong>and this is ViewModelClass.java</strong></p>
  
  <pre><code>public class ChangePasswordViewModel extends BaseObservable {
  
      public ObservableField&lt;String&gt; userOldPassword = new ObservableField&lt;&gt;("");
  
      public void userPasswordChange() {
  
          if ((TextUtils.isEmpty(userOldPassword.get()))) {
              userOldPasswordError.set("Please enter your old password");
              return;
          } else if (userOldPassword.get().length() &lt;= 5) {
              userOldPasswordError.set("Password should contain minimum 6 characters");
              return;
          } else {
              userOldPasswordError.set(null);
          }
      }
  }
  </code></pre>
  
  <p><strong>and this is string from <code>strings.xml</code></strong></p>
  
  <pre><code>&lt;string name="select"&gt;Please Enter Old Password&lt;/string&gt;
  </code></pre>
  
  <p>So, I want to access this string in my viewModel class and set it as error message instead of <code>hardcoded it directly as string</code>.</p>
  
  <p>So how can i achieve this? I am using Android Studio 3.0 Beta Version. Any help would be really appreciated.</p>