Finora non ho trovato alcun listener per la tastiera virtuale in Android. Ho trovato una soluzione alternativa, cioè ho utilizzato l'evento TextChanged per recuperare il valore delle chiavi immesse in Modifica testo.
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class ShowKeypad extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
EditText emailTxt = (EditText) findViewById(R.id.editText);
emailTxt.addTextChangedListener(new TextWatcher()
{
public void afterTextChanged (Editable s){
Log.d("seachScreen", "afterTextChanged");
}
public void beforeTextChanged (CharSequence s, int start, int
count, int after)
{
Log.d("seachScreen", "beforeTextChanged");
}
public void onTextChanged (CharSequence s, int start, int before,
int count)
{
Log.d("seachScreen", s.toString());
}
final TextView tv = (TextView)findViewById(R.id.tv);
});
}
}
fonte
2010-04-28 07:43:15
Non pensi che sarebbe una migliore idea di condividere il modo migliore che hai trovato, voglio dire che vengo qui per chiedere aiuto, elaborare la risposta alla vostra auto e allora non rinunciare alla risposta, più dare e meno prendi in considerazione;) – Spider