-1

私はこのxmlレイアウトファイルを作成しました:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/gray"
    android:orientation="vertical" >

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_margin="10dp"
    android:background="@color/black"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/s_hour"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/gray"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/e_hour"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/gray"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>

</RelativeLayout>

</LinearLayout>

そして、私はこのコード行を持っています:

class WorkingView extends LinearLayout
{

public WorkingView(Context context,String str) {
    super(context);
    // TODO Auto-generated constructor stub
    setContentView(R.layout.work_data);

    Text s_hour = (Text) findViewById(R.id.s_hour);
    s_hour.setData(str);
    }

}

そして、アクティビティを拡張する別のメイン クラスからのこの行:

private void readData() {
    WorkingView wv = new WorkingView(this,"hello");
    list.addView(wv);
 }

コードがこの readData() メソッドを呼び出すまで、すべて正常に動作します。

私は何が間違っているのか理解できませんか?

4

1 に答える 1