增加两个R.id在XML单一的TextView [英] Adding two R.id in a single TextView in xml

查看:240
本文介绍了增加两个R.id在XML单一的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个机器人:ID

例如: R.id.custom_font ]和[ R.id.product_name ]

在.java文件

 TextView tv = (TextView)findViewById(R.id.custom_font);
    Typeface cFont = Typeface.createFromAsset(getAssets(), "fonts/jcc.ttf");
    tv.setTypeface(cFont);

// Adding items to listview
    adapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.product_name,  products);
    lv.setAdapter(adapter);

当我把它们放在一起在一个单一的文本查看显示错误消息[属性机器人:ID已经为元素指定的TextView]

When I put them together in a single text view it shows an error message [Attribute "android:id" was already specified for element "TextView"]

在.xml文件

    <TextView

        android:textColor="?android:textColorPrimary"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/custom_font"
        android:id="@+id/product_name" //Attribute "android:id" was already specified for element "TextView"
        android:textSize="15sp" />

我怎样才能在两机器人:ID在一个单一的文本视图

How can I pass the two android:id in a single text view?

在此先感谢。

推荐答案

没有,那是不可能的。你只能有一个机器人:ID 与一个组件相关联

No, it is not possible. You can have only one android:id associated with one component.

这篇关于增加两个R.id在XML单一的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆