2017-08-04 59 views
-1

我是新手...我在我的应用程序中添加了浮动按钮,并在第一项中添加了一个点击活动,但是当我点击第一项应用程序时,不幸停止帮助我。 ..当我点击第一项时,浮动按钮活动未打开

MainActivity.java

public class MainActivity extends AppCompatActivity 
     implements NavigationView.OnNavigationItemSelectedListener { 

    FloatingActionMenu materialDesignFAM; 
    FloatingActionButton floatingActionButton1, floatingActionButton2, floatingActionButton3; 


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

     materialDesignFAM = (FloatingActionMenu) findViewById(R.id.material_design_android_floating_action_menu); 
     floatingActionButton1 = (FloatingActionButton) findViewById(R.id.material_design_floating_action_menu_item1); 
     floatingActionButton2 = (FloatingActionButton) findViewById(R.id.material_design_floating_action_menu_item2); 
     floatingActionButton3 = (FloatingActionButton) findViewById(R.id.material_design_floating_action_menu_item3); 
     floatingActionButton1.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
       // first item 
       Intent intent = new Intent(MainActivity.this, Menu2.class); 
       startActivity(intent); 
      } 
     }); 
     floatingActionButton2.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 

      } 
     }); 
     floatingActionButton3.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 

      } 
     }); 


     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); 

     //add this line to display menu1 when the activity is loaded 
     displaySelectedScreen(R.id.nav_menu1); 
    } 

see in screenshot

+1

添加堆栈跟踪 – Zoe

+1

你可以添加异常和XML文件? –

回答

-1

不要忘了你的活动添加到AndroidManifest.xml文件

+0

如何PLZ告诉我我很新 – Vicky

+0

看看这一个:https://developer.android.com/guide/topics/manifest/manifest-intro.html –

+0

活动加入,但现在工作.. – Vicky

相关问题