MyLayout.java:
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
public class MyLayout extends LinearLayout {
public MyLayout(Context context) {
super(context);
// TODO Auto-generated constructor stub
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.lcd, this);
}
public MyLayout(Context context, String str) {
super(context);
// TODO Auto-generated constructor stub
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.lcd, this);
}
public MyLayout(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
}
public void setMyLayout(String str)
{
LinearLayout linearLayout3;
MyLayout mMyLayout;
if (mMyLayout != null)
linearLayout3.removeView(fctLayout);
mMyLayout = new mMyLayout(this, str);
mMyLayout.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT, 1));
linearLayout3.addView(mMyLayout);
}