0
我的问题,我知道很简单,但对我的生活,我不能得到答案......绘制成滚动视图
我有一个LinearLayout中,进行了滚动型里面......在滚动视图(代码),应该调用自定义滚动型显示应用......它只能显示黑,什么也没有......这里是我的代码
第一的XML ...简单的LL同一个TextView,滚动视图和按钮
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:layout_height="wrap_content"
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:text="test field" android:layout_alignParentTop="true"/>
<ScrollView android:layout_width="600dp"
android:layout_height="300dp"
android:id="@+id/v1"
android:fillViewport="true"/>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/gfx"
android:text="Gfx"
></Button>
</LinearLayout>
现在,活动的onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
cw = getWindowManager().getDefaultDisplay().getWidth();
ch = getWindowManager().getDefaultDisplay().getHeight();
v = Draw2d findViewById(R.id.v1);
context = this;
setContentView(R.layout.gfx);
mDbHelper = new DbAdapter(this);
mDbHelper.open();
}
Draw2d是自定义scrollView的类声明像这样(它确实有onDraw和一切。如果我设置了内容查看到Draw2D的对象直接,它会显示没有问题,但我需要它withen一个LL)
public static class Draw2d extends ScrollView{
public Draw2d(Context context) {
super(context);
}
请任何帮助表示赞赏
我有,自定义scrollView中有一个onDraw函数,我没有粘贴在这里。但它确实显示,如果我直接做SetContentView作为类Draw2d ...但我不想这样做,我想设置XML布局 – Hok