【发布时间】:2014-10-14 11:12:11
【问题描述】:
我有一个使用来自服务的 RemoteView 构建的通知。
RemoteView 布局包含一个我想让它滚动的 TextView。
我已经在 xml 中将它设置为选取框,一切都很好。但现在我需要设置textView.setSelected(true),因此我需要以某种方式引用textView。
那么如何从 RemoteView 获取 textView 来执行 setSelected()?还是有其他方法可以让它在通知中滚动?
我试过了
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.notification, null);
TextView text = (TextView) layout.findViewById(R.id.text);
text.setSelected(true);
或
View v = views.apply(getApplicationContext(), null);
TextView text = (TextView) v.findViewById(R.id.text);
text.setSelected(true);
但文本没有滚动..
这是我的 xml:
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:duplicateParentState="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="false"
android:singleLine="true" >
<requestFocus
android:duplicateParentState="true"
android:focusable="true"
android:focusableInTouchMode="true" />
</TextView>
【问题讨论】:
标签: android scroll textview android-service remoteview