0
我想每10秒刷新一次適配器。我正在加載我的ListView
Adapter
裏面Handler
,所以我該怎麼辦?我如何使用Timer
?我希望當價值發生變化時,Adapter
會自動刷新ListView
。如何在Handler中使用Timer?
@SuppressLint("HandlerLeak")
Handler handle = new Handler() {
public void handleMessage(android.os.Message msg) {
super.handleMessage(msg);
CommonObjects.hideProgress();
if (msg.what == 1) {
plotadapter = new PlotsAdapter(Plots.this, arrayplot);
plotslist.setAdapter(plotadapter);
}
if (msg.what == 2) {
Toast.makeText(Plots.this, "Server, Not Available!",
Toast.LENGTH_SHORT).show();
finish();
}
}
};
@Override
protected void onRestart() {
if(CommonObjects.getLogoutreject().equals("1") && CommonObjects.logout){
// CommonObjects.logout=false;
finish();
}
super.onRestart();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.plots);
plotslist = (ListView) findViewById(R.id.plotslist);
back = (ImageView) findViewById(R.id.plotback);
bottomlayout = (RelativeLayout) findViewById(R.id.bottom_layout);
scroll_down = (ImageView) findViewById(R.id.down);
scroll_up = (ImageView) findViewById(R.id.up);
IM USINF此檢查如果(msg.what == 1){HOW我WRITE INSIDE本聲明??? – user3332060
檢查我編輯的答案 –
現在檢查我的代碼,告訴我如何根據我的代碼調整我的代碼?你使用final來聲明處理器 final Handler handler = new Handler(); – user3332060