I've looked over several SO questions and a couple tutorials.
I have tracked the problem, I think, to the context. The solution appears to possibly be editing my xml file, but nothing I find regarding this helps to remedy my problem.
In my main activity with onCreate I try to acquire a reference of my only text view object. This returns a null reference. How do I obtain a valid reference to the textview which I manually placed? I don't know if I have even added this text view correctly; should I have added it via code or something?
Here are both my onCreate and XML.
protected void onCreate(Bundle savedInstanceState) {
Log.i("[DEBUG]", "main activity - started");
super.onCreate(savedInstanceState);
s_textView = (TextView)findViewById(R.id.textView);
m_GLView = new MyGLSurfaceView(this);
setContentView(m_GLView);
s_textView = (TextView)findViewById(R.id.textView);
Log.i("[DEBUG]", "main activity - finished");
}
I have also tried the following line s_textView = (TextView)m_GLView.findViewById(R.id.textView);
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<merge>
<com.example.a2_1039652.a2_cooper.MyGLSurfaceView />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textSize="20dp" />
</merge>
</RelativeLayout>
I only have added this <com.example.a2_1039652.a2_cooper.MyGLSurfaceView />
line because it was the solution for a similar problem. It hasn't appeared to change anything about my application.