1. Introducing Channels - a new way to chat with other Android users!
    Dismiss Notice

R.id cannot be resolved


Last Updated:

  1. goutham_9

    goutham_9 New Member This Topic's Starter

    Joined:
    Oct 6, 2010
    Messages:
    2
    Likes Received:
    0
    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.....:)
     

    Advertisement

Share This Page

Loading...