我想下面的编程每周日历所示例张贴在:
How can I create a weekly calendar view for an Android Honeycomb application?
我已经加入到XML文件张贴有时间标记行假设是在当前小时。要做到这一点我用:类型不匹配:不能从ViewGroup.LayoutParams转换为LinearLayout.LayoutParams
<LinearLayout
android:id="@+id/currentTimeMarkerLinearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:layout_marginTop="120dp"
android:baselineAligned="false"
android:orientation="horizontal"
android:padding="0dp" >
<View
android:layout_width="0dp"
android:layout_height="3dp"
android:layout_weight="1" />
<View
android:id="@+id/currentTimeLineView"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_weight="14"
android:background="@color/dark_blue" />
</LinearLayout>
这LinearLayout
是RelativeLayout
且二者的ScrollView
内内。
我试图通过编程“动”这一行,通过修改layout_margintTop
这些行:
int dipValue = 720; // we want to convert this dip value to pix
Resources r = getResources();
float pix = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
dipValue, r.getDisplayMetrics());
LinearLayout lay =(LinearLayout) findViewById(R.id.currentTimeMarkerLinearLayout);
LinearLayout.LayoutParams lp = lay.getLayoutParams();
lp.setMargins(0, (int) pix, 0, 0);
lay.setLayoutParams(lp);
但我得到lp = lay.getLayoutParams()
一个错误,告诉我,它不能从ViewGroup.LayoutParams
转换为LinearLayout.LayoutParams
。
我在做什么错?
非常感谢你Luksprog,我浪费了很多时间因为这个问题。现在Righ工作非常好! – mgrdiez