我正试图在eclipse中导入这个android项目。
https://github.com/Pkmmte/CircularImageView
在xml中,我正在尝试使用ImageView
<com.pkmmte.view.CircularImageView
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_marginBottom="8sp"
android:layout_marginLeft="18sp"
android:layout_marginRight="8sp"
android:layout_marginTop="12sp"
app:border="true"
app:border_color="#EEEEEE"
app:border_width="4dp"
app:shadow="true" />
我收到错误
错误:解析XML时出错:未绑定前缀
但是我可以在Java代码中使用CircularImageView。当我输入Circular时,建议打开为..... com.pkmmte.circularimageview
那么为什么它不能在xml中运行?请帮忙..
编辑:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/ListB" >
<!--
<ImageView
android:id="@+id/imgvProfilePic"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_marginBottom="8sp"
android:layout_marginLeft="18sp"
android:layout_marginRight="8sp"
android:layout_marginTop="12sp" />
-->
<com.pkmmte.view.CircularImageView
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_alignParentLeft="true"
android:layout_marginBottom="8sp"
android:layout_marginLeft="18sp"
android:layout_marginRight="8sp"
android:layout_marginTop="12sp"
app:border="true"
app:border_color="#EEEEEE"
app:border_width="4dp"
app:shadow="true" />
<TextView
android:id="@+id/lblFamilyMemberItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15sp"
android:layout_toRightOf="@id/imgvProfilePic"
android:text="Name: "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/DarkGray" />
<TextView
android:id="@+id/lblFamilyMemberRelationItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/lblFamilyMemberItem"
android:layout_marginTop="2sp"
android:layout_toRightOf="@id/imgvProfilePic"
android:text="Relation: "
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/DarkGray" />
<View
android:id="@+id/view_sprtr_line"
android:layout_width="match_parent"
android:layout_height=".5dp"
android:layout_below="@+id/imgvProfilePic"
android:background="#D3D3D3" />
</RelativeLayout>
编辑:
之前我使用的是普通的ImageView,下面的代码正常运行。现在我用CircularImageView替换它,导致应用程序在运行时崩溃
public class FamilyMemberListAdapter extends ArrayAdapter<Map<String, String>> {
public static final String TAG = "FamilyMemberListAdapter";
List<Map<String, String>> familyMemberList = new ArrayList<Map<String, String>>();
private Activity activity;
public FamilyMemberListAdapter(Activity activity,
List<Map<String, String>> familyMemberList) {
super(activity, R.layout.activity_gch_family_members, familyMemberList);
this.activity = activity;
this.familyMemberList = familyMemberList;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {
convertView = LayoutInflater.from(this.getContext()).inflate(
R.layout.activity_gch_family_member_item, parent, false);
holder = new ViewHolder();
holder.lblFamilyMemberName = (TextView) convertView
.findViewById(R.id.lblFamilyMemberItem);
holder.lblFamilyMemberRelation = (TextView) convertView
.findViewById(R.id.lblFamilyMemberRelationItem);
holder.imgProfilePic = (CircularImageView) convertView
.findViewById(R.id.imgvProfilePic);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
int accountId = Integer.valueOf(familyMemberList.get(position).get(
"accountId"));
holder.imgProfilePic.setTag(accountId);
holder.lblFamilyMemberName.setText("Name: "
+ familyMemberList.get(position).get("name"));
holder.lblFamilyMemberRelation.setText("Relation: "
+ familyMemberList.get(position).get("relation"));
if (holder.imgProfilePic != null) {
downloadProfilePicToImageView(holder.imgProfilePic, accountId);
}
return convertView;
}
@Override
public int getCount() {
return familyMemberList.size();
}
static class ViewHolder {
TextView lblFamilyMemberName;
TextView lblFamilyMemberRelation;
CircularImageView imgProfilePic;
}
}
Logcat:
04-30 21:00:45.246: E/AndroidRuntime(18106): FATAL EXCEPTION: main
04-30 21:00:45.246: E/AndroidRuntime(18106): Process: com.bodimetrics, PID: 18106
04-30 21:00:45.246: E/AndroidRuntime(18106): android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class com.pkmmte.view.CircularImageView
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
04-30 21:00:45.246: E/AndroidRuntime(18106): at com.viatom.azur.tools.FamilyMemberListAdapter.getView(FamilyMemberListAdapter.java:45)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.AbsListView.obtainView(AbsListView.java:2346)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.ListView.measureHeightOfChildren(ListView.java:1280)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.ListView.onMeasure(ListView.java:1188)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.View.measure(View.java:18804)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.View.measure(View.java:18804)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.View.measure(View.java:18804)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
04-30 21:00:45.246: E/AndroidRuntime(18106): at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:446)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.View.measure(View.java:18804)
04-30 21:00:45.246: E/AndroidRuntime(18106): at com.jeremyfeinstein.slidingmenu.lib.CustomViewAbove.onMeasure(CustomViewAbove.java:456)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.View.measure(View.java:18804)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.View.measure(View.java:18804)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5954)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
04-30 21:00:45.246: E/AndroidRuntime(18106): at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2643)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.View.measure(View.java:18804)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2112)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1228)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1464)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1119)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6060)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.Choreographer.doCallbacks(Choreographer.java:670)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.Choreographer.doFrame(Choreographer.java:606)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.os.Handler.handleCallback(Handler.java:746)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.os.Handler.dispatchMessage(Handler.java:95)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.os.Looper.loop(Looper.java:148)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.app.ActivityThread.main(ActivityThread.java:5443)
04-30 21:00:45.246: E/AndroidRuntime(18106): at java.lang.reflect.Method.invoke(Native Method)
04-30 21:00:45.246: E/AndroidRuntime(18106): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
04-30 21:00:45.246: E/AndroidRuntime(18106): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-30 21:00:45.246: E/AndroidRuntime(18106): Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class com.pkmmte.view.CircularImageView
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
04-30 21:00:45.246: E/AndroidRuntime(18106): ... 42 more
04-30 21:00:45.246: E/AndroidRuntime(18106): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.pkmmte.view.CircularImageView" on path: DexPathList[[zip file "/data/app/com.bodimetrics-2/base.apk"],nativeLibraryDirectories=[/data/app/com.bodimetrics-2/lib/arm, /vendor/lib, /system/lib]]
04-30 21:00:45.246: E/AndroidRuntime(18106): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
04-30 21:00:45.246: E/AndroidRuntime(18106): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
04-30 21:00:45.246: E/AndroidRuntime(18106): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
04-30 21:00:45.246: E/AndroidRuntime(18106): at android.view.LayoutInflater.createView(LayoutInfl