1
我在庫customAndroidLibrary中聲明瞭CustomLayout
類。這CustomLayout
延伸ViewGroup
。現在我想在我的項目中使用我的layout.xml
中的CustomLayout。我已經將這個庫包含在我的項目中。從項目庫中使用customview
CustomLayout類
package com.android.custom;
public class CustomLayout extends ViewGroup {
.....
}
layout.xml
<com.android.custom.CustomLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/animation_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
</com.android.custom.CustomLayout>
MainActivity
package com.android.ui;
public class MainActivity extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.layout);
}
}
但它扔ClassNotFoundException
。
即使它沒有檢測到我的Activity
也如果我使用的自定義視圖layout.xml
如果我在layout.xml
中使用簡單的TextView
。然後它沒有給出任何錯誤。
只是爲了驗證,你是否已將庫添加到項目的類路徑中? – Supreethks