无法将文本字段添加到Android应用程序

时间:2014-07-10 07:55:37

标签: android eclipse

我在Eclipse / Android中编写了一些小应用程序,所以我对整个edi并不是全新的。

我在家里创建了一些屏幕(一个登录屏幕和一个或两个以上),应用程序工作正常,现在我想在工作中构建相同的屏幕我不能将任何文本控件拖到应用程序页面上,它给我下面的错误,屏幕保持空白?下面是我的XMl和错误:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".LoginScreen" >

    <EditText
        android:id="@+id/textboxUserName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="121dp"
        android:ems="10"
        android:hint="@string/blankstring"
        android:text="@string/blankstring" />

    <TextView
        android:id="@+id/labelusername"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/textboxUserName"
        android:layout_alignLeft="@+id/textboxUserName"
        android:layout_marginBottom="39dp"
        android:hint="@string/LblUsername"
        android:text="@string/LblUsername"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:id="@+id/btnLogin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/passwordboxPassword"
        android:layout_alignRight="@+id/passwordboxPassword"
        android:layout_below="@+id/passwordboxPassword"
        android:layout_marginTop="19dp"
        android:focusable="false"
        android:hint="@string/btnLogin"
        android:text="@string/btnLogin" />

    <TextView
        android:id="@+id/labelpassword"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textboxUserName"
        android:layout_below="@+id/textboxUserName"
        android:layout_marginTop="21dp"
        android:hint="@string/LblPassword"
        android:text="@string/LblPassword"
        android:textAppearance="?android:attr/textAppearanceLarge" />
<requestFocus />

    <EditText
        android:id="@+id/passwordboxPassword"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/labelpassword"
        android:layout_below="@+id/labelpassword"
        android:ems="10"
        android:hint="@string/blankstring"
        android:inputType="textPassword"
        android:text="@string/blankstring" >

    </EditText>

    <TextView
        android:id="@+id/lblnewuser"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/btngooglelogin"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="51dp"
        android:text="@string/lblNewUser"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <Button
        android:id="@+id/btnRegister"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/btnLogin"
        android:layout_alignRight="@+id/btnLogin"
        android:layout_below="@+id/lblnewuser"
        android:layout_marginTop="11dp"
        android:text="@string/btnRegister" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/labelusername"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:contentDescription="@string/blankstring"
        android:src="@drawable/logo" />

    <ImageButton
        android:id="@+id/btnfacebooklogin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/lblnewuser"
        android:layout_marginRight="24dp"
        android:layout_toLeftOf="@+id/imageView1"
        android:background="@android:color/transparent"
        android:contentDescription="@string/blankstring"
        android:src="@drawable/facebookloginicon" />

    <ImageButton
        android:id="@+id/btngooglelogin"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/labelpassword"
        android:layout_below="@+id/btnLogin"
        android:layout_marginRight="24dp"
        android:layout_marginTop="15dp"
        android:background="@android:color/transparent"
        android:contentDescription="@string/blankstring"
        android:scaleType="fitCenter"
        android:src="@drawable/gplusloginpiclarge" />


</RelativeLayout>

,错误是:

java.lang.NoSuchMethodError: java.lang.System.arraycopy([CI[CII)V
at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:916)
at android.text.TextUtils.getChars(TextUtils.java:79)
at android.text.method.ReplacementTransformationMethod$ReplacementCharSequence.getChars(ReplacementTransformationMethod.java:151)
at android.text.TextUtils.getChars(TextUtils.java:79)
at android.text.MeasuredText.setPara(MeasuredText.java:106)
at android.text.StaticLayout.generate(StaticLayout.java:239)
at android.text.DynamicLayout.reflow(DynamicLayout.java:284)
at android.text.DynamicLayout.<init>(DynamicLayout.java:170)
at android.widget.TextView.makeSingleLayout(TextView.java:6134)
at android.widget.TextView.makeNewLayout(TextView.java:6032)
at android.widget.TextView.onMeasure(TextView.java:6389)
at android.view.View.measure(View.java:16648)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
at android.view.View.measure(View.java:16648)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16648)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:337)
at android.view.View.measure(View.java:16648)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1052)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:590)
at android.view.View.measure(View.java:16648)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16648)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16648)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:619)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:519)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:339)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:517)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1584)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1309)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.onXmlModelChanged(GraphicalEditorPart.java:1267)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegateXmlModelChanged(LayoutEditorDelegate.java:402)
at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.xmlModelChanged(CommonXmlEditor.java:329)
at com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor$XmlModelStateListener.modelChanged(AndroidXmlEditor.java:1653)
at com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor.wrapEditXmlModel(AndroidXmlEditor.java:1114)
at com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor.wrapUndoEditXmlModel(AndroidXmlEditor.java:1190)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.MoveGesture.drop(MoveGesture.java:396)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GestureManager$CanvasDropListener.drop(GestureManager.java:679)
at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:91)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1085)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1070)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:782)
at org.eclipse.swt.dnd.DropTarget.Drop(DropTarget.java:456)
at org.eclipse.swt.dnd.DropTarget.Drop_64(DropTarget.java:392)
at org.eclipse.swt.dnd.DropTarget$3.method6(DropTarget.java:260)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:119)
at org.eclipse.swt.internal.ole.win32.COM.DoDragDrop(Native Method)
at org.eclipse.swt.dnd.DragSource.drag(DragSource.java:363)
at org.eclipse.swt.dnd.DragSource.access$0(DragSource.java:289)
at org.eclipse.swt.dnd.DragSource$1.handleEvent(DragSource.java:172)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
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:648)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

我的屏幕是空白的,如下图所示:

Using Eclipse Luna

我错过了参考?我应该安装其他东西吗?我不知道这里有什么问题,显然我可以将应用程序上传到我的手机但它会立即崩溃

1 个答案:

答案 0 :(得分:5)

点击绿色Android图标(&#34;在Eclipse和#34中渲染布局时使用的Android版本)并选择API 19:Android 4.4.2而不是API 20:Android 4.4W。这将解决问题。

请检查this answer