title: How to pass dynamic parameters to rest api in android when using viewmodel
body: <p>I am fetching news details from News Api site. I am using ViewModel architecture so that the device does not fetch the results when orientation changes. </p>
  
  <p>As per various turorials i am able to fetch the result to a recyclerview using retrofit and viewmodel buy giving static parameters as query to the rest api.</p>
  
  <pre class="lang-java prettyprint-override"><code>private void loadTopHeadlines() {
          ApiInterface apiInterface = ApiClient.getApiClient().create(ApiInterface.class);
          Call&lt;TopHeadlinesResponse&gt; response = apiInterface.getTopHeadlines("in", 20, 1,
                  "api_key");
          response.enqueue(new Callback&lt;TopHeadlinesResponse&gt;() {
              @Override
              public void onResponse(Call&lt;TopHeadlinesResponse&gt; call, Response&lt;TopHeadlinesResponse&gt; response) {
                  topHeadlinesResponse.setValue(response.body().getArticles());
              }
  
              @Override
              public void onFailure(Call&lt;TopHeadlinesResponse&gt; call, Throwable t) {
  
              }
          });
      }
  </code></pre>
  
  <p>As you can see in the ViewModel class that is created the method getTopHeadlines() uses static parameters. How do i change it to dynamic parameters.</p>
  
  <p>Static parameter </p>
  
  <pre class="lang-java prettyprint-override"><code>Call&lt;TopHeadlinesResponse&gt; response = apiInterface.getTopHeadlines("in", 20, 1,
                  "api_key");
  </code></pre>
  
  <p>Dynamic parameter</p>
  
  <pre class="lang-java prettyprint-override"><code>Call&lt;TopHeadlinesResponse&gt; response = apiInterface.getTopHeadlines(dynamic, dynamic, dynamic,
                  "api_key");
  </code></pre>