Можно ли вызвать функцию Activity из ящика?
Позвольте сказать: Основная деятельность открыта. В нем есть функция displayImage (). Я хочу позвонить из ящика.
**Please go through the bellow code snippet** drawer.xml file <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" tools:showIn="navigation_view"> <group android:checkableBehavior="single"> <item android:id="@+id/u_name" android:icon="@drawable/lead_leader" android:title="User name" /> <item android:id="@+id/logout" android:icon="@drawable/logout" android:title="Logout" /> </group> </menu> **after that add bellow code in your Mainactivity.java file** @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.lead_profile, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.logout) { //call your other method according navigation drawer item with other id in a different if block. ///call your function here } return super.onOptionsItemSelected(item); }