2
我使用关闭按钮和幻灯片按钮加载web视图。当我CLICAndroid java.lang.ClassCastException
main.xml中
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#FFFFFF"
android:layout_marginRight="25dip"
android:layout_marginTop="25dip"
android:layout_marginLeft="25dip"
android:layout_marginBottom="25dip" >
<WebView
android:id="@+id/webac_larger"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</WebView>
<ImageView android:id="@+id/close_btn"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/close_button"
android:layout_marginTop="-3dip"
android:layout_marginRight="0dip"
/>
<ImageButton
android:id="@+id/slidebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/close_btn"
android:src="@drawable/arrowleft" />
我想调整的一个按键,点击网页流量。
final ImageButton button1 = (ImageButton) findViewById(R.id.slidebutton);
button1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Log.d("MultiWeb", "I have clicked the button");
RelativeLayout params = ((RelativeLayout)button1.getParent());
params.setLayoutParams(new RelativeLayout.LayoutParams(100, 100));
}
});
我得到这个错误。我正在使用relatice布局,为什么错误会说明框架布局的一些问题?
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.FrameLayout$LayoutParams
它工作!你是个天才!! – sam
@ user113215,你为什么不给这个答案,所以山姆可以接受它? :) –