Introduction

From last few weeks I am working on Mono-Android and In this article I am going to create custom generic BaseAdapter derived class to generate list view!

Now for start, creating ListView is not as straight forward as of ASP.netListView/GridView
, where we can attach the list collection directly to ListView and see the result. Here in android world, things is little different, every item in list view represent a view and you have to provide values to control present in that view. During my learning, I feel like I am sub classing CButton class in MFC https://www.codeproject.com/script/Forums/Images/smiley_smile.gif

Video Link

Step By Step we move forward

Create Android application by selecting New ->Solutions and provide its name “CustomListBox”

Figure 1: Creating Android Project!

Once Project is created, Open Resource Folder->Layout and Add new file of type custListItem.axml

Add parameterized constructor, which take Activity and List<PersInfo><persinfo> as argument, and assign these values to private member listed in first step.

Coding <code><code><code>GetItemId, Count and this [int position] is fairly simple as in GetItemId: we are just returning the position as itemID, In Count: we returning list count and this [int position]: we will return item in specified position.

Here, this list is act as feeder for our CustomAdapter which I going to explain in next step.

Now you have find ListView using FindViewById<ListView> using id “Resource.Id.listView1” and create our customListAdapter by passing current activity and list collection we created in last step and assign it to ListView Object adapter property.

Interesting question, you are right java is one of the primary language of Android and even this MonoAndroid is framework created over java to provide C# support in android world.

And on to your question, Why C-Sharp, In brief I am VC++ Developer and Slowly warm up with C#. Also, Its pretty difficult for me to switch over from RAD studio of MS to Text Based or Half RAD based java one(I Believe you may agree Visual Studio are far better than eclipse(free))

2. Mono Project is full blown framework, since it provide common platform for writing application for three most popular mobile OS (iOS, Android and MS Mobile), which believe Java is not. We can have common source base and application building up and publishing is fast in case we use Mono project. (I am talking about native mobile application development here)

3. Mobile programming is my hobby and am still learning it, so its easier for me learn anything closer to my skillset!

I answered your question honestly, if you still have question, i am open for that!

"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David CrowNever mind - my own stupidity is the source of every "problem" - Mixture

Really strange opinion there. C# is far better than Java, and you are much more productive with C#. The language evolved and is now contains a lot more interesting features than Java, which seems to be rusty and outdated. Also Java is only capable to do static and managed stuff, while in C# you can actually use dynamic programming, pointers and unmanaged memory (so how can you think Java is closer to C++ than C#?!).

Agreed, i am close to computer since 1991. at that time people just dont want to go away from PASCAL, FOXPRO and fortron. now see these languages,they are now history. however both c/C++ still surviving.

Arash M. Dehghani wrote:

we can even utilize java.dll from C application for running Java code from native codes.

Same thing also available in C# too, however using COM

Arash M. Dehghani wrote:

unfortunately MS sees itself as GOD, and the worst thing i, some its developers sees itself GOD while Linux is knows as developers heaven.

see it perspective of seeing things see if there is day then there would be night. there would be opposite everything. so it better to keep off from this discussion, as end of day we are working to feed our family and to have comfortable life

"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David CrowNever mind - my own stupidity is the source of every "problem" - Mixture

I'm completely disagree with your opinion about VS and Eclipse, Eclipse is really perfect and good IDE, especially when you would save the money too! while VS is a MS product, so every time I see or hear M$, I know there are some caps need to be destroyed.

I agree eclipse is free and MS Visual Studio is paid (thats what i mention in my previous message, however not elaborated, apologies). However you must have to agree VS is most powerful and feature rich IDE present on earth for window platform, same way eclipse too evolved over the year, however you can't say is comparable to VS. if you like i can publish comparable stats for same.

Arash M. Dehghani wrote:

I really cannot count on Mono, because it's funny at first "Writing si-sharp for android!?", so certainly it converts the code in order to understandable to device/os, so what is the big differences between coding in Java and C#?! maybe delegates, properties, ..., so I thin a true android developer works with his best friend Eclipse, and I hope you will too.

Reason for coding in C# of me is that i am more familiar with construct of C# then Java. second in the end both java and c# application need there private boxes to run. Its doesn't matter which language you use, in the end machine understand only 1 and 0

Also, I want to be away from PAID Source and Open Source debate. However you can find some of my open-source project written in VC++/C# (closed source language) around the internet

Arash M. Dehghani wrote:

I'm wondering how do you find C# closer to VC++ than Java?! Java and C are good friends, and I'm happy about recent C/C++ ISO, at least MS is not free to define and declare fully dependent architecture/platform for win machinez, all I know there are to MUCH application has written in Java for phones, and most of the suggestions are talking about Java, maybe you need to switch from MS to Oracle and Google, you know MS is alive with its windows and supporters, and sooner or later it will kicked.

I think opposite. C# is much closer to VC++ (i am not talking about C++), since lot of classes are similar and have same construct. its difficult for me to comment on java, as i prefer pro Microsoft languages except little bit of PHP and Oracle DB.

Secondly i doubt on your sentence "much application are written in java", as almost all iOS application are written in Objective C. Android also support HTML5 and I believe you already know about Windows Phones

and Microsoft here to stay, as there is currently no threat to there OS. may be lot of user are migrating to tablets. However you still require PC to do your daily work. however what in future no body can predict!

Arash M. Dehghani wrote:

Hmm, seems you have a very tight connection with MS.

Yeah you can say that, using there product I earn my daily living ..

anyways someone has down voted you... i even it out . instead of voting for article someone voting for comment, INCREDIBLE

"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David CrowNever mind - my own stupidity is the source of every "problem" - Mixture

Here nothing is related with MS or Google. Xamarian is very good tool and as per my experience with Xamarian;

1."Seems you have a very tight connection with MS" - Xamarian Studio had nothing to do directly with MS (M$ ) or with MS.Net.2. Xamarian for Android uses Android SDK, Android AVD Manager and JRE 6 as same as what Eclipse uses.3. It have same fundamentals for Android development like Activity, AXML file, Android Designer Syntax etc.4. We can develop everything with Xamarian what we can do with Eclipse without knowledge of Java, even you can attach JAR file, and reuse the same C# code over other platform like iOS too, but it comes at a cost of minimum 299$ (starter edition is free).5. It is meant for collaborate and work, if we need JAR we need Java Developers and if we have reusable C# code then we need C# developers.6. If someone is comfortable with Eclipse and have no plan to develop App which needs to be ported on other platform, definitely there is no need to look for Xamarian.

In one line "Xamarian is for C# developers for agile commercial development".

as you mentioned this is just tool, and because it support a MS product should not be open 99%, so there is no any warranty and trust on tools!

What are you on about? If you are complaining that C# is a purely MS implementation, then you need to check your facts. Granted that MS "invented" C#, but they have formalised it and ratified it as an open standard. It's covered by ECMA 334. Oh, and what open standard is Java? You can find the C# standard here[^].

I was brought up to respect my elders. I don't respect many people nowadays.

A couple of points. First, which particular ranking are you using? TIOBE? Craigslist? JobServe? Monster? Rankings tend to be a useless indicator because their is no definitive source of data and this tends to be mined from other sources.

As to why C#? Well, if a developer is most comfortable in C#, then why shouldn't they use the language they are most comfortable with? And, as has been pointed out, this particular framework allows them to target other mobile platforms with the same code - something that you can't currently do with Java.

I was brought up to respect my elders. I don't respect many people nowadays.

I specifically targetted mobile devices here because you can't use Java on iPhone/iPad devices, and this article is about using a framework that will support those devices, as well as Android. Oh, and Xamarin have nothing to do with Microsoft - they are a completely external company.

I've done a fair bit with Java, as well as C#, and my background is C and C++. I'm not coming here as a language bigot, but rather stating that people should be able to choose the language they are most familiar with - and with which they can get the most effective return on their investment. Again, if they've gained deep familiarity with C#, then they should be able to use that language - especially as they can then use the same codebase on another mobile device with a simple recompilation. Prove me wrong. Show me code that will work the same on Windows Phone, an iPad 4, a Blackberry and a Galaxy Tab. You'll end up with one of two options - an HTML 5 app, or a Xamarin app.

From your initial comments in this thread, it seems like your objections are based more on a dislike of Microsoft than on a balanced viewpoint.

I was brought up to respect my elders. I don't respect many people nowadays.

"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David CrowNever mind - my own stupidity is the source of every "problem" - Mixture