Android TextView defStyle参数被忽略了吗?
请注意,我正在使用Mono for Android
我有一个ListView项目,可以通过单击列表底部的“更多”按钮进行扩展。 该列表以XML格式定义,但更多按钮只是一个可点击的TextView,它通过AddFooterView添加到列表的底部。 我试图将预定义的样式应用于运行时创建的TextView但它无法正常工作。
mMoreProductsButton = new TextView(this, null, Resource.Style.more_button); mMoreProductsButton.Text = "More"; mMoreProductsButton.Click += new EventHandler(MoreProductsButton_Click); mListView.AddFooterView(mMoreProductsButton);
TextView文档显示了这个签名: TextView(Context context, AttributeSet attrs, int defStyle)
defStyle
在文档中定义为要应用于视图的默认样式。 我在其他地方看到的一个例子将null作为AttributeSet传递,但我不确定它是否有效或与我的问题有关。
我发现了这个错误,并且不确定它是否相关且最新: http : //code.google.com/p/android/issues/detail?id = 12683
任何建议表示赞赏!
我也搜索了这个问题的答案。 它似乎是一个Android错误,因为我没有找到适用于创建视图的样式方式。 你为什么不想夸大你的TextView?
像这样:
布局/ my_view.xml
活动
TextView mMoreProductsButton = (TextView) getLayoutInflater().inflate(R.layout.my_view, null, false);
对不起,我不知道Mono是否可行。
- HttpClient.GetAsync永远不会在Xamarin.Android上返回
- 混合Action和API调用时Xamarin崩溃(线程问题?)
- C#Android:在服务上获取广播接收器?
- 为什么IAsyncResult将所有端口报告为已打开?
- 如何在unity3d中隐藏InputField附加输入框
- 是否有任何类型的解决方案来开发C#中的Blackberry应用程序,如Mono for Android或Monotouch?
- 请帮助减少Xamarin.Android的apk大小
- Xamarin AlarmManager Android
- UnityWebRequest嵌入HTTP基本身份validation的用户+密码数据不适用于Android