JOFIN JOHNSON
- Forum posts: 1
Jul 12, 2013, 9:24:15 PM via Website
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 R.java 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----
<Button
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Toggle Silent Mode" />
Java button setting function---
private void setButtonClickListener() {
Button toggleButton = (Button) findViewById(R.id.toggleButton);
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
The problem is even after i write xml code for button, it does not make corresponding id in R.java 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----
<Button
android:id="@+id/toggleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Toggle Silent Mode" />
Java button setting function---
private void setButtonClickListener() {
Button toggleButton = (Button) findViewById(R.id.toggleButton);
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
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.