使用库HORIZONTAL LISTVIEW library。它昨天工作正常,但今天创建问题dnt知道发生了什么?我按照原样跟踪了所有内容:但是我在运行时遇到了错误 java.lang.NoClassDefFoundError:com.linearlistview.R $ attr 在com.linearlistview.LinearListView。(LinearListView.java:24) 我在xml中使用它很简单:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textview_videoname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="first heading text"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft"
android:textColor="@color/infotab_textview_topheading_fontcolor"
android:textSize="@dimen/infotab_topheadingfontsize"/>
<TextView
android:id="@+id/textview_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/infotab_secondtextview_margintop"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft"
android:maxLines="2"
android:text="second heading text"
android:textColor="@color/infotab_secondheading_foncolor"
android:textSize="@dimen/infotab_secondheadingfontsize" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/infotab_textviewcountry_marginbottom"
android:layout_marginTop="@dimen/infotab_textviewcountry_margintop"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft"
android:orientation="horizontal">
<TextView
android:id="@+id/textview_country"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:gravity="center_vertical|left"
android:maxLines="1"
android:text="country name"
android:textColor="@color/infotab_textview_topheading_fontcolor"
android:textSize="@dimen/infotab_textviewcountry_fontsize" />
<TextView
android:id="@+id/textview_date"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/videodetail_edit_marginright"
android:layout_weight="0.5"
android:gravity="center_vertical|right"
android:maxLines="1"
android:text="30 jul,15"
android:textColor="@color/infotab_textview_topheading_fontcolor"
android:textSize="@dimen/infotab_textviewcountry_fontsize" />
</LinearLayout>
<View
android:id="@+id/view_videodetail"
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="@android:color/darker_gray"
android:layout_below="@+id/videodetail_tabs"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
android:weightSum="1"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft">
<RelativeLayout
android:id="@+id/llayout_viewerscount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/infotab_textviewcountry_marginbottom"
android:layout_marginTop="@dimen/infotab_textviewcountry_margintop"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft"
android:layout_weight="0.32">
<ImageView
android:id="@+id/imageview_viewerscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|left"
android:src="@drawable/viewer_icon"
/>
<TextView
android:id="@+id/textview_viewerscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/videodetail_edit_marginright"
android:maxLines="1"
android:text="1996"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:layout_alignBottom="@+id/imageview_viewerscount"
android:layout_toRightOf="@+id/imageview_viewerscount"
android:textColor="@color/infotab_textview_topheading_fontcolor"
android:textSize="@dimen/infotab_textview_followers_fontsize" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/llayout_loved"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/infotab_textviewcountry_marginbottom"
android:layout_marginTop="@dimen/infotab_textviewcountry_margintop"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft"
android:layout_weight="0.32">
<ImageView
android:id="@+id/imageview_loved"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|left"
android:src="@drawable/love_icon"
/>
<TextView
android:id="@+id/textview_loved"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/videodetail_edit_marginright"
android:layout_alignBottom="@+id/imageview_loved"
android:layout_toRightOf="@+id/imageview_loved"
android:maxLines="1"
android:text="1996"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textColor="@color/infotab_textview_topheading_fontcolor"
android:textSize="@dimen/infotab_textview_followers_fontsize" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/llayout_share"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/infotab_textviewcountry_marginbottom"
android:layout_marginTop="@dimen/infotab_textviewcountry_margintop"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft"
android:layout_weight="0.32">
<ImageView
android:id="@+id/imageview_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical|left"
android:src="@drawable/share_icon"
/>
<TextView
android:id="@+id/textview_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/videodetail_edit_marginright"
android:layout_alignBottom="@+id/imageview_share"
android:layout_toRightOf="@+id/imageview_share"
android:maxLines="1"
android:text="Share"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:textColor="@color/infotab_textview_topheading_fontcolor"
android:textSize="@dimen/infotab_textview_followers_fontsize" />
</RelativeLayout>
</LinearLayout>
<View
android:id="@+id/view_videodetailbelow"
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="@android:color/darker_gray"
android:layout_below="@+id/videodetail_tabs"
/>
<RelativeLayout
android:id="@+id/rlayout_userprofile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft"
android:layout_marginBottom="@dimen/infotab_rlayout_userprofile_margintop"
android:layout_marginTop="@dimen/infotab_rlayout_userprofile_margintop">
<ImageView
android:id="@+id/imageview_userrprofile"
android:layout_width="@dimen/infotab_imageview_userrprofile_width"
android:layout_height="@dimen/infotab_imageview_userrprofile_height"
android:gravity="center_vertical|left"
android:background="@drawable/border"
/>
<LinearLayout
android:id="@+id/llayout_userinfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft"
android:layout_toRightOf="@+id/imageview_userrprofile">
<TextView
android:id="@+id/textview_username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/infotab_textview_username_fontsize"
android:gravity="center_vertical"
android:text="username"
android:textColor="@color/infotab_textview_topheading_fontcolor"
/>
<TextView
android:id="@+id/textview_totalfollowerscount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/infotab_textview_followers_fontsize"
android:gravity="center_vertical"
android:text="1595 followers"
android:textColor="@color/infotab_textview_topheading_fontcolor"
/>
</LinearLayout>
<ImageView
android:id="@+id/imageview_followprofile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:src="@drawable/btn_follow"
android:layout_marginRight="@dimen/videodetail_edit_marginright"
/>
</RelativeLayout>
<View
android:id="@+id/view_videodetailbottom"
android:layout_height="1dp"
android:layout_width="match_parent"
android:background="@android:color/darker_gray"
android:layout_below="@+id/videodetail_tabs"
/>
<TextView
android:id="@+id/textview_viewmore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="View More"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/videodetail_backarrow_marginleft"
android:layout_marginTop="@dimen/infotab_textview_viewmore_margintop"
android:layout_marginBottom="@dimen/infotab_textview_viewmore_marginbottom"
android:textSize="@dimen/infotab_textview_viewmore_fontsize"
android:textColor="@color/infotab_textview_viewmore_fontcolor"/>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.linearlistview.LinearListView
android:id="@+id/listview_morevideos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:showDividers="none"
/>
</HorizontalScrollView>
</LinearLayout>
</ScrollView>
</RelativeLayout>
并在gradle中添加:compile'com.github.frankiesardo:linearlistview:1.0.1@aar' 但我的logcat错误在这里:
Process: com.bcast, PID: 11078
java.lang.NoClassDefFoundError: com.linearlistview.R$attr
at com.linearlistview.LinearListView.<clinit>(LinearListView.java:24)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:600)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at com..bcast.ui.fragments.InfoFragment.onCreateView(InfoFragment.java:72)
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.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:490)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1105)
at android.support.v4.view.ViewPager.populate(ViewPager.java:951)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1473)
at android.view.View.measure(View.java:17437)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
at android.view.View.measure(View.java:17437)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5381)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.support.v7.internal.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:124)
at android.view.View.measure(View.java:17437)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5381)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:17437)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5381)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:17437)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5381)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1410)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:17437)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5381)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2586)
at android.view.View.measure(View.java:17437)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2297)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1401)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1602)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1259)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6521)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:813)
at android.view.Choreographer.doCallbacks(Choreographer.java:613)
at android.view.Choreographer.doFrame(Choreographer.java:583)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:799)
at