【问题标题】:Need help in using CheckedTextView in android在 android 中使用 CheckedTextView 需要帮助
【发布时间】:2009-11-03 19:31:07
【问题描述】:

我的 layout.xml 文件中有以下内容:

<CheckedTextView 
    android:id="@+id/checktext"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:gravity="center_vertical"
    android:checkMark="?android:attr/listChoiceIndicatorSingle"
    android:paddingLeft="6dip"
    android:paddingRight="6dip"
/>

它显示了“单选按钮”,但是当我调用 onClickListener() 时?

CheckedTextView numberView2 = (CheckedTextView) v.findViewById(R.id.checktext);
numberView2.setSelected(true);
v.invalidate();

它没有显示选中的“单选按钮”。我已经通过源代码单步执行,它确实执行了“numberView2.setSelected(true);”,但它仍然没有显示选中的单选按钮。

你能告诉我这是为什么吗?我该如何解决我的问题。

【问题讨论】:

  • 你为什么要使整个父视图无效,而不仅仅是numberView2
  • 我不知道。我想尽一切办法让它发挥作用。

标签: android


【解决方案1】:

您确定不想用 setChecked 代替 setSelected?

【讨论】:

    猜你喜欢
    • 2021-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-27
    相关资源
    最近更新 更多