Android 1.5 Gridview Problem

Posted by flybirdtt on Stack Overflow See other posts from Stack Overflow or by flybirdtt
Published on 2010-06-14T09:31:00Z Indexed on 2010/06/14 9:52 UTC
Read the original article Hit count: 952

Filed under:

I used a gridview in this app.

When i run it at Verison 1.6 or newer, it's OK. But i can not get this gridview in 1.5.

I always show this info and exception:

Unable to resolve drawable "com.android.layoutlib.utils.DensityBasedResourceValue@397660" in attribute "listSelector"
org.xmlpull.v1.XmlPullParserException: Binary XML file line #3:  tag requires a 'drawable' attribute or child tag defining a drawable
    at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:151)
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:779)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:720)
    at com.android.layoutlib.bridge.ResourceHelper.getDrawable(ResourceHelper.java:150)
    at com.android.layoutlib.bridge.BridgeTypedArray.getDrawable(BridgeTypedArray.java:668)
    at android.widget.AbsListView.(AbsListView.java:514)
    at android.widget.GridView.(GridView.java:69)
    at android.widget.GridView.(GridView.java:65)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at android.view.LayoutInflater.createView(LayoutInflater.java:499)
    at android.view.BridgeInflater.onCreateView(BridgeInflater.java:77)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:562)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:122)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:617)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:620)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:296)
    at com.android.layoutlib.bridge.Bridge.computeLayout(Bridge.java:377)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.computeLayout(Unknown Source)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.recomputeLayout(Unknown Source)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle1.GraphicalLayoutEditor.activated(Unknown Source)
    at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditor.pageChange(Unknown Source)
    at org.eclipse.ui.part.MultiPageEditorPart.setActivePage(MultiPageEditorPart.java:1076)
    at org.eclipse.ui.forms.editor.FormEditor.setActivePage(FormEditor.java:601)
    at com.android.ide.eclipse.adt.internal.editors.AndroidEditor.selectDefaultPage(Unknown Source)
    at com.android.ide.eclipse.adt.internal.editors.AndroidEditor.addPages(Unknown Source)
    at org.eclipse.ui.forms.editor.FormEditor.createPages(FormEditor.java:138)
    at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(MultiPageEditorPart.java:357)
    at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:662)
    at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:462)
    at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
    at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
    at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
    at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
    at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
    at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
    at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1256)
    at org.eclipse.ui.internal.PartStack.setSelection(PartStack.java:1209)
    at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:1608)
    at org.eclipse.ui.internal.PartStack.add(PartStack.java:499)
    at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103)
    at org.eclipse.ui.internal.PartStack.add(PartStack.java:485)
    at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112)
    at org.eclipse.ui.internal.EditorSashContainer.addEditor(EditorSashContainer.java:63)
    at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorAreaHelper.java:225)
    at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAreaHelper.java:213)
    at org.eclipse.ui.internal.EditorManager.createEditorTab(EditorManager.java:778)
    at org.eclipse.ui.internal.EditorManager.openEditorFromDescriptor(EditorManager.java:677)
    at org.eclipse.ui.internal.EditorManager.openEditor(EditorManager.java:638)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2854)
    at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2762)
    at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2754)
    at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2705)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2701)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2685)
    at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2676)
    at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
    at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
    at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:361)
    at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:168)
    at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:229)
    at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:208)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:274)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActionGroup.handleOpen(PackageExplorerActionGroup.java:373)
    at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4.open(PackageExplorerPart.java:526)
    at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:48)
    at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:842)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.runtime.Platform.run(Platform.java:888)
    at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:48)
    at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
    at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:840)
    at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1101)
    at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1205)
    at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:264)
    at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:258)
    at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:298)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1311)

This is the layout xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:background="@drawable/menu_background2">    
<LinearLayout android:id="@+id/logopanel"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_alignParentTop="true"
    android:layout_marginTop="50dip" android:gravity="center"
    android:layout_marginBottom="10dip">        
    <ImageButton android:id="@+id/searchbar"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:background="@drawable/fake_search_bar"></ImageButton>   
</LinearLayout> 
<LinearLayout android:id="@+id/iconpanel"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:layout_below="@+id/logopanel"
    android:layout_above="@+id/allbotpanel" android:layout_marginTop="10dip">       
    <GridView android:id="@+id/gridcontent" android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:gravity="center"
        android:numColumns="3" android:layout_gravity="center"
        android:layout_centerInParent="true" android:background="@drawable/transparent_backgroud"
        android:listSelector="@drawable/gridviewselector">      
    </GridView> 
</LinearLayout> 
<RelativeLayout android:id="@+id/allbotpanel"
    android:layout_width="fill_parent" android:layout_height="75dip"
    android:background="@drawable/amex_bottom_bar"
    android:layout_alignParentBottom="true">        
    <LinearLayout android:id="@+id/noticebar"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:layout_height="29dip" android:layout_above="@+id/homebottombar">            
        <ImageButton android:id="@+id/infoicon"
            android:layout_width="wrap_content" android:layout_height="wrap_content"
            android:layout_gravity="left|center_vertical"
            android:layout_marginLeft="10dip" android:background="@drawable/amex_info_button" android:src="@drawable/infoselector"></ImageButton>           
        <TextView android:id="@+id/noticeicon" android:gravity="center"
            android:layout_gravity="right|center_vertical" android:layout_width="wrap_content"
            android:layout_height="25dip" android:layout_weight="1"
            android:clickable="true" android:focusable="true" android:text="@string/notice_string"></TextView>      
    </LinearLayout>     
    <LinearLayout android:id="@+id/homebottombar"
        android:orientation="horizontal" android:layout_width="fill_parent"
        android:layout_height="46dip" android:gravity="center"
        android:layout_alignParentBottom="true" android:background="@drawable/amex_bottom_bar"
        android:layout_marginBottom="3dip"></LinearLayout>  
</RelativeLayout>
</RelativeLayout>

© Stack Overflow or respective owner

Related posts about android