The usage of intents is a little bit more complex and there are different options available how to communicate between your two activities.
Try to understand the basics of intents (action, data, ...) Basics: - http://developer.android.com/reference/android/content/Intent.html When you start another Activity you have to decide how you want to communicate back to the calling activity. Please, get familiar with Start other activities:startActivity(Intent) and startActivityForResult - http://developer.android.com/reference/android/app/Activity.html) Also get some understanding how to write your Manifest to use intents correctly. Check out the following link: - http://developer.android.com/guide/topics/manifest/intent-filter-element.html -- Roman Baumgaertner Sr. SW Engineer-OSDC ·T· · ·Mobile· stick together The views, opinions and statements in this email are those of the author solely in their individual capacity, and do not necessarily represent those of T-Mobile USA, Inc. On Aug 25, 12:48 am, Sebeto <seb...@gmail.com> wrote: > Hi, > > I try to get the value of a parameter from another activity, but can't > succeed in doing that. I found things about putExtra/getExtra, but > couldn't get it to work unfortunately. > > Problem: > I've got a TabActivity called "methodes", which has a TabHost. The > contents of the Tabs are activities, and I need to retrieve in these > activities the value of maValeur (which is actually a > ArrayList<String>). My application is "net.sebeto.android.essai". > > public class Methodes extends TabActivity > { > public static ArrayList<String> maValeur; > public void onCreate(Bundle savedInstanceState) > { > > // I initialize "maValeur", ... > (...) > > // MethTab2 will be the content of the second tab > Intent Tab2 = new Intent(this, MethTab2.class); > Tab2.putStringArrayListExtra > ("net.sebeto.android.essai.Methodes.maValeur", maValeur); > > TabHost host = getTabHost(); > (...) > host.addTab(host.newTabSpec("two").setIndicator > ("Valeur").setContent(Tab2)); > } > > } > > Now: > > public class MethTab2 extends Activity > { > private ArrayList<String> maValeurBis; > > @Override > public void onCreate(Bundle savedInstanceState) > { > super.onCreate(savedInstanceState); > > // How to get the value of maValeur?? > // I found no way to use getStringArrayList? > // maValeurBis = savedInstanceState.getStringArrayList > ("net.sebeto.android.cuisine.Methodes.maValeur"); crashes, ... > // I can get the value with maValeurBis = > Methodes.maValeur; but I'm not sure that it's > // a good way to do it, is it? It works, but... do you > think it's a good method? > > maValeurAdapter = new ArrayAdapter<String>(this, > R.layout.methtab2,maValeurBis); > ListView list = new ListView(this); > list.setAdapter(maValeurAdapter); > list.setSelector(android.R.color.transparent); > setContentView(list); > } > > } > > Thank you for your answers, I'm a perfect beginner in java and in > android... If someone could give me a code which would work it would > be great! I know that it's probably very simple but... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---