0

I am trying to solve this problem on my own, but the error keeps on showing up: System.NullReferenceException: Object reference not set to an instance of an object The lines that are causing this are :

line = new LinearLayout(this);
lisCount++;
lis[lisCount] = line;
line.SetBackgroundColor(Color.Rgb(12, 155, 12));
var lineParams = line.LayoutParameters; // <- line with exception
lineParams.Width = ViewGroup.LayoutParams.MatchParent;

Can Anyone help me?

EDIT: Changed to:

line = new LinearLayout(this);
line.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent,
     ViewGroup.LayoutParams.WrapContent);lisCount++;
lis[lisCount] = line;
line.SetBackgroundColor(Color.Rgb(12, 155, 12));
var lineParams = line.LayoutParameters;
lineParams.Width = ViewGroup.LayoutParams.MatchParent;`

The problem now is that the LinearLayout disappears alltoghether

0 Answers0