英文:
Android : How to track Keyboard usage
问题
有没有办法追踪用户在软键盘上的输入速度?我想知道用户使用键盘的时间。希望我的问题清楚明了!
英文:
Is there a way to track how "fast" a user is on the soft keyboard? I want to konw the time the user takes when using the keyboard.
I hope my question is clear!
答案1
得分: 0
你可以在EditText中使用文本监听器(Text Watcher),在每次文本更改时计算时间差。
long initialTime = System.currentTimeMillis();
long total = 0;
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int start, int before, int count) {
total = total + (System.currentTimeMillis() - initialTime);
initialTime = System.currentTimeMillis();
}
@Override
public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable editable) {
}
});
英文:
You could use a text watcher in the EditText and on every text change you can calculate the difference in time.
long intialTime=System.getCurrentTimeMillis();
long total = 0;
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
total= total + (System.getCurrentTimeMillis()-initialTime)
intialTime = System.getCurrentTimeMillis();
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3)
{
}
@Override
public void afterTextChanged(Editable arg0) {
}
});
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论