android的小写view点击事件,在android xml中小写和大写“视图”有什么区别?

最近我花了一个多小时弄清楚我的xml有什么问题......直到我意识到在android xml中有两个不同的小部件:“view”和“View”。两者都是正确的,并不相同,因为大写的视图给我错误的classcastexception,直到我把它改为小写...我们什么时候使用这些?在android xml中小写和大写“视图”有什么区别?

编辑: 所以,为了创建Android的XML现有部件的修改版本,我不得不使用小写的 “视图”:

android:id="@+id/mybutton1"

android:scaleType="fitXY"

android:adjustViewBounds="true"

android:layout_width="wrap_content"

android:layout_height="0dp"

android:layout_weight="75"

class="com.example.customui2.MainActivity$ArticleFragment$MyButton"

android:contentDescription="@string/logo_desc"

android:src="@drawable/menu_button" />

附加到Widget类:

public static class MyButton extends ImageView

{

public MyButton(Context context, AttributeSet attrs) {

super(context, attrs);

}

};

当使用大写视图时,我在这样的行中有例外:

MyButton button1 = (MyButton) rootView.findViewById(R.id.mybutton1);

,但我也发现实例时大写的观点是在“间隔部件”使用,如:

android:layout_weight="20"

android:layout_width="match_parent"

android:layout_height="0dp"/>

2014-07-17

Savail

+0

很难回答,如果你没有发布你的xml –

+0

当使用''时,你有'ClassCastException'?这有点奇怪,你应该使用大写字母。 –

+0

抱歉不要在第一时间发布代码。我认为这是一个相当明显的问题,不值得张贴代码,但现在它在那里! –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值