An error occurred while binding xamarin SimpleAdapter. simpleadapter

Source: Internet
Author: User

An error occurred while binding xamarin SimpleAdapter. simpleadapter

Problem: today, when SimpleAdapter is bound to the ListView in the xamarin experiment, a crash occurs,

See figure: JavaDictionary<String, object> ();
Item. Add ("Name", "Zhang San );
Item. Add ("Sex", "Male ");
Data. Add (item );

Use the Android Device Logging tool that comes with VS2012 to view the following information:

  

Cause:

In vs2012, you cannot use the code to check for this problem. This is a running problem, but the exception cannot be thrown correctly. It can be seen through the Android Device Logging tool. It turns out that it is because of System. collections. generic. dictionary cannot be converted to java at runtime. util. map, while Android. runtime. javaDictionary is acceptable. As to why cannot be converted, there is no inheritance relationship.

Mono for android is very good, but it is too pitfall. It must be interface-oriented, so let's get a document to describe it.

 


Android SimpleAdapter error solution, first

If you use listActivity, you do not need setContentView (), and there is a ListView in your layout. In this case, an error is returned and the listview id cannot be found.
 
Can android simpleadapter be refilled? How to clear it?

Whatever data you put, after you put the data in
SimpleAdapter simpleAdapter;
SimpleAdapter. notifyDataSetChanged ();
SimpleAdapter. yydatasetinvalidated ();
Call these two methods, the source code is below, and then notify the corresponding component update of the adapter.
/**
* Notifies the attached View that the underlying data has been changed
* And it shoshould refresh itself.
*/
Public void notifyDataSetChanged (){
MDataSetObservable. policychanged ();
}

Public void policydatasetinvalidated (){
MDataSetObservable. policyinvalidated ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.