我有以下XML:显示我EDITTEXT搜索视图光标
<LinearLayout
android:id="@+id/searchBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/theTitleBar"
android:orientation="horizontal" >
<EditText
android:id="@+id/searchBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:layout_marginLeft="7dp"
android:layout_marginRight="1dp"
android:layout_marginTop="8dp"
android:layout_weight="1"
android:background="@drawable/text_area_search"
android:imeOptions="actionSearch"
android:textSize="14dp" >
<requestFocus />
</EditText>
<ImageButton
android:id="@+id/speechRecognition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="7dp"
android:layout_weight="0"
android:background="@drawable/recording_bt_crop_idle"
android:onClick="speechRecognitionClicked"
android:visibility="visible" />
</LinearLayout>
软键盘打开的那一刻活动上。
我该如何强制文本光标出现并闪烁?
时下即使在用户点击这个editText后它也不会出现。
我已经加入<requestFocus />
,但它并没有帮助
这是我的代码:
@Override
public void onResume() {
super.onResume();
if (type==AddressItem.FAVORITE_ITEM_EMPTY) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
searchBox.requestFocus();
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(searchBox, InputMethodManager.SHOW_FORCED);
}
}, 100);
}
}
尝试'android:textCursorDrawable =“@ null”' – InnocentKiller
你试过这个以编程方式吗?我有这样的成功:'EditText输入= FindViewById(Resource.Id.searchBox); input.RequestFocus();' –
Byron
尝试过,但没有工作 –