Всё пытаюсь засунуть json в listview, примеров полно но я делаю это всё во фрагменте а не в активити...
Много всего пробывал проблема при создании адаптера:
MySimpleAdapter sAdapter = new MySimpleAdapter(this, data, R.layout.item, from, to);
listView.setAdapter(new ArrayAdapter(this, R.layout.page_search, items));
ArrayAdapter simpleAdapter = new SimpleAdapter(this, listView, android.R.layout.simple_list_item_1)
Всё ведёт к одному - SimpleAdapter cannot be applied
я так понял ошибка при передачи контекста, гугл советовал getActivity(), но элементы находятся в текущем фрагменте...
З.Ы Наверно вопрос туповат, но я уже 3 часа бьюсь пытаясь засунуть данные в listview
miklce: FATAL EXCEPTION: main
Process: com.example.mce.test1, PID: 4891
java.lang.ArrayIndexOutOfBoundsException: length=2; index=2
at android.widget.SimpleAdapter.bindView(SimpleAdapter.java:160)
at android.widget.SimpleAdapter.createViewFromResource(SimpleAdapter.java:126)
at android.widget.SimpleAdapter.getView(SimpleAdapter.java:114)
at android.widget.AbsListView.obtainView(AbsListView.java:2458)
at android.widget.ListView.onMeasure(ListView.java:1248)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16736)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1254)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.widget.ScrollView.onMeasure(ScrollView.java:326)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16736)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:940)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:610)
at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:78)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1132)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:675)
at android.view.View.measure(View.java:16736)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:940)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2392)
at android.view.View.measure(View.java:16736)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2103)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1402)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1103)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6018)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:799)
at android.view.Choreographer.doCallbacks(Choreographer.java:599)
at android.view.Choreographer.doFrame(Choreographer.java:559)
at android.view.Choreographer$FrameDisplayEventReceiver.run(
aol-nnov: FATAL EXCEPTION: main
Process: com.example.mce.test1, PID: 10263
java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:386)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
at android.widget.AbsListView.obtainView(AbsListView.java:2458)
at android.widget.ListView.onMeasure(ListView.java:1248)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16736)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1254)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.widget.ScrollView.onMeasure(ScrollView.java:326)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16736)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:940)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:610)
at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:78)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1132)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:675)
at android.view.View.measure(View.java:16736)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:940)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16736)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5184)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2392)
at android.view.View.measure(View.java:16736)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2103)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1216)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1402)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1103)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6018)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:799)
at android.view.Choreographer.doCallbacks(Choreographer.java:599)
at android.view.Choreographer.doFrame(Choreographer.java:559)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:784)
at android.os.Ha
Сорри но я пока плохо в ошибках явовских разбираюсь
ArrayAdapter requires the resource ID to be a TextView
Тоесть код работает, а передан Listview вместо TextView...
Как будет выглядить аналогичный код для Listview
Вот код.
miklce: ну ёлы.. ArrayAdapter requires the resource ID to be a TextView. чего тут не понятного? давай выложи минимальный нерабочий пример куда-нить..
или давай я тебе погуглю. https://github.com/codepath/android_guides/wiki/Us... например
miklce:
> Сорри но я пока плохо в ошибках явовских разбираюсь
там не сложно - сверху вних по строкам т.н. кадры стека - последовательность вызовов то бишь. и исключительная ситуация, вызвавшая ошибку.