Android - ava.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView

   
Vista:

ava.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView

Publicado por Miki mikibardaji@hotmail.com (6 intervenciones) el 03/12/2015 18:41:53
Hola soy novato en android.

Me sale el siguiente error

FATAL EXCEPTION: main
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:2465)
at android.widget.ListView.makeAndAddView(ListView.java:1775)
at android.widget.ListView.fillDown(ListView.java:678)
at android.widget.ListView.fillFromTop(ListView.java:739)
at android.widget.ListView.layoutChildren(ListView.java:1628)
at android.widget.AbsListView.onLayout(AbsListView.java:2300)
at android.view.View.layout(View.java:13916)
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13916)
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:435)
at android.view.View.layout(View.java:13916)
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13916)
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
at android.view.View.layout(View.java:13916)
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13916)
at android.view.ViewGroup.layout(ViewGroup.java:4424)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2021)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1842)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1135)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4635)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4963)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:379)
at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362) 
at android.widget.AbsListView.obtainView(AbsListView.java:2465) 
at android.widget.ListView.makeAndAddView(ListView.java:1775) 
at android.widget.ListView.fillDown(ListView.java:678) 
at android.widget.ListView.fillFromTop(ListView.java:739) 
at android.widget.ListView.layoutChildren(ListView.java:1628) 
at android.widget.AbsListView.onLayout(AbsListView.java:2300) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424) 
at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424) 
at android.support.v7.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:435) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424) 
at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424) 
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655) 
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513) 
at android.widget.LinearLayout.onLayout(LinearLayout.java:1426) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424) 
at android.widget.FrameLayout.onLayout(FrameLayout.java:448) 
at android.view.View.layout(View.java:13916) 
at android.view.ViewGroup.layout(ViewGroup.java:4424) 
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2021) 
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1842) 
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1135) 
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4635) 
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725) 
at android.view.Choreographer.doCallbacks(Choreographer.java:555) 
at android.view.Choreographer.doFrame(Choreographer.java:525) 
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711) 
at android.os.Handler.handleCallback(Handler.java:615) 
at android.os.Handler.dispatchMessage(Handler.java:92) 
at android.os.Looper.loop(Looper.java:137) 
at android.app.ActivityThread.main(ActivityThread.java:4963) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:511) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805) 
at dalvik.system.NativeStart.main(Native Method) 



Como se puede ver, todas las lineas, ninguna es de las que he escrito yo, y no se exactamente donde falla

Pero supongo que es en la mainactivity


public class MainActivity extends AppCompatActivity {

ListView lista;
ArrayAdapter<String> adaptador;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

lista = (ListView)findViewById(R.id.lista);

adaptador = new ArrayAdapter<String>(this,android.R.layout.two_line_list_item,DataSource.TAREAS);
lista.setAdapter(adaptador);
}
}



El datasource es una clase sencilla así


public class DataSource {

static List TAREAS = new ArrayList<Tarea>();

static{

TAREAS.add(new Tarea("Trotar 30 minutos","08:00"));
TAREAS.add(new Tarea("Estudiar análisis técnico","10:00"));
TAREAS.add(new Tarea("Comer 4 rebanadas de manzana","10:30"));
TAREAS.add(new Tarea("Asistir al taller de programación gráfica","15:45"));
TAREAS.add(new Tarea("Consignarle a Marta","18:00"));

}

}


podriais darme una pista por favor
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder