在我的 Activity 的 XML 中添加 EditText 时遇到问题。它不正确可见,当我运行应用程序时它就在那里,但是通过单击它,键盘没有显示我无法在那里添加任何输入。首先,我以为我只在这个活动中遇到了这个问题,但是当我尝试在项目的任何其他活动中添加 EditText 时,同样的事情正在发生,但是在我更新到新版本的 Android 之前已经添加了 EditText studio 4.0.1 在 XML 中运行良好,当我运行应用程序时 - 键盘出现,我可以添加输入,使用compileSdkVersion 29
minSdkVersion 18
targetSdkVersion 29
这是我的 XML。用于编辑此活动中的文本。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal"
android:background="@drawable/square_border">
<EditText
android:id="@+id/idOrderSummaryPostcode"
android:layout_width="0dp"
android:layout_height="50dp"
android:hint="Enter Postcode"
android:padding="5dp"
android:textSize="18sp"
android:layout_weight="1" />
<Button
android:id="@+id/idOrderSummaryPostcodeAddNew"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="+ New"
android:textAllCaps="false"
android:textSize="15sp"
android:background="@drawable/border_style_round_light_gray_solid"/>
</LinearLayout>
这是我的活动Manifest
<activity
android:name=".view.Order.Checkout"
android:screenOrientation="portrait" />
我已经onCreate
像这样初始化它
private EditText postcode;
postcode = findViewById(R.id.idOrderSummaryPostcode);
我在我的 XML 设计窗口中收到此错误。
index: 0, size:0
view draw detail(Details)
当我单击(详细信息)时,这里是此错误的详细信息。
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:657)
at java.util.ArrayList.get(ArrayList.java:433)
at com.android.ninepatch.NinePatchChunk.draw(NinePatchChunk.java:190)
at com.android.ninepatch.NinePatchChunk.draw(NinePatchChunk.java:106)
at android.graphics.BaseCanvas_Delegate$1.draw(BaseCanvas_Delegate.java:464)
at com.android.layoutlib.bridge.impl.GcSnapshot.drawInLayer(GcSnapshot.java:697)
at com.android.layoutlib.bridge.impl.GcSnapshot.draw(GcSnapshot.java:587)
at android.graphics.BaseCanvas_Delegate.nDrawNinePatch(BaseCanvas_Delegate.java:461)
at android.graphics.BaseCanvas.nDrawNinePatch(BaseCanvas.java)
at android.graphics.BaseCanvas.drawPatch(BaseCanvas.java:307)
at android.graphics.Canvas.drawPatch(Canvas.java:1825)
at android.graphics.NinePatch.draw(NinePatch.java:217)
at android.graphics.drawable.NinePatchDrawable.draw(NinePatchDrawable.java:249)
at android.graphics.drawable.DrawableContainer.draw(DrawableContainer.java:87)
at android.graphics.drawable.DrawableWrapper.draw(DrawableWrapper.java:240)
at android.view.View.drawBackground(View.java:21671)
at android.view.View.draw_Original(View.java:21435)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:21417)
at android.view.View.draw_Original(View.java:21317)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21446)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:21417)
at android.view.View.draw_Original(View.java:21317)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21315)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21315)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21446)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:21417)
at android.view.View.draw_Original(View.java:21317)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21446)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:21417)
at android.view.View.draw_Original(View.java:21317)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21446)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:21417)
at android.widget.ScrollView.draw(ScrollView.java:1835)
at android.view.View.draw_Original(View.java:21317)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21315)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21446)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:21417)
at android.view.View.draw_Original(View.java:21317)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21315)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21315)
at android.view.View_Delegate.draw(View_Delegate.java:68)
at android.view.View.draw(View.java:21089)
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:4388)
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:65)
at android.view.ViewGroup.drawChild(ViewGroup.java:4388)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4149)
at android.view.View.draw_Original(View.java:21446)
at android.view.View_Delegate.draw(View_Delegate.java:56)
at android.view.View.draw(View.java:21417)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:404)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:565)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:425)
at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:115)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:142)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:124)
at com.android.tools.idea.rendering.RenderTask.lambda$null$11(RenderTask.java:894)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
这是我的 XML 的屏幕截图,编辑文本在那里,但在这里不正确。
现在,这是下面错误的屏幕截图。
我试过的
- 清理项目
- 重建项目
- 关闭 Andorid Studio 并再次打开项目。
- 从“设置”->“实验”启用新的布局渲染引擎。
- 从“设置”->“实验”禁用新的布局渲染引擎。
- 通过清理无效现金
File ---> Invalid Cahes/ Restart
android:inputType="textNoSuggestions"
android:inputType="number"
android:inputType="text"
- 事实上,我已经一一尝试了所有的输入类型。
android:enabled="true"
android:focusableInTouchMode="true"
android:focusable="true"
- 尝试了不同的模拟器。
- 在物理设备上尝试过。
- 我试图通过
JAVA
postcode.setEnabled(true);
postcode.setFocusable(true);
谁能帮我这里有什么问题?谢谢!