What I am trying to do is create *N* (in this case 9) copies of the
ImageView object R.id.tile, place each of them at different coordinates on
the layout, and give each its own individual identifier.
*BoardLayout.class:*
@Overrideprotected void onCreate(Bundle savedInstance){
super.onCreate(savedInstance);
setContentView(R.layout.board_layout);
entire_layout = (RelativeLayout)findViewById(R.layout.board_layout);
inner_layout = (RelativeLayout)findViewById(R.id.board);
View[] tiles = new ImageView[9];
for(int i = 0; i<tiles.length; i++){
tiles[i] = (ImageView)findViewById(R.id.tile);
tiles[i].setId(i);
params = new RelativeLayout.LayoutParams(-1, 345);
params.leftMargin = 32*2*3;
params.topMargin = 34*2*3;
layout.addView(tiles[i].findViewById(R.id.tile));
}
...
*board_layout.xml:*
<?xml version="1.0" encoding="utf-8"?><RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/backgroundcolor"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/topbar"
... >
<ImageButton
android:id="@+id/imagebutton"
... />
</LinearLayout>
<RelativeLayout
android:id="@+id/board"
android:layout_width="match_parent"
android:layout_height="345dp"
android:layout_centerVertical="true"
android:background="@drawable/wwfboard" >
<view class="languid.legend.xsolver.DrawView"
android:id="@+id/myView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ImageView
android:id="@+id/tile"
android:layout_width="21dp"
android:layout_height="21dp"
android:src="@drawable/tile" />
</RelativeLayout>
</RelativeLayout>
However, I keep getting the *"Source not found"* error on the last line:
layout.addView(tiles[i].findViewById(R.id.tile));..
Any ideas why?
(Side question: is RelativeLayout better than AbsoluteLayout for working
with coordinates?)
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.