我在Android 3+,我想提示添加到我的编辑文本部件。我尝试添加了提示布局如下...
I am on Android 3+ and I am trying to add hints to my edit text widgets. I tried adding the hint to the layout as follows...
<EditText
android:id="@+id/bar_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:hint="@string/bar_name_hint"
android:imeOptions="actionNext"
/>
但是,当我专注于文本框中写入了提示,而不是暗示消失。
But when I focus on the Text box it writes over the hint instead of the hint disappearing.
我发现添加的onfocus监听器的EditText文件,但我想避免编程这样做。该职位也低于使用选择提及,但我无法找到如何做到这一点的文档。
I found documentation on adding a onFocus listener to the EditText, but I would like to avoid doing this programatically. The post below also mentioned using selectors but I can't find documentation on how to do that.
的Android的EditText提示
那么,什么是处理这个的最佳方式?
So what is the best way to handle this?
由于某些原因,我有活动和碎片布局设置两次。在活动的onCreate:
For some reason, I had the activity and fragment layout set twice. On Activity onCreate:
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.edit_consumption);
和片段onCreateView:
and on the fragment onCreateView:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.edit_consumption, null);
所以我不得不2层的布局。我只需要在活动的onCreate删除布局来解决这个问题。也许你有同样的问题。
So I had 2 layers of layout. I only had to remove that layout from the Activity onCreate to fix the problem. Maybe you have the same problem.
上一篇:如何提取下列URL中的Android的HTTPPost下列、URL、Andr、oid
下一篇:如何使用TreeViewDrawMode.OwnerDrawAll改变选定节点的背景颜色的TreeView?节点、如何使用、颜色、背景