If you do not want to give yourself a hard time, You'd rather use a layout (ViewGroup) instead of a View.
All you have to do is get yourself a randomizer (PRNG) and get yourself some colors.
After that you can start inflating the layout with some views.
final LinearLayout layout=(LinearLayout)findViewByid(R.id.YOUR_LINEARLAYOUT);
layout.setOrientation(LinearLayout.VERTICAL);
final Random rand=new Random();
for(int i=0;i<3;i++){
final LinearLayout.LayoutParams p=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0);
p.weight=(float)Math.random();
final TextView view=new TextView(this); //No listeners here!
view.setLayoutParams(p);
layout.addView(view);
view.setBackground(new ColorDrawable(
Color.rgb(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255))
));
}
final LinearLayout.LayoutParams p=new LinearLayout.LayoutParams(-1, 0);
final TextView view=new TextView(this);
view.setLayoutParams(p);
layout.addView(view);
view.setBackground(new ColorDrawable(
Color.rgb(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255))
));