1) открытый класс ViewIdentification расширяет Activity, реализует OnFocusChangeListener {
EditText _edt1;
EditText _edt2;
EditText _edt3;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
_edt1 = (EditText)findViewById(R.id.EditText01);
_edt1.setOnFocusChangeListener(ViewIdentification.this);
_edt2 = (EditText)findViewById(R.id.EditText02);
_edt2.setOnFocusChangeListener(ViewIdentification.this);
_edt3 = (EditText)findViewById(R.id.EditText03);
_edt3.setOnFocusChangeListener(ViewIdentification.this);
}
@Override
public void onFocusChange(View v, boolean hasFocus) {
// TODO Auto-generated method stub
if(v == _edt1 && hasFocus == true){
Toast.makeText(ViewIdentification.this, "The First EditText is focused now", Toast.LENGTH_LONG).show();
}else if(v == _edt2 && hasFocus == true){
Toast.makeText(ViewIdentification.this, "The Second EditText is focused now", Toast.LENGTH_LONG).show();
}else if(v == _edt3 && hasFocus == true){
Toast.makeText(ViewIdentification.this, "The Third EditText is focused now", Toast.LENGTH_LONG).show();
}
}
}
ПРИМЕЧАНИЕ. Таким образом мы можем узнать, какой вид сфокусирован.
2)
Это можно сделать, рассчитав размер действия (местоположение, в котором находится последнее сфокусированное представление).