Reputation: 9439
I'm creating custom window title. I did it with requestWindowFeature and setFeatureInt but not work. I don't know what is wrong with this. I can't find where the errors come from.
public abstract class MegaActivity extends Activity {
private final int layoutID;
public MegaActivity(final int layoutID) {
super();
this.layoutID = layoutID;
}
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(layoutID);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
}
}
public class AsyncTaskTestActivity extends MegaActivity {
public AsyncTaskTestActivity() {
super(R.layout.main);
}
}
window_title.xml
<ImageView
android:id="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:src="@drawable/megadict_icon"/>
<TextView android:layout_width="wrap_content" android:id="@+id/textView1" android:layout_height="wrap_content" android:text="@string/appTitle" android:textSize="16dip" android:textColor="@color/white"></TextView>
</LinearLayout>
errors
07-06 23:42:46.996: ERROR/AndroidRuntime(774): FATAL EXCEPTION: main
07-06 23:42:46.996: ERROR/AndroidRuntime(774): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.asynctask/com.asynctask.AsyncTaskTestActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030002
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.os.Handler.dispatchMessage(Handler.java:99)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.os.Looper.loop(Looper.java:123)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at java.lang.reflect.Method.invokeNative(Native Method)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at java.lang.reflect.Method.invoke(Method.java:521)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at dalvik.system.NativeStart.main(Native Method)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030002
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.content.res.Resources.getValue(Resources.java:892)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.content.res.Resources.loadXmlResourceParser(Resources.java:1869)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.content.res.Resources.getLayout(Resources.java:731)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at com.android.internal.policy.impl.PhoneWindow.onIntChanged(PhoneWindow.java:992)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at com.android.internal.policy.impl.PhoneWindow.updateInt(PhoneWindow.java:2397)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at com.android.internal.policy.impl.PhoneWindow.setFeatureInt(PhoneWindow.java:933)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at com.asynctask.MegaActivity.onCreate(MegaActivity.java:20)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at com.asynctask.AsyncTaskTestActivity.onCreate(AsyncTaskTestActivity.java:26)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-06 23:42:46.996: ERROR/AndroidRuntime(774): ... 11 more
Upvotes: 0
Views: 599
Reputation: 780
is AsyncTaskTestActivity launcher activity?how did you call that activity?And the problem may be with your layouts,check your layout,whether it contains error or not?comment the requestWindowFeature and it related information temporarily,if you still get the error the problem with resources?your answers to my questions may help you
Upvotes: 1