3
How does a spinner with states and cities of Brazil? By clicking on the state, list the cities?
What is the way to do this? An all-registered bank? Sqlite? Need a model ready for states and cities?
3
How does a spinner with states and cities of Brazil? By clicking on the state, list the cities?
What is the way to do this? An all-registered bank? Sqlite? Need a model ready for states and cities?
3
Just create table (Sqlite) with states and other with cities, interconnected by a foreign key and the respective clear objects.
Of course we should already have the states and cities already registered in the bank.
Then just catch the event from spinner
of states, for example:
spinner.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parentView, View view, int pos, long id)
{
Estado es = (Estado) parentView.getItemAtPosition(pos).
// Código de pesquisa na Tabela cidades das que tiverem o estado selecionado.
// Exemplo:
ArrayList<Cidade> listaCidades = buscarNoBanco(es);
// Depois é só adicionar a listaCidades a um outro spinner
// ou uma listView de cidades.
}
});
Browser other questions tagged java android
You are not signed in. Login or sign up in order to post.
Do you know where I can find an sql script from all cities with states for sqlite? everyone I encountered error while trying to import into sqlite studio.
– War Lock
You can assemble a function that reads XML and records in the Database, here are the XML http://www.luiztools.com/post/Base-dados-com-todos-estados-e-cidades-brasileiras.aspx
– Jorge B.
Or you have this script here: http://www.johnmarques.com.br/mysql/dump-sql-estados-e-cidades/
– Jorge B.
the problem that whenever I try to import in sqlite studio these syntax error script.
– War Lock
Show me the error.
– Jorge B.
while executing SQL error: near"*" syntax error
– War Lock
Let’s go continue this discussion in chat.
– Jorge B.