• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

R.id cannot be resolved

goutham_9

Lurker
Hello frnds m goutham m very new to android development can anyone plz help me....
m trying to create a menu the menu is running perfectly but when i add a extra code to raise a event then it is giving a error saying R.id.simple_text_box cannot be resolved.

This is my Menu.java

package com.android;

import android.app.Activity;
import android.os.Bundle;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;
import android.R.*;
import com.TestApp.R;


public class Menu extends Activity {
/** Called when the activity is first created. */

public boolean onCreateOptionsMenu(android.view.Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.firstmenu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.first_menu_item:
TextView tv = (TextView) findViewById(R.id.simple_text_box);
tv.setText("You pressed " + item.getTitle() + "!");
break;
default:

break;
}

return true;

}
}

This is my firstmenu.xml

<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/first_menu_item"
android:title="First Menu Item">
</item>
</menu>

Thank u.....:)
 
Back
Top Bottom