Question about tags inside tags.

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

Question about tags inside tags.

Postby LW » Wed Jan 02, 2008 11:56 am

For this example ( a ticker is a String wich move from right to left, exactly like at wall street :
AAPL +0.12% IBM -0.25% etc... )

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4.  
  5.     //XML file
  6.  
  7.     <Ticker id="@+id/ticker"
  8.  
  9.         android:layout_width="fill_parent"
  10.  
  11.         android:layout_height="wrap_content"
  12.  
  13.         android:layout_marginTop="20dip">
  14.  
  15.         <TextView id="@+id/tickerText"
  16.  
  17.             android:layout_width="wrap_content"
  18.  
  19.             android:layout_height="fill_parent"
  20.  
  21.             android:text="@string/ticker_1_tickerText_text"/>
  22.  
  23.     </Ticker>
  24.  
  25.  
  26.  
  27.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4.  
  5.     //java file
  6.  
  7.     mTickerText = (TextView) findViewById(R.id.tickerText);
  8.  
  9.     mUserText = (EditText) findViewById(R.id.userText);
  10.  
  11.  
  12.  
  13.     mTickerText.setText(mUserText.getText());
  14.  
  15.  
  16.  
  17.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4




I would like to know how am i supposed to know that i have to put :
<TextView /> inside <Ticker /> ??
I'm asking this because i thought the " mTickerText.setText(mUserText.getText()); " line already took care about this.


if you do:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4.  
  5.     //XML file
  6.  
  7.     <Ticker id="@+id/ticker"
  8.  
  9.         android:layout_width="fill_parent"
  10.  
  11.         android:layout_height="wrap_content"
  12.  
  13.         android:layout_marginTop="20dip">
  14.  
  15.     </Ticker>
  16.  
  17.  
  18.  
  19.     <TextView id="@+id/tickerText"
  20.  
  21.             android:layout_width="wrap_content"
  22.  
  23.             android:layout_height="fill_parent"
  24.  
  25.             android:text="@string/ticker_1_tickerText_text"/>
  26.  
  27.  
  28.  
  29.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


with the " mTickerText.setText(mUserText.getText()); " line, it doesn't work...

It's ok for this, coz now i know i have to put <TextView /> inside <Ticker />, but what if there's that kind of problem with other java class for the xml file?How would i know?
LW
Junior Developer
Junior Developer
 
Posts: 11
Joined: Mon Dec 31, 2007 2:05 pm

Top

Postby plusminus » Thu Jan 03, 2008 3:11 pm

Hello LW,

the Ticker-Class extends a Layout and therefore you have to place the child-Views between the opening and the closing tag. The Ticker-Class will automatically handle the scrolling/ticking of all its child-views.
[align=center]Image[/align]

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 23 guests