Demo:
Activity:
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);
}
}
Download this Project Click Here
No comments:
Post a Comment