アプリを作成しようとしています。
私が欲しいのはですexpandable List
。のすべての要素ArrayList<Object>
は、リストの要素でもある必要があります。Parenttitleは、オブジェクトのタイトルである必要があります。このオブジェクトには、ArrayList<Double>
4つの要素も含まれています。
すべての親には1人の子供が必要です。親の子は4つのProgressBarを表示する必要があります。の最初の要素はArrayList<Double>
、最初のprogressBarの進行状況を設定する必要があります。
これは私が今持っているものです:
public class Lernen extends Activity {
private ExpandableListView mExpandableList;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lernen);
mExpandableList = (ExpandableListView) findViewById(R.id.expandable_list);
ArrayList<Parent> arrayParents = new ArrayList<Parent>();
ArrayList<String> arrayChildren = new ArrayList<String>();
// MUSS GEÄNDERT WERDEN WENN DIE METHODE GETALLCARDS FERTIG IST!!!
ArrayList<Karteikasten> kasten = new ArrayList<Karteikasten>();
// teststub:
Karteikasten foo = new Karteikasten("Kasten 1");
Karteikasten bar = new Karteikasten("Kasten 2");
kasten.add(bar);
kasten.add(foo);
System.out.println(kasten.size());
try{
// here we set the parents and the children
for (int i = 0; i < kasten.size(); i++) {
System.out.println("Durchlauf: " + i);
System.out.println(kasten.get(0).getProgress().get(0).intValue());
// for each "i" create a new Parent object to set the title and the
// children
Parent parent = new Parent();
parent.setmTitle(kasten.get(i).getName());
arrayChildren.add("Child " + i);
parent.setmArrayChildren(arrayChildren);
ProgressBar pb1 = (ProgressBar) findViewById(R.id.progressBar1);
pb1.setProgress(kasten.get(i).getProgress().get(0).intValue());
ProgressBar pb2 = (ProgressBar) findViewById(R.id.progressBar2);
pb2.setProgress(kasten.get(i).getProgress().get(1).intValue());
ProgressBar pb3 = (ProgressBar) findViewById(R.id.progressBar3);
pb3.setProgress(kasten.get(i).getProgress().get(2).intValue());
ProgressBar pb4 = (ProgressBar) findViewById(R.id.progressBar4);
pb4.setProgress(kasten.get(i).getProgress().get(3).intValue());
System.out.println("Kasten: " + kasten.get(i).getName());
// in this array we add the Parent object. We will use the
// arrayParents at the setAdapter
arrayParents.add(parent);
}
} catch (Exception e){
String stackTrace = Log.getStackTraceString(e);
System.out.println("Fehlermeldung:");
System.out.println(stackTrace);
}
// sets the adapter that provides data to the list.
mExpandableList.setAdapter(new MyExpandableListAdapter(Lernen.this,
arrayParents));
}
}
その行でNullPointerExceptionが発生します
pb1.setProgress(kasten.get(i).getProgress().get(0).intValue());
問題は、progressBarがレイアウト内list_item_child.xml
にあるが、このレイアウトがアクティビティに使用できないことである可能性があります。
誰かがそれを修正する方法を知っていますか?
どうもありがとうございます!
(そして悪い言葉でごめんなさい;))