我的程序基本上是一个项目列表,当您单击它时,它会将您发送到可扩展列表。问题是,我的项目列表长达数百个项目,因此必须为每个项目创建不同的可扩展列表类别变得乏味。相反,我想根据按下的列表选项将不同的数组发送到一个子活动。
这是我的主要活动中代码的一部分,应该发送信息:
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); }
这是我的代码中应该接收它的部分:
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");
我继续尝试将createParentList()/ createChildList()等用于我的可扩展列表。它编译得很好。但是,每当我运行它并尝试单击列表项时,它表示该进程已意外停止。有谁知道出了什么问题?
答案 0 :(得分:0)