Field in can not be resolved problem

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 1

Jul 12, 2013 9:24:15 PM via Website

Hi guys, im a beginner to android development. I was developing a SilentModeToggle app which requires a button to toggle the silent mode to loud and viceversa.
The problem is even after i write xml code for button, it does not make corresponding id in class with "build automatically" is checked in project menu. It is not there in R file when check it in package explorer. And it shows an error when i use this button id that " Button_name can not be resolved or not a field"
My code for button is shown below

XML code----
android:text="Toggle Silent Mode" />

Java button setting function---
private void setButtonClickListener() {
Button toggleButton = (Button) findViewById(;
toggleButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click


The bolded line shows error that "toggleButton can not be resolved or not in field"

please help

— modified on Jul 17, 2013 2:55:48 PM