Passing variable string to create arrays (Android)
<p>I am a newb to Android and Java and want to write a funtion that will display a list based on a varable that I pass to the function. </p>

<p>The function is below and the code below creates an array out of a string called type, but what I want to do is pass it a variable string and have it build a list based on that string. </p>

<p>So if I wanted the type list I would say <code>list_it("type")</code></p>

<p>But if I try something like <code>getResources().getStringArray(R.array.thelist);</code> it doesn't work.</p>

<p>Can someone point me in the right direction?</p>

<pre><code>public void list_it(String thelist){
    String[] types = getResources().getStringArray(R.array.type);
      ArrayAdapter&lt;String&gt; mAdapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_item1, types);
      setListAdapter(mAdapter);
      ListView lv = getListView();
      lv.setTextFilterEnabled(true);
}
</code></pre>
