使用 Runnable()平滑打开和关闭导航抽屉,但在选择抽屉项目时无法显示片段。
$string="<header>";
$imagesrc="";
While($row=$stmt->fetch()){
$string+=$row['Title'];
$imagesrc=$row['Image'];
}
$string+="</header>";
$stringImage="<img src='".$imagesrc."' />";
答案 0 :(得分:0)
仅在runOnUiThread
执行您的操作,而不是在Runnable
中调用runOnUiThread。您的代码应如下所示:
public void onNavigationDrawerItemSelected(final int position,View view) {
runOnUiThread(new Runnable() {
@Override
public void run() {
FragmentManager fragmentManager = getSupportFragmentManager();
switch (position) {
case 0:
fragmentManager.beginTransaction().replace(R.id.container, new HomeFragment()).commit();
break;
case 1:
fragmentManager.beginTransaction().replace(R.id.container, new HomeFragment()).commit();
break;
case 2:
fragmentManager.beginTransaction().replace(R.id.container, new HomeFragment()).commit();
// Intent i = new Intent(con, SplashScreenActivity.class);
// startActivity(i);
// finish();
break;
}
}
});
if (mDrawerLayout != null) {
mDrawerLayout.closeDrawer(view);
supportInvalidateOptionsMenu();
}