2013-03-18 17 views

risposta

1

Penso che OnFocusChangeListener potrebbe essere la cosa giusta per voi.

editText.setOnFocusChangeListener(new OnFocusChangeListener() { 

    @Override 
    public void onFocusChange(View v, boolean hasFocus) { 
     // view/hide ImageView 
    } 
}); 
+3

funziona benissimo. Ma ho affrontato un altro problema. Premendo il tasto Indietro, per nascondere la tastiera, 'EditText' non perde la messa a fuoco, quindi ImageViw è ancora Hiden. C'è un ascoltatore per il rifiuto della tastiera? – Procurares

+0

@Procurares Sono contento che ti piaccia! Si prega di votare/accettare la risposta, se ti ha aiutato. Sì, è possibile. Leggi su questo link per scoprire come: http://stackoverflow.com/questions/4312319/howto-capture-the-virtual-keyboard-show-hide-event-in-android – poitroae

1
edit_Text.setOnFocusChangeListener(new OnFocusChangeListener() { 
@Override 
public void onFocusChange(View v, boolean hasFocus) { 
    if(hasFocus){ 
     Toast.makeText(getApplicationContext(), "got the focus", Toast.LENGTH_LONG).show(); 
      // Hide your ImageView 
       iv.setVisibility(View.GONE); // (make the view gone) 
    }else 
     Toast.makeText(getApplicationContext(), "lost the focus", Toast.LENGTH_LONG).show(); 
      // Show your ImageView 
       iv.setVisibility(View.VISIBLE); 
    } 
}); 
Problemi correlati