Помогите люди добрые...
Каким методом можно передавать объекты из 1 listview в другой, находящимся в другом активити ?
public class Korzina extends AppCompatActivity
implements NavigationView.OnNavigationItemSelectedListener, View.OnClickListener {
private SwipeLayoutAdapterKorz mAdapter;
private ListView mListView;
Korz mData= new Korz();
ImageButton button,button2,button3;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_korzina);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
button = (ImageButton) findViewById(R.id.button);
button2 = (ImageButton) findViewById(R.id.button2);
button3 = (ImageButton) findViewById(R.id.button3);
button.setOnClickListener(this);
button2.setOnClickListener(this);
button3.setOnClickListener(this);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
List<Korz> mData = Korz.listAll(Korz.class);
mListView = (ListView)findViewById(R.id.listView);
mAdapter = new MyAdapater(this,R.layout.item_korz,R.layout.item_action,mData);
mListView.setAdapter(mAdapter);
}
@Override
public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.akcii) {
Intent intent12 = new Intent(this, Akcii.class);
startActivity(intent12);
finish();
// Handle the camera action
} else if (id == R.id.oplata) {
Intent intent22 = new Intent(this, Oplata.class);
startActivity(intent22);
finish();
} else if (id == R.id.dostavka) {
Intent intent32 = new Intent(this, Dostavka.class);
startActivity(intent32);
finish();
} else if (id == R.id.onas) {
Intent intent42 = new Intent(this, O_nas.class);
startActivity(intent42);
finish();
} else if (id == R.id.inmoney) {
Intent intent52 = new Intent(this, InMoney.class);
startActivity(intent52);
finish();
} else if (id == R.id.zakaz) {
Intent intent62 = new Intent(this, Zakaz.class);
startActivity(intent62);
finish();
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.button:
Intent intent12 = new Intent(this, Cold.class);
startActivity(intent12);
finish();
break;
case R.id.button3:
Intent intent2 = new Intent(this, Izbrannoe.class);
startActivity(intent2);
finish();
break;
default:
break;
}
}
class MyAdapater extends SwipeLayoutAdapterKorz<Korz>
{
private List<Korz> _data;
ArrayList objects;
public MyAdapater(Activity context, int contentViewResourceId, int actionViewResourceId, List<Korz> objects)
{
super(context,contentViewResourceId,actionViewResourceId,objects);
_data = objects;
}
//实现setContentView方法
@Override
public void setContentView(View contentView, int position, HorizontalScrollView parent) {
Korz p=((Korz) getItem(position));
TextView pricecent = (TextView)contentView.findViewById(R.id.pricecent);
pricecent.setText(p.price+"руб");
TextView tv1 = (TextView)contentView.findViewById(R.id.name);
tv1.setText(p.name);
ImageView tv3 = (ImageView) contentView.findViewById(R.id.imageView2);
int resID = getResources().getIdentifier(String.valueOf(p.image), "drawable", getApplicationContext().getPackageName());
tv3.setImageResource(resID);
}
//实现setActionView方法
@Override
public void setActionView(final View contentView,final int position, final HorizontalScrollView parent) {
contentView.findViewById(R.id.action).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
contentView.findViewById(R.id.star).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
List<Korz> allContacts = Korz.listAll(Korz.class);
Korz.deleteAll(Korz.class);
}
});
}
}
}