Related spinners Android
<p>I'm begginer in android. I'm working on a project. But i get very difficult to do two spinners related to each others. Actually one spinner for the country and another for the city. Instead of the country that is chosen the second spinner will show the cities. </p>

<p>I'v used "OnItemSelectedListener" but the " ArrayAdapter.createFromResourc​e " can't be used inside OnItemSelectedListener.
I've tried a lot of other ways but still none of them working. 
Can anybody help me Please???</p>

<p>(P.S. I have read and tried the other posts about this topic but it still doesn't work )
This is the code:</p>

<pre><code>spinner.setOnItemSelectedListener(
            new OnItemSelectedListener() {
                public void onItemSelected(
                        AdapterView&lt;?&gt; parent, View view, int position, long id) {


                    int spinnerId = spinner.getSelectedItemPosition();
                    if (spinnerId==0){
    adaptert = ArrayAdapter.createFromResource(
            this, R.array.tirana, android.R.layout.simple_spinner_item);
    adaptert.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    }
    else if (spinnerId==1) {
        adaptert = ArrayAdapter.createFromResource(
                this, R.array.durres, android.R.layout.simple_spinner_item);
        adaptert.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        }

    spinnert.setAdapter(adaptert);


                }

                public void onNothingSelected(AdapterView&lt;?&gt; parent) {

                }
            });
</code></pre>
