About the different activity between the value of the personal feeling if two activity related, use intent and bundle still quite a lot of, if the association is not very close, generally is the service value, after the text will be four sets together to explain the next, Now first talk about bundles, the original blogger is generally directly itntent.putextra (), the key value of less control when the more fine, and the feeling is not very troublesome, but once the key value of a lot of time, it is more scary, one is the performance of the program, and the other is the problem of code volume, However, the performance of the program should be a priority, good, nonsense not to say, on the code to prove:
This intent has its own value.
for (int i = 0; i < buddhistservicesarray.length; i++) {
Buddhistservicesbean Buddhistservicesbeans = new Buddhistservicesbean (Bstitle, Bsdetail, BsFirst, BsSecond, BsThird);
String bstitle = Buddhistservicesarray[i].getbstitle ();
String bsdetail = Buddhistservicesarray[i].getbsdetail ();
String Bsfirst = Buddhistservicesarray[i].getbsfirst ();
String Bssecond = Buddhistservicesarray[i].getbssecond ();
String Bsthird = Buddhistservicesarray[i].getbsthird ();
Bo Master at that time feel can, not very troublesome, but more words, imagine, really make people very headache, very disgusting
map<string, object> map = new hashmap<string, object> ();
Map.put ("Bstitle", bstitle);
Map.put ("Bsdetail", Bsdetail);
Map.put ("Bsfirst", Bsfirst);
Map.put ("Bssecond", Bssecond);
Map.put ("Bsthird", Bsthird);
Buddhistserviceslist.add (map);
}
Arrays.sort (Buddhistservicesarray);
Buddhistservicesbeans = Arrays.aslist (Buddhistservicesarray);
Buddhistservicesadapter = new Buddhistservicesadapter (getactivity (), Buddhistservicesbeans);
Buddhistservices_listview.setadapter (Buddhistservicesadapter);
Buddhistservices_listview.setonitemclicklistener (New Bsinfoonitemclicklistener ());
Protected class Bsinfoonitemclicklistener implements Adapterview.onitemclicklistener {
@Override
public void Onitemclick (adapterview<?> parent, view view, int position, long ID) {
Intent it_bs_info = new Intent (getactivity (), buddhistservicesinfo.class);
for (int i = 0; I <= position; i++) {
if (position = = i) {
Map map = (map) buddhistserviceslist.get (i);
String btitle = (string) map.get ("Bstitle");
String bdetail = (string) map.get ("Bsdetail");
String bfirst = (string) map.get ("Bsfirst");
String bsecond = (string) map.get ("Bssecond");
String bthird = (string) map.get ("Bsthird");
It_bs_info.putextra ("Btitle_info", btitle);
It_bs_info.putextra ("Bdetail_info", Bdetail);
It_bs_info.putextra ("Bfirst_info", Bfirst);
It_bs_info.putextra ("Bsecond_info", Bsecond);
It_bs_info.putextra ("Bthird_info", Bthird);
Pass the value to the next activity
}
}
StartActivity (It_bs_info);
}
}
This is when the next activity initializes the data and gets the corresponding value from the last activity.
private void InitData () {
Intent it = this.getintent ();
Info_title = It.getstringextra ("Btitle_info");
This.bsi_title.setText (Info_title);
title = Info_title;
String Info_detail = It.getstringextra ("Bdetail_info");
String Info_first = It.getstringextra ("Bfirst_info");
String Info_second = It.getstringextra ("Bsecond_info");
String Info_third = It.getstringextra ("Bthird_info");
This.bsi_detail.setText (Info_detail);
This.bsi_first.setText (Info_first);
This.bsi_second.setText (Info_second);
This.bsi_third.setText (Info_third);
}
OK, here are the examples of bundles:
Protected class Eventinfoonitemclicklistener implements Adapterview.onitemclicklistener {
@Override
public void Onitemclick (adapterview<?> parent, view view, int position, long ID) {
Intent it_event_info = new Intent (eventsactivity.this, Eventinfoactivity.class);
for (int i = 0; I <= position; i++) {
if (position = = i) {
Map map = (map) eventslist.get (i);
Bundle bundle = new bundle ();
Bundle.putstring ("Eventimg_info", (String) map.get ("eventimg"));
Bundle.putstring ("Eventname_info", (String) map.get ("EventName"));
Bundle.putstring ("Eventtime_info", (String) map.get ("Eventtime"));
It_event_info.putextras (bundle);
}
}
StartActivity (It_event_info);
}
}
This is not much simpler, the individual think bundle is the key value of the package, and the time to get and initialize is also very easy, the above code also involves, List,map, and for the loop, the activity between the transfer of time with a lot of, you can learn the next
Bundle&intent&for&list&map&extra