'How to make a list of cities offered when entering a city

Please tell me how to make a list of cities offered when entering a city and when entering a letter, the cities were substituted for this letter and if pressed, it was automatically inserted into the city input field. The city is entered using Preferencescreen, and then I substitute the name of the city in the Api. I just need a list of cities to appear, so as not to enter the name completely. Please make detailed instructions, otherwise I'm a beginner

PreferenceScreen

<PreferenceCategory
        android:title="@string/preferenceTitle1">
        <EditTextPreference
            android:key="CUSTOM_LOCATION"
            android:title="@string/location3"
            android:summary="@string/location4"
            android:defaultValue="Moscow"
            android:dependency="USE_DEVICE_LOCATION"/>
</PreferenceCategory>

enter image description here

But if this is not possible through the preferences Screen, then just show how to do it on the Activity using EditText



Solution 1:[1]

I dont know maybe try to use StartWith();

if(enter_city.getText().toString().startsWith(Names_city))
{
//do something
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ACTPOHOM