How can I add a placeholder text to EditText
in the class that isn t in the XML?
我的守则有以下<代码>EditText,将在警示中显示:
final EditText name = new EditText(this);
How can I add a placeholder text to EditText
in the class that isn t in the XML?
我的守则有以下<代码>EditText,将在警示中显示:
final EditText name = new EditText(this);
Ah, ok。 您回顾的是:setHint(int)
。 简单地从你的xml中抽取资源,然后回去。
在XML中,它只是android:hint=“someText”
。
editText
。
例如: i 具有两个数字数值,另一个是显示价值。 我们可以为用户打上灯,以便他能够理解他需要给予什么价值。
android:hint="Please enter phone number"
android:hint="Enter name"
这两条ed字之后,在点击 text后,将显示所进入的 h,用户可以进入他想要的东西(见奢侈品图像)。
You have to use the android:hint attribute
<EditText
android:id="@+id/message"
android:hint="<<Your placeholder>>"
/>
In Android Studio, you can switch from XML -> Design View and click on the Component in the layout, the EditText field in this case. This will show all the applicable attributes for that GUI component. This will be handy when you don t know about all the attributes that are there.
你们会感到惊讶的是,EditText有140多个定制特性。
如何提出附带内容的字句,不要改写!
关于XML:
android:inputType="textPassword"
android:gravity="center"
android:ellipsize="start"
android:hint="Input Password !."
亲眼见:D.
In Android Studio you can add Hint (Place holder) through GUI. First select EditText field on designer view. Then Click on Component Tree Left side of IDE (Normally it s there, but it may be there minimized) There you can see Properties of selected EditText. Find Hint field as below Image
您可向EditText增加Hint(Place持有人)
If you mean the location where you will add it in the layout. You can define a container like a FrameLayout and add this EditText to it when it is created.
<LinearLayout xmlns=".."/>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
FrameLayout layout = (FrameLayout) findViewById(R.id.container);
layout.addView(name);
If you want to insert text inside your EditText view that stays there after the field is selected (unlike how hint behaves), do this:
Java:
// Cast Your EditText as a TextView
((TextView) findViewById(R.id.email)).setText("your Text")
在科特林:
// Cast your EditText into a TextView
// Like this
(findViewById(R.id.email) as TextView).text = "Your Text"
// Or simply like this
findViewById<TextView>(R.id.email).text = "Your Text"
I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...
I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...
I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...
I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...
To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?
When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...
I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...
I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...