Implement ListView and YouTubeFailureRecoveryActivity together in android app

*爱你&永不变心* 提交于 2020-01-06 14:05:13

问题


I am trying to implement something like which would be ideally like this but since multiple inheritance is not supported,

MyClass ABC extends ListActivity,YouTubeFailureRecoveryActivity{

}

I am using now

MyClass ABC extends YouTubeFailureRecoveryActivity{

}

and implementing listView using something like this but it is not working,the app works well on 2.3 but crashes sometimes in 4.1

The app crashes in 4.1 at

convertView = layoutInflator.inflate(R.layout.episode_list, null);

Is interface the only solution or is there anything else can also be done ?

Logcat

12-17 11:38:38.638: I/dalvikvm(31274):   at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
12-17 11:38:38.643: I/dalvikvm(31274):   at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:636)
12-17 11:38:38.643: I/dalvikvm(31274):   at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:484)
12-17 11:38:38.643: I/dalvikvm(31274):   at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:813)
12-17 11:38:38.643: I/dalvikvm(31274):   at android.content.res.Resources.loadDrawable(Resources.java:2277)
12-17 11:38:38.643: I/dalvikvm(31274):   at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
12-17 11:38:38.643: I/dalvikvm(31274):   at android.view.View.<init>(View.java:3463)
12-17 11:38:38.643: I/dalvikvm(31274):   at android.view.View.<init>(View.java:3396)
12-17 11:38:38.643: I/dalvikvm(31274):   at android.view.ViewGroup.<init>(ViewGroup.java:426)
12-17 11:38:38.658: I/dalvikvm(31274):   at android.widget.RelativeLayout.<init>(RelativeLayout.java:184)
12-17 11:38:38.658: I/dalvikvm(31274):   at java.lang.reflect.Constructor.constructNative(Native Method)
12-17 11:38:38.658: I/dalvikvm(31274):   at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
12-17 11:38:38.668: I/dalvikvm(31274):   at android.view.LayoutInflater.createView(LayoutInflater.java:593)
12-17 11:38:38.693: I/dalvikvm(31274):   at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
12-17 11:38:38.693: I/dalvikvm(31274):   at android.view.LayoutInflater.onCreateView(LayoutInflater.java:666)
12-17 11:38:38.693: I/dalvikvm(31274):   at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
12-17 11:38:38.693: I/dalvikvm(31274):   at android.view.LayoutInflater.rInflate(LayoutInflater.java:752)
12-17 11:38:38.693: I/dalvikvm(31274):   at android.view.LayoutInflater.inflate(LayoutInflater.java:495)
12-17 11:38:38.693: I/dalvikvm(31274):   at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-17 11:38:38.693: I/dalvikvm(31274):   at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-17 11:38:38.698: I/dalvikvm(31274):   at com.fictionadda.android.PlayMedia$CustomAdapter.getView(PlayMedia.java:779)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.AbsListView.obtainView(AbsListView.java:2472)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.ListView.makeAndAddView(ListView.java:1775)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.ListView.fillDown(ListView.java:678)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.ListView.fillFromTop(ListView.java:739)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.ListView.layoutChildren(ListView.java:1628)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.AbsListView.onLayout(AbsListView.java:2307)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.708: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.713: I/dalvikvm(31274):   at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.ScrollView.onLayout(ScrollView.java:1718)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.718: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.widget.RelativeLayout.onLayout(RelativeLayout.java:948)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.View.layout(View.java:14107)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.ViewGroup.layout(ViewGroup.java:4657)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2005)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1826)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1121)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4598)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.Choreographer.doCallbacks(Choreographer.java:555)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.Choreographer.doFrame(Choreographer.java:525)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.os.Handler.handleCallback(Handler.java:615)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.os.Handler.dispatchMessage(Handler.java:92)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.os.Looper.loop(Looper.java:137)
12-17 11:38:38.723: I/dalvikvm(31274):   at android.app.ActivityThread.main(ActivityThread.java:4921)
12-17 11:38:38.723: I/dalvikvm(31274):   at java.lang.reflect.Method.invokeNative(Native Method)
12-17 11:38:38.723: I/dalvikvm(31274):   at java.lang.reflect.Method.invoke(Method.java:511)
12-17 11:38:38.723: I/dalvikvm(31274):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
12-17 11:38:38.723: I/dalvikvm(31274):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
12-17 11:38:38.723: I/dalvikvm(31274):   at dalvik.system.NativeStart.main(Native Method)

回答1:


Made the following changes in the Manifest file and it worked !!!!!

 android:largeHeap="true"

In the manifest file in the <application> tag



来源:https://stackoverflow.com/questions/20627700/implement-listview-and-youtubefailurerecoveryactivity-together-in-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!