Demo:
1)Activity:
package com.venky.dynamiclayout;
1)Activity:
package com.venky.dynamiclayout;
import
android.app.Activity;
import
android.os.Bundle;
import
android.widget.LinearLayout;
import
android.widget.TextView;
public class
CreateLayoutDynamicallyActivity extends Activity {
/** Called when the activity is first
created. */
@Override
public void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
TextView tv = new
TextView(getApplicationContext());
tv.setText("TextView");
LinearLayout ll = new
LinearLayout(getApplicationContext());
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(tv);
setContentView(ll);
}
No comments:
Post a Comment