Reputation: 107
Maybe my Googling skills aren't the greatest, but whenever I Google this problem, I only find solutions to when the whole R file isn't generated which isn't my problem. Everything else is generating just fine, however, there is no ID within R, so I have no way of referencing the views in my XML. I've already tried project->clean, and restarting the adb server and eclipse, neither to any avail. All help is greatly appreciated. Below is my code.
public class MainMenu extends Activity {
/*
* Class member variables
*/
private Button mMicrophoneButton;
private ListView mMessageList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_menu_layout);
setWidgets();
}
private void setWidgets() {
this.mMicrophoneButton = (Button) findViewById(R.id.bMicrophone);
}
}
Below is my XML, there's a lot of new stuff here that I don't recognize from previous projects I've done. But I'm not finding any mistakes, which I know is usually the first cause of problems like this.:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainMenu"
tools:ignore="HardcodedText" >
<ScrollView
android:id="@+id/svMessageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="9" >
<TextView
android:id="@+id/tvTest"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="test" />
</ScrollView>
<Button
android:id="@+id/bMicrophone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:minHeight="30dp"
android:text="Speak Now" />
</LinearLayout>
Upvotes: 0
Views: 5872
Reputation: 3
I have Got the Same error but I got it solved by cleaning and rebuilding the project.
Actually, we can add Id there manually as well. I have done that couple of times.
But you can solve it by following the steps below
It will work definitely.
Upvotes: 0
Reputation: 115
you need to save the xml file before cleaning the project for the ids to show up in R.java
Upvotes: 0
Reputation: 2532
Upvotes: 4