How do i do it? i’ve searched and looked and still haven’t found anything usefull for me.
I currently have 2 arraylist.
first one includes Strings of calculations i got from a previous activity.
second one includes Doubles of results of the above mentioned calculations i got from a previous acitivty.
I’ve saved both Arraylists in SQLLITE database.
The best i got so far is:
inside onCreate:
SimpleAdapter adapter = new SimpleAdapter(this, list,
R.layout.custom_row_view,
new String[] { "operationName", "operationValue" }, new
int[] { R.id.text1,R.id.text2 });
populateList();
setListAdapter(adapter);
inside a function – populateList(); :
static final ArrayList<HashMap<String, Double>> list = new ArrayList<HashMap<String, Double>>();
private void populateList() {
HashMap<String, Double> temp = new HashMap<String, Double>();
for (int i = 1; i <= 20; i++) {
temp.put(operationNames.get(i), operationValues.get(i));
}
list.add(temp);
}
EDIT:
The custom_row_view .xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tv1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#CBC300"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tv2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#3200A3"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
What am i missing here? it keeps crashing when entering this specific listactivity.
Any help will be really appreciated.
in your code you try to get third element from list of 2 elements! You can set some default values to this list or show only 2 items.