Hi, Unsubscribe me from the group please! Thanks a lot! Best wishes, Edward
-----邮件原件----- 发件人: [email protected] [mailto:[EMAIL PROTECTED] 代表 Tauno T 发送时间: 2008年10月20日 4:03 收件人: Android Beginners 主题: [android-beginners] Re: findViewById returns null for package private classes Strange - I made a new empty project with the code that you provided and everything works (findViewById(R.id.tetrisview) returns the correct instance of the class). I guess the fault is not in the code segment that you posted :) Tauno On Oct 19, 10:45 pm, Craig <[EMAIL PROTECTED]> wrote: > I take that back - it didn't solve my problem; I am still getting null > from my findViewById call. I had some other code for debugging which > made it looked like it worked. Could someone spot what I'm doing > wrong? > > public class Tetris extends Activity { > ... > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.tetris); > view = (TetrisView) findViewById(R.id.tetrisview); > // view is null here, but there are no inflation errors in the > log > } > ... > > } > > public class TetrisView extends View { > ... > > } > > ...and here is my tetris.xml file: > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > > > <com.technosabbey.games.tetris.TetrisView > android:id="@+id/tetrisview" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > /> > </LinearLayout> > > Thanks in advance, > Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

