Source Not Found Error Beginning Android 4 Application Development by Wei-Meng Lee, Eclipse REPOST -
this question exact duplicate of:
this re-post. need help! android beginner going through book right thats teaching me android called android 4 application development we-meng lee. making project uses preference fragment. however. when try run it, takes me screen in eclipse says "source not found "cmp=net.learn2develop.preferencefragmentexample/.preferencefragmentexampleactivity here code preferences.xml.
<?xml version="1.0" encoding="utf-8"?> <preferencescreen xmlns:android="http://schemas.android.com/apk/res/android" > <preferencecatagory android:title="catagory 1"> <checkboxpreference android:title="checkbox" android:defaultvalue="false" android:summary="true of false" android:key="checkboxpref" /> </preferencecatagory> <preferencecatagory android:title="catagory 2"> <edittextpreference android:name="edittext" android:summary="enter string" android:defaultvalue="[enter string here]" android:title="edit text" android:key="edittextpref" /> <ringtonepreference android:name="ringtone preference" android:summary="select ringtone" android:title="ringtones" android:key="ringtonepref" /> <preferencescreen android:title="second preference screen" android:summary="click here go second preference screen" android:key="secondprefscreenpref" /> <edittextpreference android:name="edittext" android:summary="enter string" android:title="edit text (second screen)" android:key="secondedittextpref" /> </preferencecatagory>
here code fragment1.java file.
package net.learn2develop.preferencefragmentexample; import android.os.bundle; import android.preference.preferencefragment; public class fragment1 extends preferencefragment { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); addpreferencesfromresource(r.xml.preferences); } }
and here preferenceexampleactivity.java file
package net.learn2develop.preferencefragmentexample; import android.app.activity; import android.app.fragmentmanager; import android.app.fragmenttransaction; import android.os.bundle; public class preferencefragmentexampleactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); fragmentmanager fragmentmanager = getfragmentmanager(); fragmenttransaction fragmenttransaction = fragmentmanager.begintransaction(); fragment1 fragment1 = new fragment1(); fragmenttransaction.replace(android.r.id.content, fragment1); fragmenttransaction.addtobackstack(null); fragmenttransaction.commit(); } }
can enlighten me on why doing this? appreciated!
the error seems clear, eclipse can't find preferencefragmentexampleactivity.java file in project. make sure file contains class preferencefragmentexampleactivity named preferencefragmentexampleactivity.java , in project (and not in other project). real beginner don't forget make clean of project , rebuild.
Comments
Post a Comment