Android ANR keyDispatchingTimedOut Error while continuous tapping on screen
1480 ワード
UIスレッド、メインスレッドブロック.新たにスレッドを開始し、Handlerによって実行する.
REFRENCES: http://stackoverflow.com/questions/4529770/android-anr-keydispatchingtimedout-error-while-continuous-tapping-on-screen
http://developer.android.com/resources/articles/painless-threading.html
@Override
public void onScroll(AbsListView view, final int firstVisibleItem,
final int visibleItemCount, final int totalItemCount) {
Thread songsList = new Thread(){
@Override
public void run(){
firstItem = firstVisibleItem;
visibleCout = visibleItemCount;
totalCount = totalItemCount;
Message message = new Message();
message.what = 2;
handler.sendMessage(message);
}
};
songsList.start();
}
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 2:
if ((firstItem + visibleCout == totalCount)
&& (totalCount != 0)) {
if (refreshAble) {
refreshAble = false;
loading.setVisibility(View.VISIBLE);
/**
*
*/
getData(++pageNo);
}
}
break;
default:
break;
}
}
};
REFRENCES: http://stackoverflow.com/questions/4529770/android-anr-keydispatchingtimedout-error-while-continuous-tapping-on-screen
http://developer.android.com/resources/articles/painless-threading.html