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 ();
}