Home > Mobile >  Android development item jump
Android development item jump

Time:09-25

I was doing an android development homework, they want to recipe is the theme of the show, I have been in the home page with the name of the listview lists each recipe, is unable to achieve something different item to jump to the same but different data interface, and a great god help

CodePudding user response:

That you use in the click event of each Item the Intent passed had different values, and in the same interface to receive different values to display,,

 
The switch (position) {
Case 0:
Messages="happens the load type page text zoom function".
Intent in3=new Intent (VersionChangeActivity. This, VersionDetailsActivity. Class);
In3. PutExtra (versionmsg, messages).
StartActivity (in3);
break;
Case 1:
Messages="happens few.";
Intent in2=new Intent (VersionChangeActivity. This, VersionDetailsActivity. Class);
In2. PutExtra (versionmsg, messages).
StartActivity (in2);
break;
Case 2:
Messages="Add APP online update function.";
Intent in1=new Intent (VersionChangeActivity. This, VersionDetailsActivity. Class);
In1. PutExtra (versionmsg, messages).
StartActivity (in1);
break;
Case 3:
Messages="Add dynamic icon guides to help users get started faster -.";
The Intent in=new Intent (VersionChangeActivity. This, VersionDetailsActivity. Class);
In the putExtra (" versionmsg ", messages);
StartActivity (in);
break;

Below is the same interface receives the value and show
 
String Msgs=getIntent (). GetStringExtra (" versionmsg ");
TextView. SetText (Msgs);

CodePudding user response:

Set the listview item to monitor, and then according to different position, the value with the Intent to start the activity, start the activity to get their value judgment according to the display of data

CodePudding user response:

 private void initData () {
Listview. SetOnItemClickListener (new AdapterView. OnItemClickListener () {//listview click event
@ Override
Public void onItemClick (AdapterView<?> AdapterView, View View, int, long l) {

Bundle Bundle=new Bundle ();//use the bundle
Bundle. PutString (" shopId ", listbeanss getRECORDS () get (I). GetShopId ());//these are you want to transfer data, the front is id
Bundle. PutString (" shopName ", listbeanss getRECORDS () get (I). GetShopName ());
Bundle. PutString (" shopNum ", listbeanss getRECORDS () get (I). GetShopNum ());
Bundle. PutString (" shopPrice, "listbeanss getRECORDS () get (I). GetShopPrice ());

Intent Intent=new Intent (getActivity (), ParticularsActivity. Class);//to appear after you click on the interface, it's simple to write the activity by value
Intent. PutExtras (bundle);
startActivity(intent);
}
});
}

//interface receives data appeared after click
Private void initData () {
//in this according to the id for you transfer the value of the...
Bundle Bundle=getIntent (). GetExtras ();
String shopId=bundle. Get String (" shopId ");
String shopName=bundle. Get String (" shopName ");
String shopNum=bundle. Get String (" shopNum ");
ShopPrice String shopPrice=bundle. Get String (" ");
}
  • Related