i need to create a widget with listview for my android application. so that i searched in google and i found one link taht is below.
https://github.com/commonsguy/cw-advandroid/tree/master/AppWidget/LoremWidget
and i followed the mentioned above link. everything is working perfectly. but i cant print the sub items of the listview.
Widget_Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top"
tools:context=".MainActivity"
android:background="@drawable/widget_frame" >
<ListView
android:id="@+id/listItem"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="45dp"
android:cacheColorHint="#00000000"
android:background="@drawable/widget_frame"
/>
</RelativeLayout>
This is the layout for the items of the ListView
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:paddingLeft="6dip"
android:textSize="20dp"
android:minHeight="?android:attr/listPreferredItemHeight"/>
here is the getViewAt(int position) function where we print all items in listview. i printed the sub items of items using '+' operator and '\n'. but i cant differentiate items and its sub items that means i cant give specific properties to sub items. can anybody please help me to differentiate the sub items from items.
getViewAt
public RemoteViews getViewAt(int position) {
RemoteViews row=new RemoteViews(mCtxt.getPackageName(),R.layout.widget_layout);
row.setTextViewText(android.R.id.text1, Names[position]+"\n"+address[position]);
}