How to access Layout elements from a widget ?

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

How to access Layout elements from a widget ?

Postby colletjb » Sun Aug 23, 2009 9:09 am

Hi,

I'm quite new in developping Android Apps.

I try to access a layout element(LinearLayout line1) in order to add into it other components(TextView[] tv).

What is the equivalent method of "FindViewById()" for widgets (AppWidgetProvider) ?

In fact, the code should look like that :

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. LinearLayout ly = (LinearLayout)findViewById(R.id.line1); // Doesn't exist <img src="http://www.anddev.org/images/smilies/sad.png" alt=":(" title="Sad" />
  3.  
  4. TextView[] tv = new TextView[31];
  5.  
  6.                 int counter = 1;
  7.  
  8.                 for(int i = 1; i <= tv.length; i++){
  9.  
  10.                         tv[i-1] = new TextView(context);
  11.  
  12.                         tv[i-1].setText(new Integer(counter++).toString());
  13.  
  14.                         ly.addView(tv[i-1]);
  15.  
  16.                 }
  17.  
  18.  
Parsed in 0.036 seconds, using GeSHi 1.0.8.4


Thanks for your help.
colletjb
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sun Aug 23, 2009 8:55 am

Top

Postby colletjb » Mon Aug 24, 2009 7:11 am

Nobody ?
colletjb
Junior Developer
Junior Developer
 
Posts: 10
Joined: Sun Aug 23, 2009 8:55 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 13 guests