findViewById liefert Null zurück

B

ben56a

Ambitioniertes Mitglied
0
hallo,

folgender Code, funktioniert nicht, da "linearLay" immer NULL bleibt!

Kann mir jemand auf die Sprünge helfen?

Danke ;)

Code:
 public Object instantiateItem(View collection, int position) {

		      
		       LinearLayout linearLay = null;

		        switch (position) 
		        {
		        
		        case 0:
		        	linearLay = (LinearLayout) findViewById(R.layout.tabesuebersicht);
			        break;
		      
		        case 1:
		        	if(currentLocation.getAccount() == 1)
		        	{	
		        		linearLay = (LinearLayout) findViewById(R.layout.premium);
		        	}else
		        	{
		        		linearLay = (LinearLayout) findViewById(R.layout.basic);
		        	}
		        	break;
		        }

		        ((ViewPager) collection).addView(linearLay, 0);
		        return linearLay;

		    }
 
Hi ben56a,

bitte ließ dir die API noch ma durch :)

Code:
Finds a view that was identified by the [B]id attribute[/B] from the XML that was processed in onCreate(Bundle).
Quelle: Activity | Android Developers)

id != layout

:)


Um Layouts einzubringen gibt es den LayoutInflater.

regards
 

Ähnliche Themen

A
  • AnimaAngelo85
Antworten
1
Aufrufe
331
swa00
swa00
L
  • LHomme
Antworten
1
Aufrufe
1.162
jogimuc
J
S
Antworten
2
Aufrufe
984
stikker
S
Zurück
Oben Unten