SDK 8上没有看到Android Eclipse Layout

时间:2012-12-25 14:54:29

标签: android xml eclipse layout eclipse-adt

我在TARGET SDK上做了一个布局:17和MİNSDK:8。还可以。当它在SDK:17但当ı尝试使用SDK:8时它在底部给出了错误。任何人都可以告诉我怎么能在SDK上使我的代码工作:8谢谢你的帮助。  这是XML ....

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <TableLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:ignore="UselessParent" >

        <TableRow
            android:id="@+id/tableRow1"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <TextView
                android:id="@+id/textButtonBakici"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/textBakici" />

            <EditText
                android:id="@+id/editTextBakici"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3"
                android:layout_weight="1"
                android:hint="@string/altiyuzyirmibes"
                android:inputType="numberDecimal" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textKrediAraba"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/textKrediAraba"/>

            <EditText
                android:id="@+id/editTextKrediAraba"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3"
                android:layout_weight="1"
                android:hint="@string/besyuzdoksan"
                android:inputType="numberDecimal" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textOgrenimKredisi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/textOgrenimKredisi" />

            <EditText
                android:id="@+id/editTextOgrenimKredisi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3"
                android:layout_weight="1"
                android:hint="@string/dortyuzon"
                android:inputType="numberDecimal" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >

            <TextView
                android:id="@+id/textTatilKredisi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/textTatilKredisi"/>

            <EditText
                android:id="@+id/editTextTatilKredisi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3"
                android:layout_weight="1"
                android:hint="@string/yuzotuzbes"
                android:inputType="numberDecimal" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow5"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <TextView
                android:id="@+id/textFaturaElektrik"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/textFaturaElektrik" />

            <EditText
                android:id="@+id/editTextFaturaElektrik"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3"
                android:layout_weight="1"
                android:hint="@string/sifir"
                android:inputType="numberDecimal" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow6"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <TextView
                android:id="@+id/textFaturaSu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/textFaturaSu" />

            <EditText
                android:id="@+id/editTextFaturaSu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3"
                android:layout_weight="1"
                android:hint="@string/sifir"
                android:inputType="numberDecimal" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow7"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <TextView
                android:id="@+id/textFaturaInternet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/textFaturaInternet" />

            <EditText
                android:id="@+id/editTextFaturaInternet"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3"
                android:layout_weight="1"
                android:hint="@string/otuz"
                android:inputType="numberDecimal" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow8"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <TextView
                android:id="@+id/textAidat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/textAidat"/>

            <EditText
                android:id="@+id/editTextAidat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3"
                android:layout_weight="1"
                android:hint="@string/sifir"
                android:inputType="numberDecimal" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow9"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <TextView
                android:id="@+id/textKaskoSigorta"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="@string/textKaskoSigorta" />

            <EditText
                android:id="@+id/editTextKaskoSigorta"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_span="3"
                android:layout_weight="1"
                android:ems="10"
                android:hint="@string/ikiyuzyirmibes"
                android:inputType="numberDecimal" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow10"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="10"
                android:orientation="horizontal" >

                <Spinner
                    android:id="@+id/spinnerYillar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="3"
                    android:entries="@array/Yillar"
                    android:prompt="@string/promptYillar" />

                <Spinner
                    android:id="@+id/spinnerAylar"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="3"
                    android:entries="@array/Aylar"
                    android:prompt="@string/prompt" />
            </LinearLayout>

            <Button
                android:id="@+id/buttonIleri"
                style="?android:attr/buttonStyleSmall"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="right"
                android:layout_weight="0"
                android:background="@drawable/navigation_forward"
                android:gravity="right" />
        </TableRow>
    </TableLayout>

</LinearLayout>

以下是错误日志:

!ENTRY com.android.ide.eclipse.adt 4 0 2012-12-25 16:41:18.827
!MESSAGE butcegiris.xml: Index: 1, Size: 1
!STACK 0
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at com.android.ninepatch.NinePatchChunk.draw(NinePatchChunk.java:174)
    at com.android.ninepatch.NinePatchChunk.draw(NinePatchChunk.java:101)
    at android.graphics.NinePatch_Delegate$1.draw(NinePatch_Delegate.java:219)
    at com.android.layoutlib.bridge.impl.GcSnapshot.drawInLayer(GcSnapshot.java:608)
    at com.android.layoutlib.bridge.impl.GcSnapshot.draw(GcSnapshot.java:577)
    at android.graphics.NinePatch_Delegate.draw(NinePatch_Delegate.java:217)
    at android.graphics.NinePatch_Delegate.nativeDraw(NinePatch_Delegate.java:170)
    at android.graphics.NinePatch.nativeDraw(NinePatch.java)
    at android.graphics.NinePatch.draw(NinePatch.java:104)
    at android.graphics.drawable.NinePatchDrawable.draw(NinePatchDrawable.java:188)
    at android.view.View.draw(View.java:6725)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
    at android.view.View.draw(View.java:6743)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
    at android.view.View.draw(View.java:6743)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:466)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:320)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:440)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1545)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1302)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.changed(GraphicalEditorPart.java:718)
    at com.android.ide.eclipse.adt.internal.editors.layout.configuration.ConfigurationChooser.setConfiguration(ConfigurationChooser.java:632)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderPreviewManager.switchTo(RenderPreviewManager.java:1352)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderPreview.click(RenderPreview.java:837)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderPreviewManager.click(RenderPreviewManager.java:1494)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GestureManager$Listener.mouseUp(GestureManager.java:469)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:219)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    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:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)

!ENTRY com.android.ide.eclipse.adt 4 0 2012-12-25 16:41:18.991
!MESSAGE butcegiris.xml: Index: 1, Size: 1
!STACK 0
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

3 个答案:

答案 0 :(得分:2)

问题不在于SDK版本或目标版本。问题在于你在某个地方使用了arraylist并且那里有一个错误的索引映射。

日志猫清楚地显示:索引为1,大小为1

这意味着你的索引的数量超过了arraylist / array的大小。

请您分享活动代码或自行检查尺寸问题

由于

答案 1 :(得分:1)

根据我的经验,根据我在谷歌io视频中听到的内容,你应该总是使用最新的SDK为你的应用程序,包括ui设计师。

原因是谷歌仅更新(或大部分)设计师的最新sdk目标,因此比以前的版本具有更少的错误。

另外,请注意,即使是现在,与真实设备(甚至模拟器)上发生的事情相比,您也无法完全信任ui设计师。很多时候它不能很好地显示(或根本不显示)因为它尚未得到支持(例如文本阴影,部分圆形图像角落......)。

所以,简而言之,总是将targetSdk设置为最新的(minSdk应该是你想要的),包括ui设计师,如果你想在旧版本上检查它,请尝试使用模拟器(或者真实的设备)以防万一有些可疑。

答案 2 :(得分:1)

这不是你的代码中的错误,但它是android sdk的渲染库中一个众所周知的错误。

参考: bug in android rendering layout