Reputation: 610
With this piece of code
final ListView lw = (ListView) findViewById( R.id.book_list );
lw.setVisibility(View.VISIBLE);
ListView listBookView = (ListView) findViewById( R.id.book_list );
ArrayList<HashMap<String, Object>> my_list = new ArrayList<HashMap<String, Object>>();
for ( int x=0; x< book_list.size(); x++)
{
String[] valori_book = book_list.get( x ).getObjVars();
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("book", valori_book[ 0 ]);
map.put("descr", valori_book[ 1 ] );
my_list.add(map);
}
// ...
SimpleAdapter showMenu = new SimpleAdapter(this, my_list, R.layout.activity_book_booklistmask,
new String[] { "book" , "descr" }, new int[] {R.id.nome_quaderno, R.id.descrizione_quaderno});
listBookView.setAdapter(showMenu);
java.lang.IllegalStateException: android.widget.ListView is not a view that can be bounds by this SimpleAdapter
The logcat doesn't write the error's row of my project so i don't know where check :/
E/AndroidRuntime( 904): java.lang.IllegalStateException: android.widget.ListView is not a view that can be bounds by this SimpleAdapter
E/AndroidRuntime( 904): at android.widget.SimpleAdapter.bindView(SimpleAdapter.java:195)
E/AndroidRuntime( 904): at android.widget.SimpleAdapter.createViewFromResource(SimpleAdapter.java:126)
E/AndroidRuntime( 904): at android.widget.SimpleAdapter.getView(SimpleAdapter.java:114)
E/AndroidRuntime( 904): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
E/AndroidRuntime( 904): at android.widget.ListView.makeAndAddView(ListView.java:1727)
E/AndroidRuntime( 904): at android.widget.ListView.fillDown(ListView.java:652)
E/AndroidRuntime( 904): at android.widget.ListView.fillFromTop(ListView.java:709)
E/AndroidRuntime( 904): at android.widget.ListView.layoutChildren(ListView.java:1580)
E/AndroidRuntime( 904): at android.widget.AbsListView.onLayout(AbsListView.java:1147)
E/AndroidRuntime( 904): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 904): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
E/AndroidRuntime( 904): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 904): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime( 904): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 904): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
E/AndroidRuntime( 904): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
E/AndroidRuntime( 904): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
E/AndroidRuntime( 904): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 904): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
E/AndroidRuntime( 904): at android.view.View.layout(View.java:7035)
E/AndroidRuntime( 904): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
E/AndroidRuntime( 904): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
E/AndroidRuntime( 904): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 904): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 904): at android.app.ActivityThread.main(ActivityThread.java:4627)
E/AndroidRuntime( 904): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 904): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 904): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
E/AndroidRuntime( 904): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
E/AndroidRuntime( 904): at dalvik.system.NativeStart.main(Native Method)
Upvotes: 1
Views: 1959
Reputation: 3282
From the SimpleAdapter documentation
A view that implements Checkable (e.g. CheckBox). The expected bind value is a boolean.
TextView. The expected bind value is a string and setViewText(TextView, String) is invoked.
ImageView. The expected bind value is a resource id or a string and setViewImage(ImageView, int) or setViewImage(ImageView, String) is invoked.
It would appear that passing an Object as the mapped object is not compatible with SimpleAdapter. Change the object type, or create a custom adapter (I recommend the later)
Upvotes: 1