Many thanks for both suggestions 

I got there in the end ( hour of trial and error) 

It's as Greg pointed out my syntax was screwed

This in Java 

private class OrderAdapter extends ArrayAdapter<Order> {
        private List<Order> items;
        public OrderAdapter(Context context, int textViewResourceId,
ArrayList<Order> items) {
                super(context, textViewResourceId, items);
                this.items = items;
        }

translates to this c# Just as Greg pointed out 

I had replaced the 'super' with base  but I hadn't removed the curly brace
to a position after the base constructor nor had I pu in the required colon

Many thanks all 

 

 

Correct c# syntax

   public class jmAdapter : ArrayAdapter<string> {
        private List<string> items
        private LayoutInflater vi;      

        public jmAdapter(Context context, int textViewResourceId,
List<string> items) :
                base.jmAdapter(context, textViewResourceId, items)
{                           
                this.items = items;
                 vi=LayoutInflater.From(context);

        }

 

 

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Greg Shackles
Sent: 21 October 2011 12:57
To: [email protected]; Discussions related to Mono for Android
Subject: Re: [mono-android] multi line list view and converting java

 

The problem isn't a Mono thing, it's that the way you're calling the base
constructor is invalid C#. It should look something like this:

 

public jmAdapter(Context context, int textViewResourceId, List<string>
items)

    : base(context, textViewResourceId, items)

{

    // ...

}

 

On Fri, Oct 21, 2011 at 5:46 AM, John Murray <[email protected]> wrote:

Can any kind soul help me the last few yards on this 

I  am experimenting with multi line listviews 

 

Either - is there any good tutorial/example especially for monodroid ? 

 

I cant find anything other than java stuff  which seems to say build your
own adapter 

 

So I took this code ...java  and  converted it to c# - seems I've got most
things  nailed i've sorted the supers and extends and shoved the layout
inflater somewhere it can reach context etc  but in VS 2010 I am getting a
weird error on the constructor line 

 

"              'Android.Widget.ArrayAdapter<string>' does not contain a
constructor that takes 0 arguments" on the constructor line

 

I don't get it - my code doesn't have 0 arguments????

Oh BTW I changed the List<Orders>  to List<string> just to keep it simple
while experimenting 

 

I am sure I've got some syntax wrong somewhere but I can't find anymore
hints so have come to a grinding halt.

I think I've sorted all other issues out but can anyone look at my code and
advise if I am going in the right direction? 

 

If there's no tutorials for mono on this(multi line listview) I am happy to
post any successful conclusion for the Wiki for anyone else's benefit

 

TIA 

John Murray

==========================================

JAVA code

private class OrderAdapter extends ArrayAdapter<Order> {

        private List<Order> items;

        public OrderAdapter(Context context, int textViewResourceId,
ArrayList<Order> items) {

                super(context, textViewResourceId, items);

                this.items = items;

        }

        @Override

        public View getView(int position, View convertView, ViewGroup
parent) {

                View v = convertView;

                if (v == null) {

                    LayoutInflater vi =
(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                    v = vi.inflate(R.layout.row, null);

                }

                Order o = items.get(position);

                if (o != null) {

                        TextView tt = (TextView)
v.findViewById(R.id.toptext);

                        TextView bt = (TextView)
v.findViewById(R.id.bottomtext);

                        if (tt != null) {

                              tt.setText("Name: "+o.getOrderName());
}

                        if(bt != null){

                              bt.setText("Status: "+ o.getOrderStatus());

                        }

                }

                return v;

        }

}

 

My c# CODE ====================================================

 

   public class jmAdapter : ArrayAdapter<string> {

 

        private List<string> items;

        private LayoutInflater vi;

        

        public jmAdapter(Context context, int textViewResourceId,
List<string> items) {    //error on this line

                base.jmAdapter(context, textViewResourceId, items);
//and on this

                this.items = items;

                 vi=LayoutInflater.From(context);

        }

 

        

        public  override View getView(int position, View convertView,
ViewGroup parent) {

                View v = convertView;

                if (v == null) {

                   

                        //=
(LayoutInflater)GetSystemService(Context.LAYOUT_INFLATER_SERVICE);

                    

                    v = vi.Inflate(Resource.Layout.custom_row_view, null);

                }

                string o = items.ElementAt(position);

                if (o != null) {

                        TextView tt = (TextView)
v.FindViewById(Resource.Id.areg);

                        TextView bt = (TextView)
v.FindViewById(Resource.Id.atype);

                        if (tt != null) {

                              tt.SetText("Areg:
"+o,TextView.BufferType.Normal);                            }

                        if(bt != null){

                              bt.SetText("Atype: "+
o,TextView.BufferType.Normal);

                        }

                }

                return v;

        }

}

 

 

 


_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

 

_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to