How to programmatically set button style?

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

How to programmatically set button style?

Postby YoungSkipper » Wed Oct 28, 2009 11:16 pm

I create button programmatically
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. rightButton = new Button(context);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


How to programmatically set button style "buttonStyleSmall" (like style="?android:attr/buttonStyleSmall" in xml) and align parent (like "layout_alignParentRight="true" in xml)?

Regards, Andrey
YoungSkipper
Freshman
Freshman
 
Posts: 4
Joined: Wed Mar 18, 2009 2:35 pm

Top

Postby YoungSkipper » Wed Oct 28, 2009 11:29 pm

Sorry, find answer for first part

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. rightButton = new Button(context, null, android.R.attr.buttonStyleSmall);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


But not understand about layout_alignParentRight.
YoungSkipper
Freshman
Freshman
 
Posts: 4
Joined: Wed Mar 18, 2009 2:35 pm

Postby YoungSkipper » Wed Oct 28, 2009 11:59 pm

Second part

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(
  3.  
  4.                                         RelativeLayout.LayoutParams.WRAP_CONTENT,
  5.  
  6.                                         RelativeLayout.LayoutParams.WRAP_CONTENT);
  7.  
  8.                         lp.addRule(android.widget.RelativeLayout.ALIGN_PARENT_RIGHT);
  9.  
  10.                        
  11.  
  12.                        
  13.  
  14.                         rLayout.addView(rightButton, lp);
  15.  
  16.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
YoungSkipper
Freshman
Freshman
 
Posts: 4
Joined: Wed Mar 18, 2009 2:35 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 6 guests