NunoDinis Posted October 18, 2012 at 03:05 PM Report #479626 Posted October 18, 2012 at 03:05 PM Boa tarde, Alguém sabe como posso passar valores entre formulários em android? Parecia-me linear, mas não é como parece. Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org
KTachyon Posted October 18, 2012 at 03:32 PM Report #479634 Posted October 18, 2012 at 03:32 PM Queres dizer entre activities, certo? Com Bundles: http://developer.android.com/reference/android/os/Bundle.html Espreita o Activity Lifecycle na documentação da Activity: http://developer.android.com/reference/android/app/Activity.html “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare
NunoDinis Posted October 18, 2012 at 04:17 PM Author Report #479639 Posted October 18, 2012 at 04:17 PM Estou a utilizar este tutorial : http://www.portalandroid.org/comunidade/viewtopic.php?f=7&t=16945&hilit=singleton Com uma variável estática consigo passar os valores, mas se na tela 2 escrever algo numa caixa de texto, ao chama-la na tela 1 não vai buscar o valor da mesma. Na tela 1 estou a usar este código: MySingleton mDados = MySingleton.getInstance (); String s = mDados.getMyString(); mensagemExibir("",""+s); E na tela 2 este: MySingleton mDados = MySingleton.getInstance (); String s = etLarU.getText().toString(); mDados.setMyString(s); Resolvido : etLarU.setonclickListener(new View.onclickListener() { public void onclick(View v) { // TODO Auto-generated method stub MySingleton mDados = MySingleton.getInstance (); String s = etLarU.getText().toString(); mDados.setMyString(s); } }); Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro. ndsotware.org
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now