android - The method findViewByID(int) is undefined for the type new View.OnClickListener(){} -


i getting above error in following code in button , edittext. don't know why coming. if guys can understand , tell me went wrong here, great.

import android.app.activity; import android.content.intent; import android.net.uri; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.edittext;  public class activity2 extends activity {      public void oncreate(bundle savedinstancestate)     {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity2);          button btn = (button) findviewbyid(r.id.btn_ok);         btn.setonclicklistener(new view.onclicklistener() {              @override             public void onclick(view v) {                 intent data = new intent();                  edittext txt_username = (edittext) findviewbyid(r.id.txt_username);                 data.setdata(uri.parse(txt_username.gettext().tostring()));                 setresult(result_ok, data);                 finish();             }         });      }  } 

i have tried see in link the method setonclicklistener(new view.onclicklistener(){}) undefined type imagebutton1 not usable me.

you have typo:

is edittext txt_username = (edittext) findviewbyid(r.id.txt_username);

not edittext txt_username = (edittext) findviewbyid(r.id.txt_username);

the last letter, d, lowercase


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -