[android-beginners] Re: How to get child Activity?

2010-04-19 Thread Rodrigo Chiossi
This might work, but it would require me to duplicate functional
methods from activity 2 into the main activity, which is undesirable.
So far, sending and intent upon releasing long press is working just
fine, and, although it adds some complexity to the code, it's by far
the simplest solution.

On Apr 16, 2:25 pm, Kitzy kitzyk...@gmail.com wrote:
 What if you left state b as part of activity 1? Then pressing button
 or releasing long-press would start activity 2 (with all of state a).

 Long pressing the button would inflate a view with state b (all inside
 activity 1)

 -Kitzy

 On Apr 16, 6:31 am, Rodrigo Chiossi xrodr...@gmail.com wrote:





  Hi Kitzy.
  If you just click the button, the second activity should start in a
  state A. if you longpress the button, the activity should start in a
  state B and go to state A upon releasing the button (In fact, upon
  releasing the screen, since the button does not exists in the second
  activity), so i can't start it after release. Your second suggestion
  is actually what I managed to do as a workaround: I broadcast an
  intent whenever the first activity receives an event and the second
  activity has already been started (I set a flag after starting). It's
  not a beautiful code, but it's the best solution so far...
  I know it would be easy just not to use this kind of interaction, but
  this is the key feature of the app.

  On Apr 16, 1:48 am, Kitzy kitzyk...@gmail.com wrote:

   What if you start your activity after release?  Or use a broadcast
   receiver?

   Why do you need the new activity to know when you release?

   -Kitzy

   On Apr 15, 10:35 am, Rodrigo Chiossi xrodr...@gmail.com wrote:

I have already tried 3 different approaches to the problem:
The first was this one i described previously, which would be the
ideal for my app.
The second one, i created an ActivityGroup which was responsible for
starting two activities and on LongClick event I was swaping the
DecorViews of the activities. Still, the same problem happened: the
ACTION_UP was being delivered to the wrong activity.
My last approach was to create a single activity and call
setContentView to swap between the two layouts, and still, the event
was not delivered to the right view.
I'm just wondering if there is a way for an Activity to request Input
events...

@Mark: you are right, i messed those approaches a little. I have the
getParent only when I use an ActivityGroup.

On Apr 15, 12:23 pm, Mark Murphy mmur...@commonsware.com wrote:

 Rodrigo Chiossi wrote:
  First, the user press a button on the main Activity. When the
  LongClick triggers, I start the second Activity wich also has a 
  button
  which should be pressed when the activity starts and should only be
  released when the user takes his finger off the screen.

 Why are you using multiple activities? UI events are not designed to
 span multiple activities.

  In order to triggers the onTouch of the button in the second 
  activity,
  i create a copy of the MotionEvent in the first activity and send it
  as an Intent Extra to the second activity which call it's own 
  onTouch
  passing this MotionEvent as parameter.

 Ick.

  Oh, and btw, I call it a 'child' activity since it has a 
  getParent()
  method which returns the main activity...

 Then you are not starting the child activity via startActivity().

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 _Android Programming Tutorials_ Version 2.0 Available!

   --
   You received this message because you are subscribed to the Google
   Groups Android Beginners group.

   NEW! Try asking and tagging your question on Stack Overflow 
   athttp://stackoverflow.com/questions/tagged/android

   To unsubscribe from this group, send email to
   android-beginners+unsubscr...@googlegroups.com
   For more options, visit this group 
   athttp://groups.google.com/group/android-beginners?hl=en

  --
  You received this message because you are subscribed to the Google
  Groups Android Beginners group.

  NEW! Try asking and tagging your question on Stack Overflow 
  athttp://stackoverflow.com/questions/tagged/android

  To unsubscribe from this group, send email to
  android-beginners+unsubscr...@googlegroups.com
  For more options, visit this group 
  athttp://groups.google.com/group/android-beginners?hl=en

 --
 You received this message because you are subscribed to the Google
 Groups Android Beginners group.

 NEW! Try asking and tagging your question on Stack Overflow 
 athttp://stackoverflow.com/questions/tagged/android

 To unsubscribe from this group, send email to
 android-beginners+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-beginners?hl=en

-- 
You received this message because you are subscribed to the Google
Groups

[android-beginners] Re: How to get child Activity?

2010-04-16 Thread Rodrigo Chiossi
Hi Kitzy.
If you just click the button, the second activity should start in a
state A. if you longpress the button, the activity should start in a
state B and go to state A upon releasing the button (In fact, upon
releasing the screen, since the button does not exists in the second
activity), so i can't start it after release. Your second suggestion
is actually what I managed to do as a workaround: I broadcast an
intent whenever the first activity receives an event and the second
activity has already been started (I set a flag after starting). It's
not a beautiful code, but it's the best solution so far...
I know it would be easy just not to use this kind of interaction, but
this is the key feature of the app.

On Apr 16, 1:48 am, Kitzy kitzyk...@gmail.com wrote:
 What if you start your activity after release?  Or use a broadcast
 receiver?

 Why do you need the new activity to know when you release?

 -Kitzy

 On Apr 15, 10:35 am, Rodrigo Chiossi xrodr...@gmail.com wrote:





  I have already tried 3 different approaches to the problem:
  The first was this one i described previously, which would be the
  ideal for my app.
  The second one, i created an ActivityGroup which was responsible for
  starting two activities and on LongClick event I was swaping the
  DecorViews of the activities. Still, the same problem happened: the
  ACTION_UP was being delivered to the wrong activity.
  My last approach was to create a single activity and call
  setContentView to swap between the two layouts, and still, the event
  was not delivered to the right view.
  I'm just wondering if there is a way for an Activity to request Input
  events...

  @Mark: you are right, i messed those approaches a little. I have the
  getParent only when I use an ActivityGroup.

  On Apr 15, 12:23 pm, Mark Murphy mmur...@commonsware.com wrote:

   Rodrigo Chiossi wrote:
First, the user press a button on the main Activity. When the
LongClick triggers, I start the second Activity wich also has a button
which should be pressed when the activity starts and should only be
released when the user takes his finger off the screen.

   Why are you using multiple activities? UI events are not designed to
   span multiple activities.

In order to triggers the onTouch of the button in the second activity,
i create a copy of the MotionEvent in the first activity and send it
as an Intent Extra to the second activity which call it's own onTouch
passing this MotionEvent as parameter.

   Ick.

Oh, and btw, I call it a 'child' activity since it has a getParent()
method which returns the main activity...

   Then you are not starting the child activity via startActivity().

   --
   Mark Murphy (a Commons 
   Guy)http://commonsware.com|http://twitter.com/commonsguy

   _Android Programming Tutorials_ Version 2.0 Available!

 --
 You received this message because you are subscribed to the Google
 Groups Android Beginners group.

 NEW! Try asking and tagging your question on Stack Overflow 
 athttp://stackoverflow.com/questions/tagged/android

 To unsubscribe from this group, send email to
 android-beginners+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-beginners?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en


[android-beginners] Re: How to get child Activity?

2010-04-15 Thread Rodrigo Chiossi
Thanks for the Answers, but none of them really seems like an option
for me.
Giving more details about what I am doing:
First, the user press a button on the main Activity. When the
LongClick triggers, I start the second Activity wich also has a button
which should be pressed when the activity starts and should only be
released when the user takes his finger off the screen.
In order to triggers the onTouch of the button in the second activity,
i create a copy of the MotionEvent in the first activity and send it
as an Intent Extra to the second activity which call it's own onTouch
passing this MotionEvent as parameter.
The problem is: Even with the second Activity up and running, when the
user takes his finger off the screen for the first time, the
MotionEvent ACTION_UP is delivered to the main activity instead of the
second one. I don know exactly why this happens, but I need to forward
this event to the second activity in order to release the button.
Oh, and btw, I call it a 'child' activity since it has a getParent()
method which returns the main activity...

On Apr 15, 5:56 am, Sebastián Treu sebastian.t...@gmail.com wrote:
 On Wed, Apr 14, 2010 at 3:03 PM, Rodrigo Chiossi xrodr...@gmail.com wrote:
  Hi there!

  I have a main Activity and I'm starting a child activity with
  startActivity(intent).
  I want to get the Activity Object created for the child. How can I do
  it?

 I don't know for what, as when you start the new child activity you
 are in it's context and the other is stopped. Although, If you want
 this, an ugly solution can be to have a Main class that extends
 Application and you implement a tree or a list or whatever you want of
 activities, and everytime you launch a new activity you add it to that
 tree, list or whatever. I don't know for what you will want to, but I
 think you can do that UGLY solution. Then, you add the Main class name
 to the xml manifest, and that class is instanciated before anything.
 You can access public methods with getApplication().

 --
 If you want freedom, compile the source. Get gentoo.

 Sebastián Treuhttp://labombiya.com.ar

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe, reply using remove me as the subject.


[android-beginners] Re: How to get child Activity?

2010-04-15 Thread Rodrigo Chiossi
I have already tried 3 different approaches to the problem:
The first was this one i described previously, which would be the
ideal for my app.
The second one, i created an ActivityGroup which was responsible for
starting two activities and on LongClick event I was swaping the
DecorViews of the activities. Still, the same problem happened: the
ACTION_UP was being delivered to the wrong activity.
My last approach was to create a single activity and call
setContentView to swap between the two layouts, and still, the event
was not delivered to the right view.
I'm just wondering if there is a way for an Activity to request Input
events...

@Mark: you are right, i messed those approaches a little. I have the
getParent only when I use an ActivityGroup.

On Apr 15, 12:23 pm, Mark Murphy mmur...@commonsware.com wrote:
 Rodrigo Chiossi wrote:
  First, the user press a button on the main Activity. When the
  LongClick triggers, I start the second Activity wich also has a button
  which should be pressed when the activity starts and should only be
  released when the user takes his finger off the screen.

 Why are you using multiple activities? UI events are not designed to
 span multiple activities.

  In order to triggers the onTouch of the button in the second activity,
  i create a copy of the MotionEvent in the first activity and send it
  as an Intent Extra to the second activity which call it's own onTouch
  passing this MotionEvent as parameter.

 Ick.

  Oh, and btw, I call it a 'child' activity since it has a getParent()
  method which returns the main activity...

 Then you are not starting the child activity via startActivity().

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 _Android Programming Tutorials_ Version 2.0 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe, reply using remove me as the subject.


[android-beginners] How to get child Activity?

2010-04-14 Thread Rodrigo Chiossi
Hi there!

I have a main Activity and I'm starting a child activity with
startActivity(intent).
I want to get the Activity Object created for the child. How can I do
it?

Thanks.

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe, reply using remove me as the subject.


[android-beginners] Align ImageView to the right

2010-03-26 Thread Rodrigo Chiossi
Hi there!
I'm new to android and I'm trying to create a simple layout, with a
TextView aligned to the left and an ImageView aligned to the right,
both in the same line.
I've tried many approaches, but the Imageview never aligns to the
right. Here is my latest attempt:

?xml version=1.0 encoding=utf-8?
TableLayout xmlns:android=http://schemas.android.com/apk/res/
android
android:orientation=vertical
android:layout_width=fill_parent
android:layout_height=wrap_content
TableRow
TextView android:text=@string/label_dots
android:id=@+id/TextView01
android:layout_width=wrap_content
android:layout_height=fill_parent
android:gravity=left/
ImageView android:id=@+id/ImageView01
android:layout_width=fill_parent
android:layout_height=fill_parent
android:src=@drawable/action_add
android:gravity=right/
/TableRow
/TableLayout

It doesn't work on eclipse Layout preview and it doesn't work on my
G1.
Any ideas how to fix it?

-- 
You received this message because you are subscribed to the Google
Groups Android Beginners group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

To unsubscribe from this group, send email to 
android-beginners+unsubscribegooglegroups.com or reply to this email with the 
words REMOVE ME as the subject.