【发布时间】:2010-11-17 05:49:10
【问题描述】:
我想在xml中获取launcher:cellWidth的个数:
<mobi.intuitit.android.p.launcher.CellLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:launcher="http://schemas.android.com/apk/res/mobi.intuitit.android.p.launcher"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
launcher:cellWidth="80dip"
/>
我知道我可以通过以下方式在自定义视图中获取它:
public CellLayout(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);
mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 100);
但是我怎样才能在 Activity 中获得它?不是自定义视图。 谢谢!
【问题讨论】:
标签: android xml custom-attributes