1

好像我不能把我的requestFocus裏面TextInputEditText,因爲它會導致預覽屏幕上呈現的問題該堆棧跟蹤:TextInputEditText requestFocus的XML中引起呈現問題

android.content.res.Resources$NotFoundException: Unable to find resource ID #0x1ff0005 
at android.content.res.Resources.getResourceName(Resources.java:2235) 
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2602) 
at android.content.res.Resources.loadDrawable(Resources.java:2540) 
at android.content.res.Resources.getDrawable(Resources.java:806) 
at android.content.Context.getDrawable(Context.java:458) 
at android.widget.Editor.updateCursorPosition(Editor.java:2007) 
at android.widget.Editor.updateCursorsPositions(Editor.java:1703) 
at android.widget.TextView.getUpdatedHighlightPath(TextView.java:5526) 
at android.widget.TextView.onDraw(TextView.java:5713) 
at android.view.View.draw(View.java:16178) 
at android.view.View.draw(View.java:16090) 
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) 
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3609) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) 
at android.view.View.draw(View.java:16181) 
at android.support.design.widget.TextInputLayout.draw(TextInputLayout.java:845) 
at android.view.View.draw(View.java:16090) 
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) 
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3609) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) 
at android.view.View.draw(View.java:16088) 
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) 
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3609) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) 
at android.view.View.draw(View.java:16088) 
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) 
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3609) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) 
at android.view.View.draw(View.java:16088) 
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) 
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3609) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) 
at android.view.View.draw(View.java:16088) 
at android.view.ViewGroup.drawChild_Original(ViewGroup.java:3609) 
at android.view.ViewGroup_Delegate.drawChild(ViewGroup_Delegate.java:61) 
at android.view.ViewGroup.drawChild(ViewGroup.java:3609) 
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3399) 
at android.view.View.draw(View.java:16181) 
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:431) 
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:428) 
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350) 
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510) 
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498) 
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888) 
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498) 
at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72) 
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610) 
at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607) 
at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362) 
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607) 
at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629) 
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:652) 
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80) 
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:594) 
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152) 
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452) 
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402) 
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54) 
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137) 
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:589) 
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320) 
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310) 
at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254) 
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269) 
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227) 
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217) 
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) 
at com.intellij.util.Alarm$Request$1.run(Alarm.java:351) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
at java.lang.Thread.run(Thread.java:745) 

XML

<android.support.design.widget.TextInputEditText 
    ... > 

    <requestFocus /> 
</android.support.design.widget.TextInputEditText> 

我該如何解決這個問題?

+0

堆棧跟蹤是說** android.content.res.Resources $ NotFoundException:無法找到資源ID#0x1ff0005 **。你確定資源存在於xml中,或者你指的是正確的id嗎? –

+0

@BaluSKT先生,我認爲這不是我的問題。我沒有在我的XML中引用任何資源ID,當我包含''時,錯誤顯示_only_' – simplebe

回答

2

下面的Java代碼工作對我來說:

TextInputEditText tEdit = (TextInputEditText) findViewById(...); 
tEdit.requestFocus(); // (java) 

<requestFocus() /> //not work for TextinputEditText in xml.