I am developing a hidden object game for android in eclipse. I have settle a background and want to put some small images on the background on specific positions using x and y axis. how to do it. i have searched a lot for it but haven't found anything helping. i am giving my code. and yes i have used java prams with imagebutton method and set(x) and (y) method as well(which are only available in honeycomb 3.0).
here is the xml code:
<LinearLayout xmlns:android="http://ift.tt/nIICcg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/bg_level1" >
<ImageButton
android:id="@+id/IbCross"
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/cross" />
</LinearLayout>
stage.java
package com.findmystuff;
import android.app.Activity;
import android.os.Bundle;
import android.widget.AbsoluteLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
public class Stage extends Activity{
ImageButton ib1;;
String st = "what the fuck is this!";
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.level1);
ib1=(ImageButton) findViewById(R.id.IbCross);
ib1.setX(445);
ib1.setY(767);
}
}
it is giving me error of "Call requires API level 11 (current min is 10): android.widget.ImageButton#setX" and of course it want float numbers. if i set the min API to 11. then what would be the float notation of x and y axis.
is there any alternative to this function. which takes arguments of x and y axis and put that image on that specified position on the background? or something else. which is simple and not tedious as i have to put several images on different levels of the game.!!
thanks in advance for your suggestions.
No comments:
Post a Comment