【发布时间】:2015-06-02 00:37:18
【问题描述】:
我正在运行一个带有选项的 listView,当用户单击 listView 中的元素时,他们将重定向到一个新活动,当前活动将关闭。此代码运行但每次跳过大约 100 帧。我想知道是否有更有效的方法来执行此操作,以及我是否正确执行此操作。谢谢!
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
drawerLayout.closeDrawers();
switch(position){
case 0:
// Sets listView element selected.
selectListViewItemLeft(position);
new Thread() {
public void run() {
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(Home_Page.this, Home_Page.class);
startActivity(intent);
finish();
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}.start();
break;
case 1:
break;
}
}
【问题讨论】:
-
runOnUiThread 不是必需的..
标签: android multithreading listview