How to fill mthe ListView of multiple columns ?

RavenRaven USMember
edited July 2015 in Xamarin.Android

I want to use a ListView under the calendar. I am using Alliance Calendar.
This is an example program -
The ListView contains 3 columns : Time , Place , Person
When a Date is selected by the user - Time of meeting , Place to meet , Person to meet - on the selected Date ,is displayed. There will be multiple rows depending upon the Date.

In database.cs


    // RETURN TIME FROM SELECTED DATE
    public string GetTime(string sdate) {
        string stime = "";
        try {
            /* SQLite query */
        }
        catch (SQLiteException){}
        return stime;
    }

Similarly for Place and Person

These are obtained from different tables and I don't want to create another table for these.

In MainActivity.cs


    database database1 = new database ("test1");
    CustomCalendar CalendarControl;
    string time, place, person;
    string selecteddate;

    time = database1 .GetTime(selecteddate);
    place = database1 .GetPlace(selecteddate);
    person = database1 .GetPerson(selecteddate);

    CalendarControl.OnCalendarSelectedDate += CalendarControl_CalendarDateSelected;




    private void CalendarControl_CalendarDateSelected(object sender, CalendarDateSelectionEventArgs e)
    {
        selecteddate = e.SelectedDate.ToString();
        Toast.MakeText(this, e.SelectedDate.ToString(), ToastLength.Short).Show();
    }

ListView.axml

    <?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">
        <TextView
            android:id="@+id/time"
            android:layout_width="110px"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:textColor="#ffffff" />
        <TextView
            android:id="@+id/place"
            android:layout_width="110px"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:textColor="#ffffff" />
        <TextView
            android:id="@+id/person"
            android:layout_width="110px"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:textColor="#ffffff" />
    </LinearLayout>

Now, my question is how to fill the ListView since we do not know the number of rows

Every time a date is selected, all the meeting places, time and person name must be displayed with respect to that day.

Best Answer

Answers

  • RavenRaven USMember

    Thank you. I wasn't aware of the join clause. This is very helpful.
    I got a code which is similar to what you told here,
    http://redth.codes/2010/10/12/monodroid-custom-listadapter-for-your-listview/

Sign In or Register to comment.