i have made this xml layout file :
<?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>
and i have this line of codes:
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);
}
}
and this line from another main class which extends activity:
private void readData() {
WorkingView wv = new WorkingView(this,"hello");
list.addView(wv);
}
it all works fine, until the code calls this readData() method.
i don't understand what is wrong?