我想当用户在 EditText
上书写时显示图像,
这里触摸 EditText
时有相同的输出:
menuH.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
menuH2.setVisibility(VISIBLE);
return true;
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
menuH2.setVisibility(View.INVISIBLE);
Intent intent = new Intent(getApplicationContext(), Index.class);
startActivity(intent);
}
return true;
}
});
所以,我需要执行相同输出的函数,但是当用户在 EditText
上书写时,感谢高级:)
说明:
看图:
当用户在编辑文本上书写时,我想显示图像,如果我们假设(缩写和确定)是图像,那么我想在书写时显示它们,但是当用户停止在 EditText 上书写时
并切换到另一个编辑文本图像消失
最佳答案
尝试 TextChangedListener,例如:
menuH.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Show your image
}
});
关于java - 如何在文字上书写时显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28875518/