No not offended, thank you very much for the input.. it really helped,
but now i need to figure out how to make the images swap on their own
when the system is playing ("I am trying to do simon says") for my
son :)
Here is the improved code
public class GameActivity extends Activity {
/** Called when the activity is first created. */
ImageView imageView1;
ImageView imageView2;
ImageView imageView3;
ImageView imageView4;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.myviewlay);
imageView1= (ImageView)findViewById(R.id.ImageView01);
imageView2= (ImageView)findViewById(R.id.ImageView02);
imageView3= (ImageView)findViewById(R.id.ImageView03);
imageView4= (ImageView)findViewById(R.id.ImageView04);
imageView1.setOnTouchListener(mTouchListener);
imageView2.setOnTouchListener(mTouchListener);
imageView3.setOnTouchListener(mTouchListener);
imageView4.setOnTouchListener(mTouchListener);
}
private OnTouchListener mTouchListener = new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
v.setVisibility(View.INVISIBLE);
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else
{
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch
block
e.printStackTrace();
}
v.setVisibility(View.VISIBLE);
}
return true;
}
};
}
On Apr 22, 1:56 am, TreKing <[email protected]> wrote:
> On Fri, Apr 22, 2011 at 12:30 AM, edprog <[email protected]> wrote:
> > public class myView extends View implements OnTouchListener{}
>
> Sure. Or a member in the Activity that you then set on the ImageViews.
>
> private mTouchListener = new OnTouchListener() { /* CODE */ }
> ...
>
> imageView1.setOnTouchListener(mTouchListener);
> imageView2.setOnTouchListener(mTouchListener);
> imageView3.setOnTouchListener(mTouchListener);
> imageView4.setOnTouchListener(mTouchListener);
>
> Then you're still within the scope of the Activity which is usually handy.
>
> I think,... and yes it is a mess because in the main Activity is where at
>
> > least I was able to make the user click on the images and swap them with
> > another one while I tried the same from the view it did not work... it just
> > shows a black screen, and I tried to look it up in the LogCat but did not
> > tell me something that i would pick up right away.
>
> Yeah, graphics stuff is always a pain to debug and there's not much anyone
> can do to help with graphical issues like that.
>
> > Just on the side note.., I am new to android, at least give me that,...
>
> Given :-)
>
> > you might be an expert..
>
> Hardly. I know what I need to know to do what I need to do. And I know where
> to look when I have to learn something new. ;-)
>
> Again, no offense, just going off what you said and the code you posted.
> Anyways, good luck.
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
--
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