
有没有办法链接ListVIEw中包含的特定TextVIEw?我尝试使用android:autolink =“all”但这不起作用.我得到了一个脱离背景错误.
还需要注意:ListVIEw是我在VIEwFlipper中的第二个视图.
我也尝试过:
VIEw mItemVIEw = mAdapter.getVIEw(2, null, null); TextVIEw infoText = (TextVIEw) mItemVIEw.findVIEwByID(R.ID.rowText2); linkify.addlinks(infoText, linkify.ALL);在适配器绑定到ListVIEw并切换视图之后.没运气.
这是堆栈跟踪:
06-03 21:19:25.180: ERROR/AndroIDRuntime(1214): Uncaught handler: thread main exiting due to uncaught exception06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): androID.util.AndroIDRuntimeException: Calling startActivity() from outsIDe of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.app.ApplicationContext.startActivity(ApplicationContext.java:550)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.content.Contextwrapper.startActivity(Contextwrapper.java:248)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.text.style.URLSpan.onClick(URLSpan.java:62)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.text.method.linkMovementMethod.ontouchEvent(linkMovementMethod.java:216)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.Widget.TextVIEw.ontouchEvent(TextVIEw.java:6560)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.vIEw.VIEw.dispatchtouchEvent(VIEw.java:3709)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.vIEw.VIEwGroup.dispatchtouchEvent(VIEwGroup.java:884)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.vIEw.VIEwGroup.dispatchtouchEvent(VIEwGroup.java:884)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.vIEw.VIEwGroup.dispatchtouchEvent(VIEwGroup.java:884)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.vIEw.VIEwGroup.dispatchtouchEvent(VIEwGroup.java:884)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.vIEw.VIEwGroup.dispatchtouchEvent(VIEwGroup.java:884)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.vIEw.VIEwGroup.dispatchtouchEvent(VIEwGroup.java:884)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.vIEw.VIEwGroup.dispatchtouchEvent(VIEwGroup.java:884)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at com.androID.internal.policy.impl.PhoneWindow$DecorVIEw.superdispatchtouchEvent(PhoneWindow.java:1659)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at com.androID.internal.policy.impl.PhoneWindow.superdispatchtouchEvent(PhoneWindow.java:1107)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.app.Activity.dispatchtouchEvent(Activity.java:2061)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at com.androID.internal.policy.impl.PhoneWindow$DecorVIEw.dispatchtouchEvent(PhoneWindow.java:1643)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.vIEw.VIEwRoot.handleMessage(VIEwRoot.java:1691)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.os.Handler.dispatchMessage(Handler.java:99)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.os.Looper.loop(Looper.java:123)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at androID.app.ActivityThread.main(ActivityThread.java:4363)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at java.lang.reflect.Method.invokeNative(Native Method)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at java.lang.reflect.Method.invoke(Method.java:521)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:618)06-03 21:19:25.219: ERROR/AndroIDRuntime(1214): at dalvik.system.NativeStart.main(Native Method)有任何想法吗?
提前致谢!!!
解决方法:
这对我有用:
http://www.anddev.org/view-layout-resource-problems-f27/linkify-problem-t14779.html
基本上,不要使用getApplicationContext(),不要使用它(从链接窃取)
GOOD(linkify works)
CustomAdapter mAdapter = new CustomAdapter(this, itemList);BAD(linkify在运行时失败:从外部调用startActivity()…)
Context mContext = getApplicationContext();CustomAdapter mAdapter = new CustomAdapter(mContext, itemList); 总结 以上是内存溢出为你收集整理的Android – autoLink全部内容,希望文章能够帮你解决Android – autoLink所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)