android - Resource not found error when making list view -


in android trying make simple list, simple app crashes every time run same error. here code of main file

package com.example.test;  import java.util.arraylist;  import android.os.bundle; import android.widget.arrayadapter; import android.widget.listview; import android.app.activity;  public class mainactivity extends activity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         listview lv=(listview)findviewbyid(r.id.listview1);          arraylist<string> country=new arraylist<string>();         country.add("aaaaa");         country.add("aaaaa");         country.add("aaaaa");          arrayadapter<string> adapter=new arrayadapter<string>(getapplicationcontext(),r.id.listview1,country);         lv.setadapter(adapter);      }    } 

and xml file like

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:paddingbottom="@dimen/activity_vertical_margin"     android:paddingleft="@dimen/activity_horizontal_margin"     android:paddingright="@dimen/activity_horizontal_margin"     android:paddingtop="@dimen/activity_vertical_margin"     tools:context=".mainactivity" >      <listview         android:id="@+id/listview1"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:layout_alignparentleft="true"         android:layout_alignparenttop="true"         android:layout_marginleft="28dp"         android:layout_margintop="47dp" >     </listview>  </relativelayout> 

now error in log cat is.

07-15 18:09:22.235: e/androidruntime(1202): fatal exception: main 07-15 18:09:22.235: e/androidruntime(1202): android.content.res.resources$notfoundexception: resource id #0x7f080000 type #0x12 not valid 07-15 18:09:22.235: e/androidruntime(1202):     @ android.content.res.resources.loadxmlresourceparser(resources.java:2144) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.content.res.resources.getlayout(resources.java:853) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.layoutinflater.inflate(layoutinflater.java:394) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.arrayadapter.createviewfromresource(arrayadapter.java:371) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.arrayadapter.getview(arrayadapter.java:362) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.abslistview.obtainview(abslistview.java:2159) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.listview.measureheightofchildren(listview.java:1246) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.listview.onmeasure(listview.java:1158) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.view.measure(view.java:15518) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.relativelayout.measurechild(relativelayout.java:666) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.relativelayout.onmeasure(relativelayout.java:477) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.view.measure(view.java:15518) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:4825) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.framelayout.onmeasure(framelayout.java:310) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.view.measure(view.java:15518) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.linearlayout.measurevertical(linearlayout.java:847) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.linearlayout.onmeasure(linearlayout.java:588) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.view.measure(view.java:15518) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.viewgroup.measurechildwithmargins(viewgroup.java:4825) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.widget.framelayout.onmeasure(framelayout.java:310) 07-15 18:09:22.235: e/androidruntime(1202):     @ com.android.internal.policy.impl.phonewindow$decorview.onmeasure(phonewindow.java:2176) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.view.measure(view.java:15518) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.viewrootimpl.performmeasure(viewrootimpl.java:1874) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.viewrootimpl.measurehierarchy(viewrootimpl.java:1089) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.viewrootimpl.performtraversals(viewrootimpl.java:1265) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.viewrootimpl.dotraversal(viewrootimpl.java:989) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.viewrootimpl$traversalrunnable.run(viewrootimpl.java:4351) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.choreographer$callbackrecord.run(choreographer.java:749) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.choreographer.docallbacks(choreographer.java:562) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.choreographer.doframe(choreographer.java:532) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.view.choreographer$framedisplayeventreceiver.run(choreographer.java:735) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.os.handler.handlecallback(handler.java:725) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.os.handler.dispatchmessage(handler.java:92) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.os.looper.loop(looper.java:137) 07-15 18:09:22.235: e/androidruntime(1202):     @ android.app.activitythread.main(activitythread.java:5041) 07-15 18:09:22.235: e/androidruntime(1202):     @ java.lang.reflect.method.invokenative(native method) 07-15 18:09:22.235: e/androidruntime(1202):     @ java.lang.reflect.method.invoke(method.java:511) 07-15 18:09:22.235: e/androidruntime(1202):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 07-15 18:09:22.235: e/androidruntime(1202):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 07-15 18:09:22.235: e/androidruntime(1202):     @ dalvik.system.nativestart.main(native method) 

i read lot resource not found error , did every trick didn't work. removed r file, cleaned project, make new project failed.

inside array adapter change r.id.listview1 to android.r.layout.simple_list_item_1

arrayadapter<string> adapter=new arrayadapter<string>(getapplicationcontext(),android.r.layout.simple_list_item_1,country); 

Comments