You have to call setContentView before you can call findViewById, so your code will be:
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout ll = (LinearLayout) findViewById(R.id.linearLayout1);
TextView tv = new TextView(this);
tv.setText("testView");
tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
ll.addView(tv);