XML: Can you create a button with a variable text field?

Put your problem here if it does not fit any of the other categories.

XML: Can you create a button with a variable text field?

Postby Lita » Fri Mar 28, 2008 2:34 am

Hi. This is my first time posting and I am kind of a novice with XML. I didn't know where to post this question. But I thought out of all the categories, this section was the best fit. So I want several classes to use an this XML layout with several buttons. However, depending on the class, I want the text of the buttons to say different things with different functionality. Is there a way to display a button with varying text depending on a class that is using the layout? Any help would be greatly appreciated!
Lita
Freshman
Freshman
 
Posts: 2
Joined: Fri Mar 28, 2008 2:26 am

Top

Postby Jesmiatka » Fri Mar 28, 2008 9:03 am

Hi,

why don't you set it in the oncreate of the java class?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 button = (Button) this.findViewById(R.id.buttonid);
  2.  
  3.                 button.setText("LOLCAKES");
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Jesmiatka
Senior Developer
Senior Developer
 
Posts: 164
Joined: Mon Feb 04, 2008 3:37 pm
Location: Netherlands

Postby Lita » Fri Mar 28, 2008 10:15 pm

I totally forgot about that! Thank you so much. So is the text within the button optional? I always thought it was required. but my experience of XML was only through DroidDraw.
Lita
Freshman
Freshman
 
Posts: 2
Joined: Fri Mar 28, 2008 2:26 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google Feedfetcher and 14 guests