toggle between android layout editor "Text" and android layout editor "Design"

My idea is getting "Text" component and "Design" component and set focus, so how to do it?

0

here is "Text" and "Design"

0

I find


FileEditorManager.getInstance(myProject).getAllEditors()

can get AndroidDesignerEditor and FileEditor, so question become "how to focus editor component"

0

here is my solution:

 

//pj is myProject
FileEditorManagerImpl fem = FileEditorManager.getInstance(pj)

VirtualFile vf = getVirtualFile("/home/roroco/Dropbox/try/adr/try/app/src/main/res/layout/content_main.xml")

FileEditor[] fes = fem.getAllEditors(vf)
if (fes.any { it instanceof AndroidDesignerEditor }) {
FileEditor fe = fem.getSelectedEditor(vf)
if (fe instanceof AndroidDesignerEditor) {
fem.setSelectedEditor(vf, TextEditorProvider.TYPE_ID)
} else {
fem.setSelectedEditor(vf, AndroidDesignerEditorProvider.ANDROID_DESIGNER_ID)
}
}
0

请先登录再写评论。