我有两个 android: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);
当我将它们放在一个 TextView 中时,它会显示一条错误消息 [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" />
如何在单个 TextView 中传递两个 android:id?
提前致谢。
最佳答案
不,这是不可能的。一个组件只能关联一个 android:id
。
关于android - 在xml中的单个TextView中添加两个R.id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13647820/