Android add placeholder text to EditText

后端 未结 8 840
感动是毒
感动是毒 2020-12-02 04:34

How can I add a placeholder text to EditText in the class that isn\'t in the XML?

I have the following EditText in my code which will be sh

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 05:01

    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.

    
        
    
    
    FrameLayout layout = (FrameLayout) findViewById(R.id.container);
    layout.addView(name);
    

提交回复
热议问题