开发者

Weird bug: EditText launches Google Search

开发者 https://www.devze.com 2023-03-03 08:55 出处:网络
I\'m doing a very simple test app that uses the text to speech engine and to \"say\" the text that you put in an EditText. It has an EditText and a Button. Howe开发者_开发百科ver when I try to enter t

I'm doing a very simple test app that uses the text to speech engine and to "say" the text that you put in an EditText. It has an EditText and a Button. Howe开发者_开发百科ver when I try to enter text into the EditText it launches Google Search as soon as I type a letter. ¿Does anyone know how to fix this?

Update: When using a physical keyboard it works just fine so I guess it's a problem with the soft keyboard...

XML Code:

<EditText android:id="@+id/etText" android:layout_width="fill_parent"
 android:layout_height="fill_parent" android:gravity="top"
 android:layout_marginTop="5dip" android:layout_marginLeft="2dip"
 android:layout_marginRight="2dip" android:inputType="text">
</EditText>


Settingandroid:inputType="text" in the layout xml for the EditText and in the Activity calling editTextFieid.requestFocus() solved the problem for me. This problem only occurs for the first EditText in an Activity. It was the username EditText in my case.


I ran into this same issue when I had an unused OnClickListener.

In refactoring code, I found that I had left an empty onClickListener and onClick method. Removing the implements OnClickListener and method containing public void onClick(View view) items, and I never got the search box to appear on my editText click-events anymore. It seems odd, but it worked for me!

Also, I removed the following line:

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
0

精彩评论

暂无评论...
验证码 换一张
取 消