Question: the R . id . action _ home always have errors although i import the R; please give the soultion with R . id .

the R.id.action_home always have errors although i import the R; please give the soultion with R.id..... statments;
package com.example.dropdown;
import static com.example.dropdown.R.*;
import com.example.dropdown.R;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.PopupMenu;
private boolean onMenuItemClick(MenuItem menuItem){
switch (menuItem.getItemId()){
case R.id.action_home:
Toast.makeText(this, "Home clicked", Toast.LENGTH_SHORT).show();
break;
case R.id.action_light_mode:
Toast.makeText(this, "Light Mode activated", Toast.LENGTH_SHORT).show();
setLightMode();
break;
case R.id.action_dark_mode:
Toast.makeText(this, "Dark Mode activated", Toast.LENGTH_SHORT).show();
setDarkMode();
break;
default:
return false;
}
return true;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!