http://techdroid.kbeanie.com/2010/09/expandablelistview-on-android.htmlを実行しようとしていますが、monodroidを使用していますが、私の問題はJavaでプログラムするのに使用されていますが、私は問題をBaseAmpandListList groupPositionとchildPositionをリストから入れてください。どうすればこの問題を解決できますか?ExpandableListViewモノラル用
答えて
ExpandableListAdapter
を作成する際の問題は、このメソッドでは返さなければならないということです。Java.Lnag.Object.
私はあなたのjavaの例を動作させることができませんでした。
ただし、SimpleExpandableListAdapter
クラスを使用する代わりにExpandableListAdapter
を定義せずにExpandableListView
を使用する例を示します。
この例ではExpandableListView
を使用することができますが、BaseExpandableListAdapter
に付属する柔軟性は増しません。
using System;
using System.Collections.Generic;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace Scratch.ExpandableListActivity
{
[Activity (Label = "Scratch.ExpandableListActivity", MainLauncher = true)]
public class Activity1 : Android.App.ExpandableListActivity
{
IExpandableListAdapter mAdapter;
const string Name = "NAME";
const string IsEven = "IS_EVEN";
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
using (var groupData = new JavaList<IDictionary<string, object>>())
using (var childData = new JavaList<IList<IDictionary<string, object>>>()) {
for (int i = 0; i < 20; i++) {
using (var curGroupMap = new JavaDictionary<string, object>()) {
groupData.Add(curGroupMap);
curGroupMap.Add(Name, "Group " + i);
curGroupMap.Add(IsEven, (i % 2 == 0) ? "This group is even" : "This group is odd");
using (var children = new JavaList<IDictionary<string, object>>()) {
for (int j = 0; j < 15; j++) {
using (var curChildMap = new JavaDictionary<string, object>()) {
children.Add(curChildMap);
curChildMap.Add(Name, "Child " + j);
curChildMap.Add(IsEven, (j % 2 == 0) ? "This child is even" : "This child is odd");
}
}
childData.Add(children);
}
}
}
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter (
this,
groupData,
Android.Resource.Layout.SimpleExpandableListItem1,
new string[] { Name, IsEven},
new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 },
childData,
Android.Resource.Layout.SimpleExpandableListItem2,
new string[] { Name, IsEven },
new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 }
);
SetListAdapter(mAdapter);
}
}
}
}
これをフラグメントでどのように使用しますか? – MikeOscarEcho
前4.2(4.0.6など)にAndroidのためのMonoを使用して、バージョン、それは次のようにすべきである:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Collections.Generic;
namespace MonoAndroidApplication2
{
[Activity(Label = "Expandable List Activity", MainLauncher = true)]
public class Activity1 : ExpandableListActivity
{
IExpandableListAdapter mAdapter;
String NAME = "NAME";
String IS_EVEN = "IS_EVEN";
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
List< IDictionary <String , object >> groupData = new List< IDictionary < string , object >>();
List< IList<IDictionary< String, object>>> childData = new List < IList < IDictionary < string, object>>>();
for (int i = 0; i < 20; i++)
{
Dictionary< String, object > curGroupMap = new Dictionary < string , object >();
groupData.Add(curGroupMap);
curGroupMap.Add(NAME, "Group " + i);
curGroupMap.Add(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");
List< IDictionary <String , object >> children = new List< IDictionary < string , object >>();
for (int j = 0; j < 15; j++)
{
Dictionary< String, object > curChildMap = new Dictionary < string , object >();
children.Add(curChildMap);
curChildMap.Add(NAME, "Child " + j);
curChildMap.Add(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
}
childData.Add(children);
}
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter (
this,
groupData,
Android.Resource.Layout.SimpleExpandableListItem1,
new String[] { NAME, IS_EVEN },
new int[] { Android.Resource.Id.Text1, Android.Resource.Id.Text2 },
childData,
Android. Resource. Layout.SimpleExpandableListItem2,
new String[] { NAME, IS_EVEN },
new int[] { Android.Resource .Id.Text1, Android.Resource.Id.Text2 }
);
SetListAdapter(mAdapter);
}
}
}
このコード約任意のおかげでは、著者、lanksにあります。
それはそうかもしれません。 4.0.1と4.0.1の間の変更を最小限に抑えるために、4.0.6でも「更新された4.2.1」の回答が4.0.6でも有効であるはずです。 – jonp
- 1. Android用モノラル - ボイスレコーディング
- 2. モノラルLVL用と
- 3. モノラル用のネットコンポーネント
- 4. Android用モノラル - ExapandableListView
- 5. モノラルAndroid用Calendar
- 6. InvalidCastExceptionが(Android用モノラル)
- 7. Android用モノラル用Facebook SDK
- 8. ExpandableListView inside ExpandableListView
- 9. モノラルGTKでWebKitを使用
- 10. Android用モノラルとBaseExpandableListAdapterの例
- 11. モノラル、シェルスクリプト?
- 12. モノラルのICSharpテキストエディタ
- 13. モノラルでHttpContext.GetService
- 14. モノラルでPdfSharp
- 15. モノラルのテールコール
- 16. モノラルでaspnet_compiler
- 17. モノラルのオーチャードCMS
- 18. モノラルfor Android。ホームスクリーンウィジェット
- 19. Android用モノラル - デバッグのスピードアップ方法
- 20. アンドロイド:ExpandableListView
- 21. ExpandableListView onGroupLongClick
- 22. clear ExpandableListView
- 23. モノラル対応ネットワーク/ソケットライブラリ
- 24. モノラルのASP.NET MVC 2
- 25. モノラル、描画機能
- 26. ウィンドウとモノラルのSQLite?
- 27. モノラル.NETフレームワークとWMI
- 28. モノラルのASP.NET mvc 2.2
- 29. は、C#ではモノラル
- 30. ExpandableListViewとNavigationDrawer
私は質問をよく理解しているとは思わない。どのようにJavaコードでそれをやりますか? –