我在Glass中創建了一個Immersion
類型的應用程序。我嘗試動態更改Activity
中的TextView,但是當我轉到該活動時程序崩潰。我不想使用Cards
,因爲它是一個身臨其境的程序。Google Glass:TextView setText在活動中不起作用
任何想法如何獲得TextView.setText
在常規活動中工作?
謝謝!
活動onCreate方法
TextView tvTest = (TextView)findViewById(R.id.testText);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_checklist);
mGestureDetector = createGestureDetector(this);
readJson();
tvTest.setText("testing testing");
}
活動XML
<FrameLayout
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:padding="40px"
tools:context=".NewChecklistActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center_horizontal"
android:text="@string/newChecklist"
android:textSize="50px"
android:textStyle="bold" />
<TextView
android:id="@+id/testText"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</FrameLayout>
你能發表一些代碼嗎?你可以通過膨脹佈局並從中獲得'TextView'小部件的方式與任何其他Android設備上的方式不同,所以相同的技術應該在那裏工作。 –
@TonyAllevato添加了代碼。這種方式通常適用於我曾經使用過的任何Android程序,因爲它爲什麼不適用於Glass。 –