开发者

Consolidating the number of activities in my Android app

开发者 https://www.devze.com 2023-01-06 03:16 出处:网络
In my application, I currently have several activities that consist of a TextView and a scrollbar. The only difference between them is the string that the TextView displays. Is there a way to consolid

In my application, I currently have several activities that consist of a TextView and a scrollbar. The only difference between them is the string that the TextView displays. Is there a way to consolidate all of these into one single activity, and depending on how/where the activity is started from, changes the TextView? Perhaps send the name of the string as an argument to startActivity, or something 开发者_运维问答along those lines?


When you start your Activity with an Intent you can pass values to it with the Bundle object.

This can be done quite easily with this method call:

http://developer.android.com/reference/android/content/Intent.html#putExtra(java.lang.String, java.lang.String)

From the new Activity (the one started with the call to startActivity()) you can get this value by calling getIntent().getExtras().getXXX(YOUR KEY)

0

精彩评论

暂无评论...
验证码 换一张
取 消