EditText焦点问题

时间:2015-07-06 12:05:25

标签: android android-edittext focus

我有两个焦点问题:

  1. 如果我的EditText被关注并且显示键盘;然后我按下硬件后退键,键盘 隐藏但我的EditText仍然是焦点(它仍然显示一个闪烁的光标)。

  2. 当我按下工具栏中EditText左侧的actionbartoggle时,键盘可见且EditText被聚焦,键盘隐藏,EditText失去焦点。这是正确的。但是当我按下ButtonEditText的右侧)而键盘显示且EditText有焦点时,除Button侦听器外没有任何其他事情发生。 当我将focusableintouchmode=truefocusable=true属性放在Button上时,键盘会隐藏,EditText会失去焦点但听众不再工作

        <android.support.v7.widget.Toolbar
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/toolbar"
        style="@style/toolbarStyle"
        android:layout_width="match_parent"
        android:layout_height="@dimen/toolbarHeight" >
    
        <RelativeLayout
            android:id="@+id/focusHolder"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:layout_centerVertical="true"
            >
    
            <ImageButton
                android:id="@+id/refreshBtn"
                android:src="@drawable/refreshicon"
                android:layout_width="48dp"
                android:layout_height="match_parent"
                android:layout_alignParentRight="true"
                android:background="@null" />
    
            <EditText
                android:id="@+id/addressBar"
                android:layout_width="match_parent"
                android:layout_height="30dp"
                android:layout_toLeftOf="@id/refreshBtn"
                android:singleLine="true"
                android:imeOptions="actionGo"
                android:layout_centerVertical="true"
                android:drawableLeft="@drawable/searchicon"
                android:drawablePadding="5dp"
                style="@style/addressBarStyle"/>
    
        </RelativeLayout>
    </android.support.v7.widget.Toolbar>
    

1 个答案:

答案 0 :(得分:0)

试试这段代码......

Public Sub Function3_FileExplorer()
Dim file As Variant
'   Start File Explorer to select file containing data (simple GUI, much easier than coding vFileName)
With Application.FileDialog(msoFileDialogOpen)
    .AllowMultiSelect = False
    If .Show Then
        file = .SelectedItems(1)
        Path = file
    End If
End With
MsgBox file

Exit Sub
ErrorHandler:
MsgBox "Error detected" & vbNewLine & "Error" & Err.Number & _
       Err.Description, vbCritical, "Error Handler: Error " & Err.Number

End Sub
相关问题