【问题标题】:W/PathParser: Points are too far apart Navigation DrawerW/PathParser:点距导航抽屉太远
【发布时间】:2016-06-09 10:32:23
【问题描述】:

您好,当我尝试将 Navigation Drawer 移动到其中一个片段时,它会跳转到主要活动 XML 而不是片段,我尝试检查我的导入类是否相同,我使用了 android 库并支持图书馆,它没有帮助。

这是我的代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}

@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        super.onBackPressed();
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        return true;
    }

    return super.onOptionsItemSelected(item);
}

@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    FragmentManager fragmentManager = getFragmentManager();



    if (id == R.id.nav_first_layout) {
        fragmentManager.beginTransaction().replace(R.id.content_frame,new FirstFragment());
    }


    else if (id == R.id.nav_second_layout) {
        fragmentManager.beginTransaction().replace(R.id.content_frame,new SecondFragment());


    } else if (id == R.id.nav_third_layout) {
        fragmentManager.beginTransaction().replace(R.id.content_frame,new ThirdFragment() );
    }
    else if (id == R.id.nav_share) {

    } else if (id == R.id.nav_send) {

    }

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

当我尝试按下其中一项时,我收到了下一条消息: W/PathParser:点相距太远 4.000000596046461 有什么建议吗?

【问题讨论】:

  • 对我来说,如果我保留模板的图标,则显示错误,一旦更改就会消失

标签: java android android-fragments android-studio navigation-drawer


【解决方案1】:

我发现我的问题是缺少命令, 需要替换这段代码:

 if (id == R.id.nav_first_layout) {
    fragmentManager.beginTransaction().replace(R.id.content_frame,new FirstFragment());
}

使用此代码:

if (id == R.id.nav_first_layout) {
        fragmentManager.beginTransaction().replace(R.id.content_frame,new FirstFragment()).commit();
    }

我错过了 .commit 命令。

【讨论】:

  • 好吧,很高兴你解决了这个问题,但W/PathParser: Points are too far apart 4.000000596046461 与片段事务无关。这是与 svg/vectors 相关的警告。
  • 如此巧合,我们中的许多人遇到了同样的问题并且看到了同样不相关的警告 W/PathParser: 的事情。
  • 我没有找到任何解决方案,在 log cat 中折叠这样的行是否安全,或者我们需要找到任何解决方案??
  • @AalapPatel 嗨,请阅读 Omkar 评论,我可以说我的应用程序运行完美,尽管这些警告出现了
  • 我知道的老问题,但为了后代的缘故....当从导航抽屉访问的片段之一的 mobile_navigation.xml 中的 id 错误时,我收到此错误。我想知道在执行上述操作时您是否在没有意识到的情况下更正了此文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-14
  • 1970-01-01
  • 2013-07-04
  • 2021-01-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多