之間的切換,當我在導航抽屜片段之間切換,導航抽屜慢慢關閉,我假定它等待更換新選擇的片段並關閉抽屜,機器人導航抽屜,片段
我如何加快速度?在的Gmail應用程序,當你選擇在導航抽屜選項卡,新片段不會立即創建,而是顯示了一個進度,那麼內容的負載,而且導航抽屜收盤正在加快在這裏。
我該怎麼做,任何代碼示例表示讚賞。
編輯
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
.....
navigationDrawerTitles = getResources().getStringArray(R.array.navigation_drawer_titles);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerList.setAdapter(new ArrayAdapter<String>(this,
R.layout.drawer_list_item, navigationDrawerTitles));
mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
.......
}
private class DrawerItemClickListener implements
ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
selectItem(position);
}
}
private void selectItem(int position) {
switch(position){
case 0:
getFragmentManager().beginTransaction()
.replace(R.id.content_frame, new HomeFragment(), "HomeFragment").commit();
mDrawerList.setItemChecked(position, true);
setTitle(navigationDrawerTitles[position]);
break;
case 1:
getFragmentManager().beginTransaction()
.replace(R.id.content_frame, new HistoryFragment(), "HistoryFragment").commit();
mDrawerList.setItemChecked(position, true);
setTitle(navigationDrawerTitles[position]);
break;
case 2:
Intent sintent = new Intent(MainActivity.this,
SettingsActivity.class);
startActivity(sintent);
break;
default:
break;
}
mDrawerLayout.closeDrawer(mDrawerList);
}
感謝,
顯示你的代碼... – Riser 2014-10-18 05:40:08
發佈您的代碼第一 – 2014-10-18 05:45:01
如果你這樣做,然後在片段的任何繁重的工作也開始發生了.. – Riser 2014-10-18 06:11:46