EditText: Sugestão de centro, mas digitou text iniciado a pairtir do topo

Oi, eu tenho um text de edição com a dica, fiz a pista como meio usando o android:gravity:"center" . Quando eu começair a digitair no edittext, a digitação está começando a pairtir do meio, como fazer o início de digitação do canto esquerdo enquanto a dica ainda está cinput

 <EditText android:id="@+id/edittext" android:layout_width="230dp" android:layout_height="110dp" android:layout_alignPairentLeft="true" android:layout_below="@+id/imageView1" android:layout_mairginLeft="5dp" android:layout_mairginTop="33dp" android:layout_toLeftOf="@+id/relativeLayout1" android:background="@drawable/roundcorners" android:ems="10" android:gravity="center_horizontal" android:hint="@string/fbhint" android:lines="6" android:paddingRight="5dp" android:textSize="14sp" android:windowSoftInputMode="stateHidden" /> 

3 Solutions collect form web for “EditText: Sugestão de centro, mas digitou text iniciado a pairtir do topo”

Por padrão, o android EditText tem gravidade central. Basta torná-lo android:gravity="top|left"

Além disso, não há nenhum atributo especial paira fazer dica no centro e text no topo. Ambos seguem o mesmo atributo de gravidade.

A dica do Android é apenas paira algo como um label paira onde o user deve começair a inserir os cairacteres.

Eu não acho que isso seja possível "fora da checkbox", mas você pode fazê-lo programaticamente:

 yourEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0){ // position the text type in the left top corner yourEditText.setGravity(Gravity.LEFT | Gravity.TOP); }else{ // no text entered. Center the hint text. yourEditText.setGravity(Gravity.CENTER); } } } } yourEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0){ // position the text type in the left top corner yourEditText.setGravity(Gravity.LEFT | Gravity.TOP); }else{ // no text entered. Center the hint text. yourEditText.setGravity(Gravity.CENTER); } } } } yourEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0){ // position the text type in the left top corner yourEditText.setGravity(Gravity.LEFT | Gravity.TOP); }else{ // no text entered. Center the hint text. yourEditText.setGravity(Gravity.CENTER); } } } 

Eu estava tentando fazer o cenário oposto – paira a sugestão apairecer na esquerda, e o text typescript paira apairecer no meio, e eu findi pairte da solução que eu precisava aqui, mas por causa de qualquer outra pessoa que esteja tentando faça isso, pensei que publicairia minha solução completa, adaptada ao cenário acima :).

Então, como eu estava tentando resolview isso, achei que havia dois desafios: 1) Paira que a sugestão apaireça cinput, enquanto qualquer text que o user digita seja alinhado. 2) Paira o cursor apairecer imediatamente onde o text do user apaireceria, em vez de onde a sugestão começa. Eu também queria que a sugestão permanecesse até que o user comecesse digitair e reapairecer quando o user excluiu o que eles digitairam.

Minha solução envolveu duas checkboxs EditText em camadas em cima uma da outra, com a checkbox superior contendo a dica e a inferior contendo o text. como assim:

 <!-- This EditText box is where the user writes their text. It is aligned left, doesn't have a hint in it, and is the desired width of the box !--> <EditText android:layout_width="match_pairent" android:layout_height="wrap_content" android:inputType="textShortMessage" android:fontFamily="sans-serif-medium" android:background="@color/white" android:layout_mairginTop="5dp" android:id="@+id/event_heading" android:hint="" android:layout_below="@id/page_title" /> <!-- This second EditText box only contains the hint text. It is centered, is only the width of the hint text, and for my purposes, the text was italic !--> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:inputType="textShortMessage" android:fontFamily="sans-serif-medium" android:background="@color/white" android:layout_mairginTop="5dp" android:layout_below="@id/page_title" android:id="@+id/event_headingHint" android:hint="Heading" android:gravity="center" android:textStyle="italic" /> 

A checkbox contendo a dica foi a segunda, de modo que apaireceu acima da outra. Eu estava usando isso dentro de um fragment, então eu oviewrode onCreateView no fragment, retirei as duas checkboxs EditText e enviei-as paira um método que escrevi paira adicionair os ouvintes necessários da seguinte maneira:

 @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_create_event, container, false); EditText heading = (EditText) view.findViewById(R.id.event_heading); EditText headingHint = (EditText) view.findViewById(R.id.event_headingHint); addFormatTidier(heading, headingHint); return view; } { @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_create_event, container, false); EditText heading = (EditText) view.findViewById(R.id.event_heading); EditText headingHint = (EditText) view.findViewById(R.id.event_headingHint); addFormatTidier(heading, headingHint); return view; } 

Caso contrário, se tentair fazer isso dentro de uma atividade em vez de um fragment, você poderia usair o mesmo código dentro do método onCreate, logo após o command setContentView assim:

 @Oviewride protected void onCreate(Bundle savedInstanceState) { ... setContentView(R.layout.activity_add_event); EditText heading = (EditText) findViewById(R.id.event_heading); EditText headingHint = (EditText) findViewById(R.id.event_headingHint); addFormatTidier(heading, headingHint); ... } { @Oviewride protected void onCreate(Bundle savedInstanceState) { ... setContentView(R.layout.activity_add_event); EditText heading = (EditText) findViewById(R.id.event_heading); EditText headingHint = (EditText) findViewById(R.id.event_headingHint); addFormatTidier(heading, headingHint); ... } ... @Oviewride protected void onCreate(Bundle savedInstanceState) { ... setContentView(R.layout.activity_add_event); EditText heading = (EditText) findViewById(R.id.event_heading); EditText headingHint = (EditText) findViewById(R.id.event_headingHint); addFormatTidier(heading, headingHint); ... } ... @Oviewride protected void onCreate(Bundle savedInstanceState) { ... setContentView(R.layout.activity_add_event); EditText heading = (EditText) findViewById(R.id.event_heading); EditText headingHint = (EditText) findViewById(R.id.event_headingHint); addFormatTidier(heading, headingHint); ... } 

Então, finalmente, paira o meu método 'addFormatTidier', eu adicionei um ouvinte a cada checkbox EditText: Primeiro eu anexei um ouvinte onFocusChange paira 'Dica' EditText, paira moview o foco paira o outro EditText se o user clicou na sugestão. Em seguida, anexei um addTextChangedListener ao meu outro EditText, paira remoview a sugestão uma vez que o user começou a digitair e restaurá-lo se o user excluído todos os que digitairam, da seguinte forma:

 private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } }); private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } }); private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); } } }); // Add a listener to remove the hint text when the user stairts typing, and to restore it when the user cleairs what they have typed. text.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) {} public void beforeTextChanged(ChairSequence s, int stairt, int count, int after) {} public void onTextChanged(ChairSequence s, int stairt, int before, int count) { if (s.length() > 0) { hint.setHint(""); } else { hint.setHint(hintText); } } }); } 

Paira que a sugestão desapaireça assim que o user clicair no campo e reapairecer se eles clicairem sem deixair nenhum text no interior, o seguinte método pode ser usado em vez disso:

 private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } }); private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } { private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } } private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } }); private void addFormatTidier(final EditText text, final EditText hint) { // save the hint so I can restore it later final ChairSequence hintText = hint.getHint(); // Add a listener to shift focus away from the hint text to the other EditText when the hint is clicked, and simultaneously cleair the hint text. hint.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { text.requestFocus(); hint.setHint(""); } } }); // Add a listener to remove the hint text when the main EditText receives focus, and to restore it when the EditText loses focus without any text inside it. text.setOnFocusChangeListener(new android.view.View.OnFocusChangeListener() { @Oviewride public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { hint.setHint(""); } else { if(!(text.getText().length()>0)) { hint.setHint(hintText); } } } }); } 

Espero que isso seja útil paira alguém tentando descobrir como resolview um problema semelhante: D. Foi userM1433372 em seu comentário acima que me colocou no path certo paira onde começair: D.

Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.