2012-03-16 12 views
1

複数の列をサポートするC#Android Listviewを実行しようとしています。 私はここにリストビューを行うにはどのようにいくつかのコードが見つかりました:複数の列を持つAndroidリストビュー

 // List view control 
     ListView list = (ListView) FindViewById(Resource.Id.mylist); 
     List<Dictionary<string, string>> mylist = new List<Dictionary<string, string>>(); 
     Dictionary<string, string> map = new Dictionary<string, string>(); 

     map.Add("Profit Centre", "Systems"); 
     map.Add("Last Updated", "16/02/2012 15:34"); 
     mylist.Add(map); 
     map = new Dictionary<string, string>(); 
     map.Add("Profit Centre", "IDTS"); 
     map.Add("Last Updated", "20/02/2012 10:26"); 
     mylist.Add(map); 

     SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, Resource.Layout.list_item,new String[] {"Profit Centre", "Lasted Updated",}, new int[] { Resource.Id.columnA, Resource.Id.columnB}); 

     list.Adapter = mSchedule; 

SimpleAdapterは、第二のパラメータが正しくないことを不平を言う: http://www.heikkitoivonen.net/blog/2009/02/15/multicolumn-listview-in-android/

しかし、これは次のように私はC#のにそれを変換するJavaコードです。これは、この

ERROR 1 =

最良のオーバーロードされたメソッドの「Android.Widget.SimpleAdapter.SimpleAdapter(Android.Content.Context、System.Collections.Generic.IList>の一致、int型、文字列[]を報告し、 INT [])」は、いくつかの無効な引数を持ってい

ERROR 2 =

引数2:から変換できません 'System.Collections.Generic.IList> '

' から' System.Collections.Generic.List>

これはなぜですか?私はGoogleを使って、複数の列を持つリストビュー(Android用)を作成する方法があるのか​​どうかを調べていますが、JavaコードのみをC#で見つけることはできません。

おかげで、

アンドリュー・アシュクロフト

+0

あなたはアンドロイドのためのC#を使用していますデベロ何か? – alykhalid

+0

はい私はMonoDevelopを使用してC#でコードを開発しています – coolandy28

答えて

1

あなたは、Android SimpleAdapter

変更し、次のコード内でマイリストの定義と予想されるリストの間に矛盾があります。

  // List view control 
     ListView list = (ListView)FindViewById(Resource.Id.mylist); 
     IList<IDictionary<string, object>> mylist = new List<IDictionary<string, object>>(); 
     IDictionary<string, object> map = new Dictionary<string, object>(); 
     map.Add("Profit Centre", "Systems");  
     map.Add("Last Updated", "16/02/2012 15:34");  
     mylist.Add(map);  
     map = new Dictionary<string, object>()>;  
     map.Add("Profit Centre", "IDTS");  
     map.Add("Last Updated", "20/02/2012 10:26");  
     mylist.Add(map);  

     SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, Resource.Layout.list_item,new String[] {"Profit Centre", "Lasted Updated",}, new int[] { Resource.Id.columnA, Resource.Id.columnB});  

     ListAdapter = mSchedule; 

あなたの活動は、あなたが、

ListAdapter = mSchedule; 

に関して

シャロームKeynanをライン

list.Adapter = mSchedule; 

を交換する必要があるよりも、ListActivityを実装している場合

関連する問題