I am so new to android. I have a simple list and a custom raw to fill up the list. I also have a json file in assets folder. this is my xml file for the raw:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/bcgn">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TableRow >
<CheckBox
android:id="@+id/FoodCheck"
android:text="Celery"
android:textColor="#696969"/>
<TextView
android:id="@+id/stCal"
android:text="300"
android:layout_marginLeft="150dip"
android:textColor="#696969"/>
</TableRow>
</TableLayout>
</RelativeLayout>
and this is my simple list:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/bcgn">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/txtHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Vegetables"
android:textSize="15dip"
android:textColor="#00008B"
android:gravity="center"
android:textAllCaps="true"
android:background="#7FFFD4"
/>
<ListView android:id="@+id/list"
android:drawSelectorOnTop="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#A9A9A9"
android:dividerHeight="2dip"
android:addStatesFromChildren="true"/>
</TableLayout>
</LinearLayout>
and this is a short version of my Json file:
[{"name":"celery","cal":200},{"name":"carrot","cal":700},{"name":"lettuce","cal":500}]
Do i really need to convert Json to a hashmap? can i just use a list? Do i need to have the adapter on a separate java file? and if yes please provide the complete code and a brief explanation, because I am new and can not understand some parts. Thank you very much