java - Cannot find id with R.id -


this activity_main.xml:

<?xml version="1.0" encoding="utf-8"?> <linearlayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical">   <textview     android:id="@+id/mytext"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:text="new text" />  </linearlayout> 

textview has in id of mytext , java file trying access view:

protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     view mytextview = (textview)findviewbyid(r.id.mytext);  // here     mytextview.settext("new text in text view"); } 

but mytext has red color font meaning not resolved.

why so? how can fix it?

update:

my imports:

package ru.startandroid.androidlessons;  import android.app.activity; import android.os.bundle; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.textview; 

i following tutorial , created lots of modules in 1 project. so, got confused , created layouts in 1 module , tried access module's java file. so, using right java file did it

but still unable import r.java of module. possible? or restricted?

module name: p0061_layouts, package name: ru.startandroid.layouts

if setcontentview(r.layout.activity_main) worked? may have mistake first of use textview instead of view

if still have same error manually clean project try if using eclipse in menu bar project-> cleanproject , check automatically build


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -