3
在我的应用程序中,我有一个文本时钟显示当前小时,我想当我点击一个按钮来从文本时钟获取值并将其放入一个字符串变量。我有这样的:我怎样才能从文本时钟的值
TextClock time = (TextClock) findViewById(R.id.horas);
horas = time.getText().toString();
而在我布局textclock是这样的:
<TextClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/horas"
android:textSize="30dp"
android:layout_below="@+id/space2"
android:layout_centerHorizontal="true" />
但有了这个它返回一个空值。
这应该工作,只要你”在'TextClock'布局后重新调用它;即在屏幕上可见之后。 –
谢谢你,我已经意识到,代码没有在正确的地方:D –
如果你解决了它,请发布一个答案,并将其标记为正确答案,以便它不再出现在未解决的问题中 – njzk2