- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 this我的android应用程序中的项目。
我的 list_style.xml 看起来像
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/libs/circularimageview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<com.mikhaellopez.circularimageview.CircularImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/kamilwirtek"
android:layout_gravity="left"
android:layout_margin="10dp"
android:id="@+id/avatar"
app:border="true"
app:border_color="#000000"
app:border_width="4dp"
app:shadow="true" />
<TextView
android:id="@+id/full_name"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25dp"
android:textColor="#111111"
android:text="TextView" />
</LinearLayout>
09-12 21:33:39.270 5506-5506/info.androidhive.materialdesign E/AndroidRuntime﹕ FATAL EXCEPTION: main
android.view.InflateException: Binary XML file line #10: Error inflating class com.mikhaellopez.circularimageview.CircularImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at info.androidhive.materialdesign.activity.CustomAdapter.getView(CustomAdapter.java:36)
at android.widget.AbsListView.obtainView(AbsListView.java:2271)
at android.widget.ListView.makeAndAddView(ListView.java:1769)
at android.widget.ListView.fillDown(ListView.java:672)
at android.widget.ListView.fillFromTop(ListView.java:733)
at android.widget.ListView.layoutChildren(ListView.java:1622)
at android.widget.AbsListView.onLayout(AbsListView.java:2106)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:907)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1649)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1507)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1420)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
at android.view.View.layout(View.java:13754)
at android.view.ViewGroup.layout(ViewGroup.java:4364)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1868)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1689)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4214)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
at android.view.Choreographer.doCallbacks(Choreographer.java:555)
at android.view.Choreographer.doFrame(Choreographer.java:525)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Nativ
09-12 21:35:22.970 5506-5510/info.androidhive.materialdesign D/dalvikvm﹕ GC_CONCURRENT freed 510K, 5% free 12177K/12807K, paused 23ms+8ms, total 69ms
CircularImageView circularImageView = (CircularImageView)getActivity().findViewById(R.id.avatar);
circularImageView.setBorderColor(getResources().getColor(R.color.GrayLight));
circularImageView.setBorderWidth(10);
circularImageView.addShadow();
09-12 21:41:21.359 8783-8783/info.androidhive.materialdesign E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.materialdesign/info.androidhive.materialdesign.activity.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at info.androidhive.materialdesign.activity.HomeFragment.onCreateView(HomeFragment.java:42)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1163)
at android.app.Activity.performStart(Activity.java:5018)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2032)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
最佳答案
您正试图从 Activity 的 View 而不是 fragment 的 View 中获取 View 。
代替:
CircularImageView circularImageView = (CircularImageView)getActivity().findViewById(R.id.avatar);
CircularImageView circularImageView = (CircularImageView)view.findViewById(R.id.avatar);
关于android - 错误膨胀类 - CircularImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32544065/
我正在尝试使用 this我的android应用程序中的项目。 我的 list_style.xml 看起来像 当我运行应用程序时,我收到以下代码错误: 09-12 21:33:39.270
CircularImageView,https://github.com/Pkmmte/CircularImageView , 在像这样设置图像位图时效果很好... circularImageView
我想创建类似于谷歌联系人应用程序的图标。 我希望提供背景颜色和文本并生成图标。 我目前正在尝试的是解决方案 here. 我正在使用 CircularImageView external libra
我正在使用类 posted on StackOverflow 我刚遇到 OutOfMemoryError: 提供 StackTrace: android.view.InflateException:
我正在尝试在 android studio 中使用 CircularImageView,但出现以下错误 java.lang.RuntimeException: Unable to start acti
我在不同的 API 上测试我的应用程序,它似乎可以在 API 17 到 23 上工作,但我发现在 API 16 中,我无法加载我的自定义 View 。我只想在一个圆圈中显示一张照片,并且我已经从此线程
我是一名优秀的程序员,十分优秀!