I have a class that extends View, that i have declared in the xml-layout file.
The class has this constructor:
Using java Syntax Highlighting
- public class Gamefield extends View
- {
- ....
- public Gamefield(Context context, AttributeSet attrs)
- {
- super(context, attrs);
- this.ctx = context;
- game = new Game();
- neueRunde();
- chip10 = this.getResources().getDrawable(R.drawable.chip_10);
- chip10.setBounds(100,100,120,120);
- chip50 = this.getResources().getDrawable(R.drawable.chip_50);
- chip50.setBounds(100,100,120,120);
- chip100 = this.getResources().getDrawable(R.drawable.chip_100);
- chip100.setBounds(100,100,120,120);
- chip500 = this.getResources().getDrawable(R.drawable.chip_500);
- chip500.setBounds(100,100,120,120);
- bank = (TextView) ((Activity)ctx).findViewById(R.id.TextViewBank);
- bank.bringToFront();
- punkte = (TextView) ((Activity)ctx).findViewById(R.id.TextViewPunkte);
- punkte.bringToFront();
- }
Parsed in 0.050 seconds, using GeSHi 1.0.8.4
The XML-Layout file:
Using xml Syntax Highlighting
- <AbsoluteLayout android:id="@+id/AbsoluteLayout01" android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android">
- <ListView android:id="@+id/android:list" android:layout_width="wrap_content" android:layout_height="wrap_content"></ListView>
- <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/TextViewBank" android:layout_y="300px" android:layout_x="200px" android:text="Bank:"></TextView>
- <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/TextViewPunkte" android:layout_x="5px" android:layout_y="300px" android:text="Player:" android:bufferType="normal"></TextView>
- <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_x="100px" android:layout_y="120px" android:textSize="20px" android:id="@+id/TextViewMessage"></TextView>
- <com.andriod.blackjack.Gamefield
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="BJ"
- android:background="@string/backpic"/>
- </AbsoluteLayout>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
So my question is, does this code create an Instance of the class Gamefield?? Because i need a reference to this class in my code and how do i get it?
Here the code where the layout is set
Using java Syntax Highlighting
- public class GameActivity extends ListActivity
- {
- private static final int BET_ID = Menu.FIRST;
- private static final int EXIT_ID = Menu.FIRST+1;
- private static final int NEWCARD_ID = Menu.FIRST+2;
- private static final int SHOW_ID = Menu.FIRST+3;
- private static final int TAKEMONEY_ID = Menu.FIRST+4;
- private TextView message;
- private Gamefield gf;
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.game);
Parsed in 0.038 seconds, using GeSHi 1.0.8.4
Thanks!

