0

My program is basically a list of items, and when you click the items it sends you to an expandable list. The problem is, my list of items is hundreds of items long, so it becomes tedious to have to make a different expandable list class for each one. Instead, I want to send different arrays to one subactivity depending on which list option was pressed.

Here's the part of my code in my main activity that is supposed to send the info:

if ((String) ((TextView) view).getText() == "Name of List Item") {
               Intent myIntent = new Intent(view.getContext(),
                     SubActivity.class);
               myIntent.putExtra("parents", new String[] { "bunch of parents" });
               myIntent.putExtra("children", new String[][] {
                           { "bunch" },
                           { "of" },
                           { "children"} });
               startActivityForResult(myIntent, 0); }

Here's the part of my code that is supposed to receive it:

String[] parents;              //declared outside onCreate() so they can be used by methods like createParentList()
String[][] children;

public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      Bundle b = this.getIntent().getExtras();

      moves = b.getStringArray("parents");
      parents = (String[][]) b.getSerializable("children");   

I go on to try to use createParentList()/createChildList(), etc for my expandable list. It compiles perfectly fine. However, whenever I run it and try to click on the list item, it says that the process has stopped unexpectedly. Does anyone know what is wrong?

Kin
  • 1

1 Answers1

0

i think you should see http://shri.blog.kraya.co.uk/2010/04/26/android-parcel-data-to-pass-between-activities-using-parcelable-classes/ ,or Transferring object data from one activity to another activity .you should do yourself Serializable

Community
  • 1
  • 1
pengwang
  • 19,536
  • 34
  • 119
  • 168