Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - How to set set location of buttons programatically

How to set set location of buttons programatically

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to set set location of buttons programatically

Postby rockerboy » Sat Nov 28, 2009 2:03 am

Hi,

How do I set the location of buttons/other views programmatically? Below is my program snippet in the onCreate() method of my activity. Any help please?

//Create two buttons
Button button1 = new Button(this);
Button button2 = new Button(this);

//Create layout params. Here, don't know how to
//set the location (relative location or X ,Y)
LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

button1.setLayoutParams(params);
button1.setText("Click this first");

button2.setLayoutParams(params);
button2.setText("Click this next");

//Create relativelayout
RelativeLayout layout = new RelativeLayout(this);
RelativeLayout.LayoutParams layoutparams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT,10,10);

//Add buttons to layout
layout.addView(button1, layoutparams);
layout.addView(button2, layoutparams);
//Set layout as content of activity
setContentView(layout);
rockerboy
Freshman
Freshman
 
Posts: 8
Joined: Sat Nov 14, 2009 3:27 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests