I tried everything on stackoverflow, but still can't find a solution.
I tried to debug by setting breakpoint, the scoreView variable's mText is being updated, it keep showing the default string startingScore
, but the UI is not updated, i tried to call the setText using onUiThread
function as well.
I can't really figure it out. Can someone help?
Thank you so much
(This is an augmented reality game using metaio)
I have also checked the id of the view and string are unique.
ARActivity.java
public class ARActivity extends ARViewActivity {
// TextView of the score, will be updated regularly
TextView scoreView;
...
//onCreate Method in ARActivity.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ar_view);
scoreView = (TextView) findViewById(R.id.arScoreView);
scoreView.setText("Happy day");
}
// onDrawFrame method in ARActivity.java
@Override
public void onDrawFrame() {
metaioSDK.render();
scoreView.setText("Happy day");
}
ar_view.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/arScoreView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="22dp"
android:layout_marginStart="28dp"
android:layout_marginTop="18dp"
android:text="@string/startingScore"
android:visibility="visible" />
Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Shiny Pandas</string>
<string name="hello_world">Hello world!</string>
<string name="action_settings">Settings</string>
<string name="how_to_play">How To Play</string>
<string name="new_game">New Game</string>
<string name="title_activity_main_menu">Shiny Pandas</string>
<string name="about_us">About Us</string>
<string name="title_activity_how_to">HowToActivity</string>
<string name="title_section1">Section 1</string>
<string name="title_section2">Section 2</string>
<string name="title_section3">Section 3</string>
<string name="title_activity_about_us">AboutUsActivity</string>
<string name="pause">Pause</string>
<string name="startingScore">Score: 0</string>
</resources>
============ UPDATE =============
I Just realize when I click the back button on my phone back to the menu, the default text changed at that time.