Hi everybody,
In my application I have a database which contains 3
tables. I am reading the database and show to the user using
SimpleCursorAdapter . like:
try
{
sampleDB = this.openOrCreateDatabase(SAMPLE_DBNAME,
MODE_PRIVATE, null);
System.out.println ("Inside try...");
Cursor c = sampleDB.rawQuery ("SELECT _id,RoomName,
SwitchFullName FROM SwitchTable ORDER BY RoomName",null);
System.out.println (c.getCount()+"%%%%");
startManagingCursor(c);
System.out.println ("After startManagingCursor(c))");
String[] columns = new String[] {"RoomName",
"SwitchFullName"};
int[] names = new int[] {R.id.room, R.id.switch1};
myAdapter = new SimpleCursorAdapter(this,
R.layout.roomswitchlist, c, columns,names);
setListAdapter(myAdapter);
}
catch (SQLiteException se )
{
Log.e(getClass().getSimpleName(), "Could not create or Open
the database");
}
}
my xml file is like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:src="@drawable/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Room Name: "
android:shadowColor="#00ccff"
android:shadowRadius="1.5"
android:shadowDx="1"
android:shadowDy="1"
/>
<TextView android:id="@+id/room"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#00ccff"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Switch Name: "
android:shadowColor="#00ccff"
android:shadowRadius="1.5"
android:shadowDx="1"
android:shadowDy="1"
/>
<TextView android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#00ccff"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Now my problem is that it shows data like:
Image Room Name: Hall
Switch Name: AC
Image RoomName :Hall
Switch Name: Fan
Image RoomName: Hall
Switch Name: TV
Image RoomName: Bathroom
Switch Name : Bulb
Image RoomName: Bathroom
Switch Name: CFL
But what I want is display all the switches in a single room together
like:
Image RoomName: Hall
Switch Name: AC
Fan
TV
Image RoomName: Bathroom
Switch Name: Bulb
CFL
How to do this? responses are appreciated
Thanks
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en