ListView with a dynamic intents that change a TextView and WebView on each call

独自空忆成欢 提交于 2019-12-02 07:59:49

To accomplish that, you would, instead of using a different Intent for each list item, call the same Activity with the same Intent, but pass extras along with it.

Let's say, for instance, that you want to pass a different String depending on which list item is clicked. You would want to

myIntent.putExtra(String key, String value);
startActivity(myIntent);

The Activity that you start with this Intent will then be able to grab these extras in its onCreate() using

Bundle extras = getIntent().getExtras();

and access the extras you put in the Intent using the methods outlined here. This way you can use a single Activity for all list items but have the Activity display different information based on the extra values.

Narendra

I'll give you a link where you can get the best tutorial for that... http://www.vogella.de/articles/Android/article.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!