[android-developers] MediaPlayer not working properly - causing sounds to be truncated

2011-01-19 Thread Peter Carpenter
Greetings fellow androidians,

I need to provide the facility to play multiple sounds (which could be large) 
concurrently and to know once each sound has finished playing.

Unfortunately this results in my sounds being played back quite randomly. 
Sometimes the first sound is truncated before the second starts, sometimes they 
play over the top of eachother correctly, and sometimes they start together but 
one (or both) cuts out prematurely!

I can't use the soundpool as I want to detect when each sound has finished 
playing.

My code:

private void playSound(final File f, final Runnable onFinish)
{
runOnUiThread(new Runnable() {
public void run() {
try {
FileDescriptor fd = new FileInputStream(f).getFD();
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(fd);
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.prepare();
mp.start();
mp.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp)
{
mp.release();
if (onFinish != null)
onFinish.run();
}
});
}
catch (IOException io)
{
logError(io);
}
}
});
}

The log does indicate some kind of event is being removed from the queue and a  
write being blocked:

W/AudioFlinger(15290): write blocked for 159 msecs, 146 delayed writes, thread 
0xd7e0
W/TimedEventQueue(15290): Event 8 was not found in the queue, already cancelled?
D/dalvikvm(25327): GC_FOR_MALLOC freed 5468 objects / 497648 bytes in 41ms
W/TimedEventQueue(15290): Event 20 was not found in the queue, already 
cancelled?
D/dalvikvm(25327): GC_EXTERNAL_ALLOC freed 424 objects / 26632 bytes in 30ms
I/AudioHardwareQSD(15290): AudioHardware pcm playback is going to standby.

Does anyone have any ideas on what is going on?  Are you only allowed to 
prepare one mediaplayer at a time???

Regards,

Peter Carpenter.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

RE: [android-developers] Re: Scrolling broken in 2.2 ?

2010-10-17 Thread Peter Carpenter
I saw someone had referenced this e-mail and thought I should share my solution 
in case anyone else is attempting to make this work, it's actually quite easy.
All you need to do is override/add the following in your parent ScrollView to 
prevent it from 'stealing' the gesture from another ScrollView or AdapterView 
(list).

@Override
public boolean onInterceptTouchEvent(MotionEvent ev)
{
   final int action = ev.getAction();
   if (action == MotionEvent.ACTION_MOVE)
   {
   if (isScrollableChildAtPoint((int)ev.getX(), (int)ev.getY(), this))
   return false;
   }
   return super.onInterceptTouchEvent(ev);
}

public static boolean isScrollableChildAtPoint(int x, int y, ViewGroup v)
{
Rect frame = new Rect();
x += v.getScrollX();
y += v.getScrollY();
for (int i = v.getChildCount() - 1; i = 0; i--)
{
final View child = v.getChildAt(i);
child.getHitRect(frame);
if (frame.contains(x, y))
{
if (child instanceof FrameLayout || child instanceof 
AdapterView?)
return true;
else if (child instanceof ViewGroup)
return isScrollableChildAtPoint(x, y, (ViewGroup)child);
}
}
return false;
}




 -Original Message-
 From: android-developers@googlegroups.com 
 [mailto:android-develop...@googlegroups.com] On Behalf Of Romain Guy
 Sent: Wednesday, 15 September 2010 4:42 PM
 To: android-developers@googlegroups.com
 Subject: Re: [android-developers] Scrolling broken in 2.2 ?

 Hi,

 You should never have a scrolling widget inside a scrolling widget;
 for instance a ListView inside a ScrollView. The behavior for such a
 setup is pretty much guaranteed to not work (and definitely not
 guaranteed to work.)

 On Tue, Sep 14, 2010 at 11:39 PM, Peter Carpenter
 peter.carpen...@skytechnologies.com wrote:
  My app builds up a custom screen as dictated to me via the users
  'application'.  This means that I can end up in the situation where I have a
  parent scrollview and somewhere down the heirachy I can have a listView or a
  multiline TextView.

  Both of these scenarios continue to work fine under 2.1, however are broken
  in 2.2 (both device and emulator).  The symptoms are that the child (list or
  textview) is unable to scroll using touch gestures although they can be
  scrolled using the keypad.

  Has anyone else experienced this behaviour and/or have a work around??  It
  appears that the onTouchEvent function in View has been changed
  substantially but I am currently delving into the code...

  Cheers,

  Peter.

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

 Note: please don't send private questions to me, as I don't have time
 to provide private support.  All such questions should be posted on
 public forums, where I and others can see and answer them

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


RE: [android-developers] Re: Exact Layout that fits a background image

2010-09-26 Thread Peter Carpenter
Ah, they'd be my own classes but they're irrelevant for this example.

Replace ApcEditText with EditText, remove TableComponent from the constructor 
parameters (it's not referenced), and only pass 'context' into the constructor 
of your EditText.

Peter.

-Original Message-
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of Martin
Sent: Sunday, 26 September 2010 6:23 AM
To: Android Developers
Subject: [android-developers] Re: Exact Layout that fits a background image

On 22 Sep., 01:51, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:
         ApcEditText editText;
...
         public DataViewController(Context context, TableComponent tc)

Just a question: What is ApcEditText and TableComponent?
I do not have these classes in my Android Standard Library.

Greetings, Martin

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


RE: [android-developers] Re: Exact Layout that fits a background image

2010-09-21 Thread Peter Carpenter
It's not hard - just lots of maths

Android gives some vague documentation here:  
http://developer.android.com/guide/topics/ui/custom-components.html

I've provided a sample class that does its own layout - it's not pretty, but 
should give you an idea of what's involved.  I've no idea how you'd create a 
generic layout that you can use in your xml or eclipse layout editor - sorry.  
Hopefully someone else can provide a few tips on how to do this.


The following class contains 3 child objects - a button, a text view  an edit 
text.  I probably could have used a relative layout for this, but I wanted to 
do a few other things too (that I've removed to keep this example simple).  
Here I specifically wanted the component to be limited to the height of the 
button (as thin as possible) and the remaining space split evenly between the 
textView and the editView, with appropriate padding in between.

Note the following:
In onMeasure - I call measure on all of the child components, and call 
setMeasuredDimension at the end.  onMeasure can be called in a number of modes 
and can definitely get quite complex. :(  Read the following 

In onLayout - I call layout on all of the children.  You should really use the 
child dimensions calculated in the last call of onMeasure by calling 
[child].getMeasuredHeight()/getMeasuredWidth()  but I didn't as the values 
shouldn't have changed.

RequestLayout is a call that recursively travels up the component heirachy 
until it reaches the ViewRoot and triggers a relayout of the entire screen.  
EditTexts and other components like to call this when their contents change so 
that they can grow and cause layouts as you type.  If this is annoying, you can 
override it to prevent this from happening.


Hope this helps rather than confuses,

Peter.


public class DataViewController extends ViewGroup
{
TextView textView;
ApcEditText editText;
Button ddButton;

private static final int BUTTON_PAD = 2;

public DataViewController(Context context, TableComponent tc)
{
super(context);

textView = new TextView(context);
textView.setText(Text);
addView(textView);

ddButton = new Button(context);
addView(ddButton);

editText = new ApcEditText(context, null, true);
addView(editText);
}

@Override
public void requestLayout()
{
// Prevent changes in the child components from causing the layout
// to be recalculated.  (You don't necessarily have to overwrite 
this)
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
int hSize = MeasureSpec.getSize(heightMeasureSpec);
int hMode = MeasureSpec.getMode(heightMeasureSpec);

ddButton.measure(0, MeasureSpec.makeMeasureSpec(hMode, hSize - 
getPaddingLeft() - getPaddingRight()));

int h = ddButton.getMeasuredHeight() + getPaddingTop() + 
getPaddingBottom();
int minWidth = ddButton.getMeasuredWidth() + 2 * BUTTON_PAD + 
getPaddingLeft() + getPaddingRight();
int wSize = MeasureSpec.getSize(widthMeasureSpec);
int w = (wSize - minWidth) / 2;

textView.measure(MeasureSpec.makeMeasureSpec(MeasureSpec.EXACTLY, 
w),
MeasureSpec.makeMeasureSpec(MeasureSpec.EXACTLY, h));
editText.measure(MeasureSpec.makeMeasureSpec(MeasureSpec.EXACTLY, 
w),
MeasureSpec.makeMeasureSpec(MeasureSpec.EXACTLY, h));

setMeasuredDimension(wSize, h);
}

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b)
{
int left = getPaddingLeft();
int top = getPaddingTop();
int right = r - l - getPaddingRight();
int bottom = b - t - getPaddingBottom();

int minWidth = ddButton.getMeasuredWidth() + 2 * BUTTON_PAD + 
getPaddingLeft() + getPaddingRight();
int w = (r - l - minWidth) / 2;

textView.layout(left, top, left + w, bottom);
editText.layout(left + w + BUTTON_PAD, top, left + BUTTON_PAD + w * 
2, bottom);
ddButton.layout(right - ddButton.getMeasuredWidth(), top, right, 
bottom);
}
}


-Original Message-
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of Martin
Sent: Wednesday, 22 September 2010 3:56 AM
To: Android Developers
Subject: [android-developers] Re: Exact Layout that fits a background image

Woow this sounds very hard. Is it explained somewhere how to do this,
or is there an example?
If I create my own layout-class, can I still use the Layout-Editor
with eclipse?
Greetings, Martin

On 21 Sep., 02:10, Peter Carpenter
peter.carpen

RE: [android-developers] Exact Layout that fits a background image

2010-09-20 Thread Peter Carpenter
You can create your own class that extends ViewGroup and override the 
layout/onMeasure functions to explicitly define your own layout.
Not sure of how to do this via xml though.

-Original Message-
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of Martin
Sent: Tuesday, 21 September 2010 8:02 AM
To: Android Developers
Subject: [android-developers] Exact Layout that fits a background image

Hi!

I have a background image (full screen) and want to create an exact
layout, which fits this background-image. The buttons and labels have
to be at an exact place of the background-image. How can I do this?
The absolute-layout is deprecated. If I use relative layout, I can use
margins, but the positions differ from device to device.

The best thing is if I could set the exact positions as percent of the
total view size. How can I do this?

Greetings, Martin

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Scrolling broken in 2.2 ?

2010-09-15 Thread Peter Carpenter
My app builds up a custom screen as dictated to me via the users 'application'. 
 This means that I can end up in the situation where I have a parent scrollview 
and somewhere down the heirachy I can have a listView or a multiline TextView.

Both of these scenarios continue to work fine under 2.1, however are broken in 
2.2 (both device and emulator).  The symptoms are that the child (list or 
textview) is unable to scroll using touch gestures although they can be 
scrolled using the keypad.

Has anyone else experienced this behaviour and/or have a work around??  It 
appears that the onTouchEvent function in View has been changed substantially 
but I am currently delving into the code...

Cheers,

Peter.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

RE: [android-developers] Scrolling broken in 2.2 ?

2010-09-15 Thread Peter Carpenter
Hey Romain,

Thanks for the reply,

I can understand why this is not an ideal ui design - I entirely agree.  But 
this doesn't change the fact that there seems to be some regression with the 
Android UI code.  On researching further I've found that there are a number of 
registered bugs for 2.2 to do with browsers exhibiting similar problems whilst 
showing pages containing frames.  Looks like something fundamental has changed 
here.

As far as our use case goes - I need to be able to display whatever a user 
requires in their screen.  Currently we can show these screens on Windows, 
iPhone  Blackberry and Android  2.1 without any issues.  But Android 2.2 
suddenly has this issue with the nesting.  Whilst we *could* design the app to 
work around this bug by using a popup editor - this does not help us keep 
things consistent, and your architecture bug free.

As a workaround - do you know of any way to reset Nexus ones back to 2.1?

Cheers, :)

Peter.

-Original Message-
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of Romain Guy
Sent: Wednesday, 15 September 2010 4:42 PM
To: android-developers@googlegroups.com
Subject: Re: [android-developers] Scrolling broken in 2.2 ?

Hi,

You should never have a scrolling widget inside a scrolling widget;
for instance a ListView inside a ScrollView. The behavior for such a
setup is pretty much guaranteed to not work (and definitely not
guaranteed to work.)

On Tue, Sep 14, 2010 at 11:39 PM, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:
 My app builds up a custom screen as dictated to me via the users
 'application'.  This means that I can end up in the situation where I have a
 parent scrollview and somewhere down the heirachy I can have a listView or a
 multiline TextView.



 Both of these scenarios continue to work fine under 2.1, however are broken
 in 2.2 (both device and emulator).  The symptoms are that the child (list or
 textview) is unable to scroll using touch gestures although they can be
 scrolled using the keypad.



 Has anyone else experienced this behaviour and/or have a work around??  It
 appears that the onTouchEvent function in View has been changed
 substantially but I am currently delving into the code...



 Cheers,



 Peter.

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en



-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


RE: [android-developers] Re: Scrolling broken in 2.2 ?

2010-09-15 Thread Peter Carpenter
Thanks Mike,

Yep it's definitely a cross platform framework.  At its simplest, I don't think 
it's too much to expect from a UI to have a scrolling textView within a parent 
scrollview. 

I'll delve into the source today and see if I can spot what's messing with the 
touch events.

Cheers,

Peter.

-Original Message-
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of Mike dg
Sent: Wednesday, 15 September 2010 7:58 PM
To: Android Developers
Subject: [android-developers] Re: Scrolling broken in 2.2 ?

It sounds like Peter is working on so,e framework for cross platform
applications, si it's probably less than ideal to make Android just
act different.

You are probably out of luck for 2.2 if the browser exhibits the same
behavior.

On Sep 15, 3:18 am, Kumar Bibek coomar@gmail.com wrote:
 Umm, Well, Getting back to 2.1 will not fix your problems. I would
 reckon the best approach would be to re-design your UI.

 -Kumar Bibekhttp://techdroid.kbeanie.com

 On Sep 15, 12:05 pm, Peter Carpenter



 peter.carpen...@skytechnologies.com wrote:
  Hey Romain,

  Thanks for the reply,

  I can understand why this is not an ideal ui design - I entirely agree.  
  But this doesn't change the fact that there seems to be some regression 
  with the Android UI code.  On researching further I've found that there are 
  a number of registered bugs for 2.2 to do with browsers exhibiting similar 
  problems whilst showing pages containing frames.  Looks like something 
  fundamental has changed here.

  As far as our use case goes - I need to be able to display whatever a user 
  requires in their screen.  Currently we can show these screens on Windows, 
  iPhone  Blackberry and Android  2.1 without any issues.  But Android 2.2 
  suddenly has this issue with the nesting.  Whilst we *could* design the app 
  to work around this bug by using a popup editor - this does not help us 
  keep things consistent, and your architecture bug free.

  As a workaround - do you know of any way to reset Nexus ones back to 2.1?

  Cheers, :)

  Peter.

  -Original Message-
  From: android-developers@googlegroups.com 
  [mailto:android-develop...@googlegroups.com] On Behalf Of Romain Guy
  Sent: Wednesday, 15 September 2010 4:42 PM
  To: android-developers@googlegroups.com
  Subject: Re: [android-developers] Scrolling broken in 2.2 ?

  Hi,

  You should never have a scrolling widget inside a scrolling widget;
  for instance a ListView inside a ScrollView. The behavior for such a
  setup is pretty much guaranteed to not work (and definitely not
  guaranteed to work.)

  On Tue, Sep 14, 2010 at 11:39 PM, Peter Carpenter
  peter.carpen...@skytechnologies.com wrote:
   My app builds up a custom screen as dictated to me via the users
   'application'.  This means that I can end up in the situation where I 
   have a
   parent scrollview and somewhere down the heirachy I can have a listView 
   or a
   multiline TextView.

   Both of these scenarios continue to work fine under 2.1, however are 
   broken
   in 2.2 (both device and emulator).  The symptoms are that the child (list 
   or
   textview) is unable to scroll using touch gestures although they can be
   scrolled using the keypad.

   Has anyone else experienced this behaviour and/or have a work around??  It
   appears that the onTouchEvent function in View has been changed
   substantially but I am currently delving into the code...

   Cheers,

   Peter.

   --
   You received this message because you are subscribed to the Google
   Groups Android Developers group.
   To post to this group, send email to android-developers@googlegroups.com
   To unsubscribe from this group, send email to
   android-developers+unsubscr...@googlegroups.com
   For more options, visit this group at
  http://groups.google.com/group/android-developers?hl=en

  --
  Romain Guy
  Android framework engineer
  romain...@android.com

  Note: please don't send private questions to me, as I don't have time
  to provide private support.  All such questions should be posted on
  public forums, where I and others can see and answer them

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group 
  athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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

RE: [android-developers] Re: Scrolling broken in 2.2 ?

2010-09-15 Thread Peter Carpenter
Hi Kumar,

I the short term, it would.  We're not a consumer application so we do have a 
reasonable amount of control over the devices that we ultimately deploy on.  
It's not out of the question for us to say that we don't support 2.2.  But 
obviously it's not in our interests to lock ourselves out of any future android 
releases.

Cheers,

Peter.

-Original Message-
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of Kumar Bibek
Sent: Wednesday, 15 September 2010 5:19 PM
To: Android Developers
Subject: [android-developers] Re: Scrolling broken in 2.2 ?

Umm, Well, Getting back to 2.1 will not fix your problems. I would
reckon the best approach would be to re-design your UI.

-Kumar Bibek
http://techdroid.kbeanie.com

On Sep 15, 12:05 pm, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:
 Hey Romain,

 Thanks for the reply,

 I can understand why this is not an ideal ui design - I entirely agree.  But 
 this doesn't change the fact that there seems to be some regression with the 
 Android UI code.  On researching further I've found that there are a number 
 of registered bugs for 2.2 to do with browsers exhibiting similar problems 
 whilst showing pages containing frames.  Looks like something fundamental has 
 changed here.

 As far as our use case goes - I need to be able to display whatever a user 
 requires in their screen.  Currently we can show these screens on Windows, 
 iPhone  Blackberry and Android  2.1 without any issues.  But Android 2.2 
 suddenly has this issue with the nesting.  Whilst we *could* design the app 
 to work around this bug by using a popup editor - this does not help us keep 
 things consistent, and your architecture bug free.

 As a workaround - do you know of any way to reset Nexus ones back to 2.1?

 Cheers, :)

 Peter.

 -Original Message-
 From: android-developers@googlegroups.com 
 [mailto:android-develop...@googlegroups.com] On Behalf Of Romain Guy
 Sent: Wednesday, 15 September 2010 4:42 PM
 To: android-developers@googlegroups.com
 Subject: Re: [android-developers] Scrolling broken in 2.2 ?

 Hi,

 You should never have a scrolling widget inside a scrolling widget;
 for instance a ListView inside a ScrollView. The behavior for such a
 setup is pretty much guaranteed to not work (and definitely not
 guaranteed to work.)

 On Tue, Sep 14, 2010 at 11:39 PM, Peter Carpenter
 peter.carpen...@skytechnologies.com wrote:
  My app builds up a custom screen as dictated to me via the users
  'application'.  This means that I can end up in the situation where I have a
  parent scrollview and somewhere down the heirachy I can have a listView or a
  multiline TextView.

  Both of these scenarios continue to work fine under 2.1, however are broken
  in 2.2 (both device and emulator).  The symptoms are that the child (list or
  textview) is unable to scroll using touch gestures although they can be
  scrolled using the keypad.

  Has anyone else experienced this behaviour and/or have a work around??  It
  appears that the onTouchEvent function in View has been changed
  substantially but I am currently delving into the code...

  Cheers,

  Peter.

  --
  You received this message because you are subscribed to the Google
  Groups Android Developers group.
  To post to this group, send email to android-developers@googlegroups.com
  To unsubscribe from this group, send email to
  android-developers+unsubscr...@googlegroups.com
  For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 --
 Romain Guy
 Android framework engineer
 romain...@android.com

 Note: please don't send private questions to me, as I don't have time
 to provide private support.  All such questions should be posted on
 public forums, where I and others can see and answer them

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group 
 athttp://groups.google.com/group/android-developers?hl=en



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
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 post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] ListView issue (Editors?)

2010-09-07 Thread Peter Carpenter
Hi all,

I would like to have a listview (or a spinner) that uses an EditText as it's 
view.  This appears to work well until I click on the editText and the soft 
keyboard is displayed.  What results is that the screen is now redisplayed 
using the remaining part of the screen but the focus always jumps to a field 
outside of the list view.

I assume from this, that whilst the keyboard is popping up, the listView has 
removed my EditText and then redisplays it after the keyboard has popped up and 
moved the focus.  Swing had the concept of editor cells which were always 
available to counteract this issue.

Is there a similar concept in Android?  Or is there a better way to do what I'm 
trying to do?

I appreciate your comments,

Peter Carpenter.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] StateListDrawable erases colorfilters???

2010-08-01 Thread Peter Carpenter
Hallo there,

I am creating a custom check box in which I wish to support an infinite number 
of colours for the foreground or the background.
To do this I have a background image, and a foreground image which is a tick 
that will be drawn over the top of the background.
To set the colours I am adding a colour filter to the foreground or background 
drawable, however this is getting 'lost' once the button is drawn.
IF I set the colorFilter on the actual StateListDrawable (sl), then this works 
fine, however I want the colour filters to be applied to the underlying images.

Does anyone know what could be going on here?  It appears as though the 
StateListDrawable is not respecting the colorFilters of it's children.

Cheers,

Peter.


CODE I'M USING BELOW:


CheckBox b = new CheckBox(context);
StateListDrawable sl = new StateListDrawable();

int checked = android.R.attr.state_checked;
int enabled = android.R.attr.state_enabled;
int focused = android.R.attr.state_focused;
int pressed = android.R.attr.state_pressed;
int wFocused = android.R.attr.state_window_focused;

Drawable background = 
context.getResources().getDrawable(R.drawable.btn_check_off).mutate();
Drawable foreground = 
context.getResources().getDrawable(R.drawable.btn_check_center).mutate();
Drawable selectedBackground = 
context.getResources().getDrawable(R.drawable.btn_check_off_selected);
Drawable pressedBackground = 
context.getResources().getDrawable(R.drawable.btn_check_off_pressed);
Drawable disabledBackground = 
context.getResources().getDrawable(R.drawable.btn_check_off_disable).mutate();
Drawable focusBorder = 
context.getResources().getDrawable(R.drawable.focus_border);

if (style != null  style.getForegroundColour() != null)
foreground.setColorFilter(style.getForegroundColour(), 
Mode.MULTIPLY);
else
foreground.setColorFilter(Color.GREEN, Mode.MULTIPLY);

if (style != null  style.getBackgroundColour() != null)
{
background.setColorFilter(style.getBackgroundColour(), 
Mode.MULTIPLY);
disabledBackground.setColorFilter(style.getBackgroundColour(), 
Mode.MULTIPLY);
}

sl.addState(new int[] {checked, -wFocused, enabled}, new 
LayerDrawable(new Drawable[] {background, foreground}));
sl.addState(new int[] {-checked, -wFocused, enabled}, background);
sl.addState(new int[] {checked, pressed, enabled}, new 
LayerDrawable(new Drawable[] {pressedBackground, foreground}));
sl.addState(new int[] {-checked, pressed, enabled}, pressedBackground);
sl.addState(new int[] {checked, focused, enabled}, new 
LayerDrawable(new Drawable[] {selectedBackground, foreground}));
sl.addState(new int[] {-checked, focused, enabled}, selectedBackground);
sl.addState(new int[] {checked, enabled}, new LayerDrawable(new 
Drawable[] {background, foreground}));
sl.addState(new int[] {-checked, enabled}, background);

sl.addState(new int[] {checked, -wFocused}, new LayerDrawable(new 
Drawable[] {disabledBackground, foreground}));
sl.addState(new int[] {-checked, -wFocused}, disabledBackground);
sl.addState(new int[] {checked, focused}, new LayerDrawable(new 
Drawable[] {disabledBackground, focusBorder, foreground}));
sl.addState(new int[] {-checked, focused}, new LayerDrawable(new 
Drawable[] {disabledBackground, focusBorder}));
sl.addState(new int[] {checked}, new LayerDrawable(new Drawable[] 
{disabledBackground, foreground}));
sl.addState(new int[] {-checked}, disabledBackground);

b.setButtonDrawable(sl);

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Clarification on static variables

2009-06-03 Thread Peter Carpenter

Thanks very much Mark  Streets of Boston.

It's taken me a while to get a grasp of the whole application lifecycle
- especially once you throw Services into the mix, but I think I'm
starting to get it! :)

System.exit() definitely gets me out of the hole for now.  Which is
great - but as you say we'll still have to fix up the statics to get an
automated restart up and running.

Thank you both for protecting my sanity.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Extremely frustrating = TextView in ScrollView - Scroll to bottom?

2009-05-28 Thread Peter Carpenter

Oh dear...
I should have tried that first.  It works beautifully!
Thanks very much skink.  I wasn't able to get the Selection.SetSelection
to work even if I posted it later.  There's obviously something I don't
quite understand about how all of this works. - Like why I need to put a
TextView that supports scrolling inside a scrollview to do this
anyway... :S

After experimenting a bit more I was only able to get the following 2
commands to work:

sv.post(new Runnable() {
public void run() {
sv.scrollTo(0, tv.getHeight());
}
});

And 

sv.post(new Runnable() {
public void run() {
sv.fullScroll(ScrollView.FOCUS_DOWN);
}
});

Thanks skink  Raphael

-Original Message-
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of skink
Sent: Thursday, 28 May 2009 6:52 PM
To: Android Developers
Subject: [android-developers] Re: Extremely frustrating = TextView in
ScrollView - Scroll to bottom?




On 28 Maj, 01:28, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:
 Hi guys,


 It appears that plenty of people have asked about this in newsgroups,
 but no solution offered.

 textView.setText(s);


try:
tv.setText(s);
sv.post(new Runnable() {
void run() {
sv.scrollTo(0, yPosition);
}
});













--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Extremely frustrating = TextView in ScrollView - Scroll to bottom?

2009-05-27 Thread Peter Carpenter
Hi guys,

 

I can't for the life of me work out how to get a text view to be
displayed scrolled to the bottom.

 

It appears that plenty of people have asked about this in newsgroups,
but no solution offered.

 

textView.setText(s);

scrollView.fullScroll(ScrollView.FOCUS_UP);

 

The above code is called, and whilst the text is updated correctly, the
view is not scrolled.

(I've tried ScrollView.FOCUS_DOWN) and that doesn't work either

 

Do I need to force the scrollView to measure itself before calling the
scroll function?  If so what would be the best way to go about doing
this and then calling the scroll.

 

I've also tried setting the text as spannable and setting the cursor
position to the end.

 

Cheers,

 

Peter.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Easy one (hopefully) Inverse preference dependency?

2009-05-22 Thread Peter Carpenter
Hi,

 

I have a preference where I'd like to toggle the state of a preference
depending on the state of a checkbox.

This works wonderfully if I want something visible when it's checked.
However I want another preference to be visible when it's NOT checked. 

Is there a way to specify android:dependency= !pref_server_active  or
android:dependency= NOT(pref_server_active) ?

 

Cheers,

 

Peter.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: 1.5 api change - broken scrollbar resources

2009-05-14 Thread Peter Carpenter

Hi Romain,

That makes complete sense.  Will make appropriate changes.

Cheers,

Peter.

-Original Message-
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of Romain Guy
Sent: Thursday, 14 May 2009 4:07 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Re: 1.5 api change - broken scrollbar resources


The system scrollbar does not have a track anymore. Your code should
simply account for that possibility. The framework code does attempt
to load a scrollbar track but does not crash if no resource is
present.

On Wed, May 13, 2009 at 10:36 PM, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:


 Hi all,

 I've just been attempting to upgrade my application to support 1.5 and
 discovered that I can no longer retrieve a resource for my scrollbar
 background.

 My app requires me to draw a scrollbar that I can use to control a
 custom component.

 Currently I was using the following code (which Jeff was kind enough to
 point me in the right direction of):

 TypedValue val = new TypedValue();
 if (context.getTheme().resolveAttribute(
       android.R.attr.scrollbarThumbVertical, val, true))
 {
    scrollThumb = getResources().getDrawable(val.resourceId);
 }
 if (context.getTheme().resolveAttribute(
       android.R.attr.scrollbarTrackVertical, val, true))
 {
    scrollTrack = getResources().getDrawable(val.resourceId);
 }

 However the 2nd getDrawable causes a ResourceNotFound exception so it
 appears the scrollbarTrackVertical has been removed??

 Does anyone know of any other ways to get the system scrollbar
 drawables? (or a system scrollbar by itself?)

 Regards,

 Peter.

 




-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] 1.5 api change - broken scrollbar resources

2009-05-13 Thread Peter Carpenter


Hi all,

I've just been attempting to upgrade my application to support 1.5 and
discovered that I can no longer retrieve a resource for my scrollbar
background.

My app requires me to draw a scrollbar that I can use to control a
custom component.

Currently I was using the following code (which Jeff was kind enough to
point me in the right direction of):

TypedValue val = new TypedValue();
if (context.getTheme().resolveAttribute(
   android.R.attr.scrollbarThumbVertical, val, true))
{
scrollThumb = getResources().getDrawable(val.resourceId);
}
if (context.getTheme().resolveAttribute(
   android.R.attr.scrollbarTrackVertical, val, true))
{
scrollTrack = getResources().getDrawable(val.resourceId);
}

However the 2nd getDrawable causes a ResourceNotFound exception so it
appears the scrollbarTrackVertical has been removed??

Does anyone know of any other ways to get the system scrollbar
drawables? (or a system scrollbar by itself?)

Regards,

Peter.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Davlik bug? UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: [classXXX]

2009-05-11 Thread Peter Carpenter
Hi Dan,
 
Thanks for your response.
After looking a bit closer I finally did find a jar in my path that seemed to 
be causing the problem as you said!  Interestingly, it wasn't imported as a 
library / dependency, but was still in the source path, none-the-less.
 
Thanks!
 
Peter.



From: android-developers@googlegroups.com on behalf of Dan Bornstein
Sent: Tue 12/05/2009 7:05 AM
To: Android Developers
Subject: [android-developers] Re: Davlik bug? UNEXPECTED TOP-LEVEL EXCEPTION: 
java.lang.IllegalArgumentException: already added: [classXXX]




On May 10, 7:23 pm, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:
 However for each one of these scenarios I keep getting the following
 exception thrown by the davlik compiler. [...]
 UNEXPECTED TOP-LEVEL EXCEPTION:
 java.lang.IllegalArgumentException: already added:
 Lau/com/skytechnologies/ecssdk/comm/CommException;

The (admittedly ugly) message is trying to tell you that you have in
fact managed to include two classes with the same fully-qualified name
(package + name) in your dx commandline. If you are using dx
implicitly via the Eclipse plugin (looks like you are), then you have
somehow managed to add the same classes twice in the Eclipse UI.

Since you haven't included a full steps-to-reproduce I can't opine
further about what's going on. I am also not an Eclipse user, so I
will have to defer to other experts if the root problem is at that
level.

In any case, I hope this helps.

-dan






--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---

inline: winmail.dat

[android-developers] Davlik bug? UNEXPECTED TOP-LEVEL EXCEPTION: java.lang.IllegalArgumentException: already added: [classXXX]

2009-05-10 Thread Peter Carpenter
 

Hi all,

 

I am attempting to integrate some previous libraries that we have within
my new android project.

I have made several attempts including:

Importing the code as sub-projects (that are built using the
android.jar)

Importing the code as jar files (from the built code)

Adding the files directly as part of my project

Reordering the dependencies

 

However for each one of these scenarios I keep getting the following
exception thrown by the davlik compiler.

It is always picking the first class in the package (ie if I remove that
class, it picks the next and so on).

 

It would appear to me that this is a compiler bug - somehow it's getting
it's dependencies in a twist.

Anyone else experienced this?  And/or have any ideas on how to get
around this one?

 

Cheers,

 

Peter.

 

 

 

[2009-05-11 12:13:01 - Android] 

UNEXPECTED TOP-LEVEL EXCEPTION:

java.lang.IllegalArgumentException: already added:
Lau/com/skytechnologies/ecssdk/comm/CommException;

[2009-05-11 12:13:01 - Android] at
com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)

[2009-05-11 12:13:01 - Android] at
com.android.dx.dex.file.DexFile.add(DexFile.java:143)

[2009-05-11 12:13:01 - Android] at
com.android.dx.command.dexer.Main.processClass(Main.java:299)

[2009-05-11 12:13:01 - Android] at
com.android.dx.command.dexer.Main.processFileBytes(Main.java:276)

[2009-05-11 12:13:01 - Android] at
com.android.dx.command.dexer.Main.access$100(Main.java:56)

[2009-05-11 12:13:01 - Android] at
com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:228)

[2009-05-11 12:13:01 - Android] at
com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.
java:245)

[2009-05-11 12:13:01 - Android] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java
:130)

[2009-05-11 12:13:01 - Android] at
com.android.dx.cf.direct.ClassPathOpener.processDirectory(ClassPathOpene
r.java:190)

[2009-05-11 12:13:01 - Android] at
com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java
:122)

[2009-05-11 12:13:01 - Android] at
com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:10
8)

[2009-05-11 12:13:01 - Android] at
com.android.dx.command.dexer.Main.processOne(Main.java:245)

[2009-05-11 12:13:01 - Android] at
com.android.dx.command.dexer.Main.processAllFiles(Main.java:183)

[2009-05-11 12:13:01 - Android] at
com.android.dx.command.dexer.Main.run(Main.java:139)

[2009-05-11 12:13:01 - Android] at
sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)

[2009-05-11 12:13:01 - Android] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

[2009-05-11 12:13:01 - Android] at
java.lang.reflect.Method.invoke(Unknown Source)

[2009-05-11 12:13:01 - Android] at
com.android.ide.eclipse.adt.build.DexWrapper.run(Unknown Source)

[2009-05-11 12:13:01 - Android] at
com.android.ide.eclipse.adt.build.ApkBuilder.executeDx(Unknown Source)

[2009-05-11 12:13:01 - Android] at
com.android.ide.eclipse.adt.build.ApkBuilder.build(Unknown Source)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:63
3)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.ja
va:170)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.ja
va:201)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:25
3)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.ja
va:256)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManage
r.java:309)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:34
1)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:
140)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)

[2009-05-11 12:13:01 - Android] at
org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

[2009-05-11 12:13:01 - Android] 1 error; aborting

[2009-05-11 12:13:01 - Android] Conversion to Dalvik format failed with
error 1


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more 

[android-developers] Compiling against a *REAL* android.jar in eclipse???

2009-04-27 Thread Peter Carpenter
Hello everyone,

 

I'd like to be able to extend classes like View and still have access to
the protected member variables.

Under the standard SDK's, android.jar is only a stub and so access to
the protected member variables is not found.  (And also all classes
tagged as {hide} are hidden)


Does anyone know of an easy way to get around/FIX this without going
linux?

 

Cheers,

 

Peter.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Compiling against a *REAL* android.jar in eclipse???

2009-04-27 Thread Peter Carpenter
Hi Dianne,

 

Thanks for replying.

 

I want to create custom GUI components and access things like
View.mScrollX which has no setFunction (to create a horizontally
scrolling view), and mBGDrawable which does have a set function - but
that does a whole heap of stuff I don't want it to do.

 

Essentially with the second option, I would like to have an image button
using all of the standard background drawables (but hide only the
default standard enabled state image).  I can't find API's that let me
do any of this cleanly.  The only way I can currently find is to
intercept the draw function and hide the background temporarily.  It
would be nicer to be able to either create my own StateListDrawable
using the existing button background drawables (which are not public) or
else have a removeState function in the StateListDrawable.

 

So essentially you are saying I shouldn't be doing this???

 

Cheers,


Peter.

 



From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Dianne
Hackborn
Sent: Tuesday, 28 April 2009 1:02 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Re: Compiling against a *REAL* android.jar
in eclipse???

 

Don't do that.  If you aren't writing an app but system code, use the
platform build system.

On Mon, Apr 27, 2009 at 7:29 PM, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:

Hello everyone,

 

I'd like to be able to extend classes like View and still have access to
the protected member variables.

Under the standard SDK's, android.jar is only a stub and so access to
the protected member variables is not found.  (And also all classes
tagged as {hide} are hidden)


Does anyone know of an easy way to get around/FIX this without going
linux?

 

Cheers,

 

Peter.

 

 




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see
and answer them.




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Compiling against a *REAL* android.jar in eclipse???

2009-04-27 Thread Peter Carpenter
Thanks Dianne, makes sense.

 

With the scrolling - I wanted to essentially copy the code used for
vertical scrolling and implement it for horizontal (like others have
done)   However this won't compile due to inability to access the
protected member variables.  There was no function that would
setScrollX() without calling invalidate() etc.  But, this component will
apparently exist in 1.5, so there's light at the end of the tunnel for
this one.

 

 

With regards to the button example though, it looks like I can't win
either way ...  

* If I implement my own background drawing, it won't be compatible with
future versions (Because I can't reference the existing button images
and therefore if the images change in later versions I can't get them)

* If I modify the code and the mechanism for drawing buttons changes, it
will break.

 

Looks like the best thing to do is wrapper the StateListDrawable in this
case then. :-(

 

Cheers,

 

Peter.

 



From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Dianne
Hackborn
Sent: Tuesday, 28 April 2009 1:30 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Re: Compiling against a *REAL* android.jar
in eclipse???

 

Correct.  Don't do this.  Your code will break in the future.  That is
why these fields are hidden.

For scrolling, you can use the method to set the scroll position.

For the background, if the normal background image doesn't do what you
want, then implement your own background drawing.  Clearing and
re-setting the background field is clearly relying on implementation
details that can change in future versions.

If there are specific features you find are missing, you can file
feature requests or (more likely to have a result) submit patches to add
those features.  For the latter, though, keep in mind that we are very
restrictive on accepting changes to fundamental parts of the system like
this.

On Mon, Apr 27, 2009 at 8:13 PM, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:

Hi Dianne,

 

Thanks for replying.

 

I want to create custom GUI components and access things like
View.mScrollX which has no setFunction (to create a horizontally
scrolling view), and mBGDrawable which does have a set function - but
that does a whole heap of stuff I don't want it to do.

 

Essentially with the second option, I would like to have an image button
using all of the standard background drawables (but hide only the
default standard enabled state image).  I can't find API's that let me
do any of this cleanly.  The only way I can currently find is to
intercept the draw function and hide the background temporarily.  It
would be nicer to be able to either create my own StateListDrawable
using the existing button background drawables (which are not public) or
else have a removeState function in the StateListDrawable.

 

So essentially you are saying I shouldn't be doing this???

 

Cheers,


Peter.

 



From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Dianne
Hackborn
Sent: Tuesday, 28 April 2009 1:02 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Re: Compiling against a *REAL* android.jar
in eclipse???

 

Don't do that.  If you aren't writing an app but system code, use the
platform build system.

On Mon, Apr 27, 2009 at 7:29 PM, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:

Hello everyone,

 

I'd like to be able to extend classes like View and still have access to
the protected member variables.

Under the standard SDK's, android.jar is only a stub and so access to
the protected member variables is not found.  (And also all classes
tagged as {hide} are hidden)


Does anyone know of an easy way to get around/FIX this without going
linux?

 

Cheers,

 

Peter.

 

 




-- 

Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see
and answer them.



 

 




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see
and answer them.




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: EditText Tabhost problem

2009-04-20 Thread Peter Carpenter

The editText calls requestLayout every time the text is modified, and
this request flows all of the way up the hierarchy. I would have to
assume that the onMeasure/onLayout functions for the tab are doing
something like clearing the focus, or removing  re-adding your
editText.

Now how to fix this?  I'm not sure. I eagerly await other people's
suggestions!

-Original Message-
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of cvance383
Sent: Saturday, 18 April 2009 7:37 AM
To: Android Developers
Subject: [android-developers] EditText  Tabhost problem


The problem I am having is I have a framelayout with a tabhost (
widget  tabcontent) then I have another layout over top of the tabs
that looks like a form. It has two editTexts but when I type in the
them, the tabs steal focus and put what i typed in the edittext i have
within the tabcontent. If I remove the tabs from my xml and app, the
top level edittext works fine. Anyone know why the tabs steal focus
when I type in the form in the foreground. Any solutions? I appreciate
any help.




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] RequestLayout?

2009-04-19 Thread Peter Carpenter
Hello all,

 

I'm really tearing my hair out trying to make a Spinner component behave
with an EditText as it's child rather than a TextView.

The problem I've getting is that everytime I select an item from the
drop down list, I lose the focus ring from the EditText.  The cursor is
still there, but somehow the state has been lost.

 

The problem CAN be fixed (sort of) by adding a call to requestLayout()
in the onItemSelected event handler.  This seems to be quite
heavy-handed though, because this forces the whole window to be layed
out.

 

Surely there must be a simple way to force the spinner to layout it's
contents  therefore reset the state of the focus ring without laying
out the whole window?  I've tried spinner.forceLayout(),
spinner.childDrawableStateChanged(editText), editText.invalidate() all
to no effect.

 

Does anyone have any ideas please?

I've been slamming my head against this wall for a week now.

 

Regards,

 

Peter.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: How to keep focus highlight on ExpandableList group....

2009-04-16 Thread Peter Carpenter

I'm struggling with a similar issue myself at the moment.

I traced mine down to the fact that modifying the child component caused
it to call RequestLayout().  This in turn, caused the parent to relayout
which unfortunately meant removing and replacing the component with a
new one - thus the focus being lost.  

I fixed this specific problem by overriding the adapter so that it
always used the same instance of the child view when editing. (I'm not
sure why the internal recycling didn't seem to be doing this already
though...)

This might be enough for your situation, however, I'm still left with
the component receiving the focus but not displaying as focused.  That's
the subject of my other thread.

Just a few thoughts...

Peter.

-Original Message-
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of John B. Hansen
Sent: Thursday, 16 April 2009 6:27 AM
To: Android Developers
Subject: [android-developers] How to keep focus highlight on
ExpandableList group


I'm using an ExpandableListActivity and notice that whenever I select
a group item (to expand or collapse it), it highlights briefly and
then
quickly un-highlights.

For my application, I want the group items to remain highlighted. I've
tried requestFocus() and several other things but nothing is working.

Anyone know how to keep a selected group item (after expand or
collapse)
highlighted and focused?

Any help appreciated.

jh





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Accessing internal scrollbar drawable

2009-04-16 Thread Peter Carpenter

Hi,

Hopefully this is a simple one.

My application requires me to draw a scrollbar myself (and include the
old-school physical up/down buttons.  I can't do this via XML as all of
my screens are generated on the fly by data received over a socket. Like
a web browser.

Now the drawables I'm after are scrollbar_vertical.9 and
scrollbar_handle_vertical.9  however these are no longer visible in
the SDK.
I've been poking around and found that
android.R.attr.scrollbarThumbVertical seems to describe what I'm
after, however if I try to load this using
getResources().getDrawable(android.R.attr.scrollbarThumbVertical) I
get a Resources$NotFoundException...

All of the scrollbar parameters in view are protected, but not visible
because the sdk jar file purposely hides them. Grrr!
Ie - ScrollBarDrawable is exactly the class I want, but I quote from the
file:
 * For now, we'll hide it so it can be cleaned up later.
  * {...@hide}

Does anyone know how I can get the standard scrollbar drawables or am I
really going to have to copy them in as my own resources?

Peter.





--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Accessing internal scrollbar drawable

2009-04-16 Thread Peter Carpenter

That's fantastic Jeff, thanks!
Not obviously intuitive though, so I don't feel quite so stupid!

-Original Message-
From: android-developers@googlegroups.com 
[mailto:android-develop...@googlegroups.com] On Behalf Of Jeff Sharkey
Sent: Thursday, 16 April 2009 5:34 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Re: Accessing internal scrollbar drawable


You're probably looking to resolve the attribute by passing it through
the current theme.  Something like this might work:

TypedValue outValue = new TypedValue();
context.getTheme().resolveAttribute(android.R.attr.scrollbarThumbVertical,
outValue, true);
getResources().getDrawable(outValue.resourceId);

j

On Wed, Apr 15, 2009 at 11:12 PM, Peter Carpenter
peter.carpen...@skytechnologies.com wrote:

 Hi,

 Hopefully this is a simple one.

 My application requires me to draw a scrollbar myself (and include the
 old-school physical up/down buttons.  I can't do this via XML as all of
 my screens are generated on the fly by data received over a socket. Like
 a web browser.

 Now the drawables I'm after are scrollbar_vertical.9 and
 scrollbar_handle_vertical.9  however these are no longer visible in
 the SDK.
 I've been poking around and found that
 android.R.attr.scrollbarThumbVertical seems to describe what I'm
 after, however if I try to load this using
 getResources().getDrawable(android.R.attr.scrollbarThumbVertical) I
 get a Resources$NotFoundException...

 All of the scrollbar parameters in view are protected, but not visible
 because the sdk jar file purposely hides them. Grrr!
 Ie - ScrollBarDrawable is exactly the class I want, but I quote from the
 file:
  * For now, we'll hide it so it can be cleaned up later.
  * {...@hide}

 Does anyone know how I can get the standard scrollbar drawables or am I
 really going to have to copy them in as my own resources?

 Peter.





 




-- 
Jeff Sharkey
jshar...@google.com




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Editable Spinner - 95% of the way there - But need some backup!!

2009-04-15 Thread Peter Carpenter


Ok I've got the measure  layout stuff worked out.  Really not that hard
after all - was just a different approach to what I was expecting.

However, this hasn't helped me with the focus ring disappearing problem.

Does anyone have any ideas on this one? 

Pretty please?  :)


-Original Message-
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Peter
Carpenter
Sent: Tuesday, 14 April 2009 3:26 PM
To: android-developers@googlegroups.com
Subject: [android-developers] Editable Spinner - 95% of the way there -
But need some backup!!


Hi all,

I've been slugging away at trying to get an editable spinner component
working.  I've managed to get 95% of the way there but must confess I'm
lost as to how the focus/layout system works within android - especially
inside of this thing they call an AdapterView...


What I have working:
* The spinner displays an EditText and I can type in it.
* I can add a textChangedListener to the EditText and receive updates
beautifully.
* If I register an OnItemSelectedListener on the spinner, I can update
the text field with the new selection  my textChangedListener will pick
it up.

What doesn't work:
* My EditText doesn't scale up to the size of it's parent spinner.
(Setting the layoutParams doesn't seem to help???
* When I change the selection via the spinner popup list, something
changes so that my EditText no longer receives the orange ring around it
when it has focus.  (I still get the flashing cursor and can edit fine,
it just loses the orange focus border)


Would any kind soles have any advice to offer?  Even any tips or
websites on what the philosophy behind this onMeasure, onLayout
philosophy is?  I can't seem to find any books/sites that talk about GUI
stuff that look any deeper than the xml.


My spinner class so far is below.

Cheers,

Peter.


class ApcSpinner extends Spinner implements SpinnerAdapter
{
protected EditText editText = null;
LayoutInflater inflater;
private final DataSetObservable observers = new
DataSetObservable();
ArrayListString options = new ArrayListString();

public ApcSpinner(Context c)
{
super(c);
for (int i=0; i  10; i++)
options.add(Record  + i);
inflater = (LayoutInflater)c.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);

editText = new EditText(c);
editText.setHorizontalFadingEdgeEnabled(true);
editText.setHorizontallyScrolling(true);
setStyle(editText);
if (style != null)
{
if (style.getBackgroundColour() != null)
setBackgroundColor(style.getBackgroundColour());
}

// Control ourselves...
setAdapter(this);
}

public int getCount()
{
return options.size();
}

public Object getItem(int position)
{
return options.get(position);
}

public long getItemId(int position)
{
return position;
}

public int getItemViewType(int position)
{
return 0;
}

public View getView(int position, View convertView, ViewGroup
parent)
{
return editText;
}

public View getDropDownView(int position, View convertView,
ViewGroup parent)
{
TextView textView;
if (convertView != null)
textView = (TextView)convertView;
else
textView = (TextView) inflater.inflate(
android.R.layout.simple_spinner_dropdown_item,
parent, false);
textView.setText(getItem(position).toString());
setStyle(textView);
return textView;
}

public int getViewTypeCount()
{
return 1;
}

public boolean hasStableIds()
{
return false;
}

public boolean isEmpty()
{
return options.size() == 0;
}

public void registerDataSetObserver(DataSetObserver observer)
{
observers.registerObserver(observer);
}

public void unregisterDataSetObserver(DataSetObserver observer)
{
observers.unregisterObserver(observer);
}
}




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: TextView.setText doesn't update

2009-04-14 Thread Peter Carpenter

Hi,

I'm not sure which thread timers fire in, but have you tried calling the
setText explicitly from the UI thread?

final String timeSinceUpdate = tracker.getUpdateAge();
runOnUiThread(new Runnable()
{
public void run()
{
mMyTextView .setText(Current location ( + timeSinceUpdate +
);
}
}

Peter.

-Original Message-
From: android-developers@googlegroups.com
[mailto:android-develop...@googlegroups.com] On Behalf Of Midian
Sent: Tuesday, 14 April 2009 9:44 AM
To: Android Developers
Subject: [android-developers] TextView.setText doesn't update


I have a Timer set up to update a TextView field once every second.
Thing is, I can't see any changes on screen!

Debugging shows...
setText inside the timer function *is* being called.
getText called on the text view returns the *correct* (new) text that
just isn't displayed!

I've tried TextView.postInvalidate() to no effect.
Code below.

Anyone seen this before?
Thanks.



IN MyActivity.onCreate:
mMyTextView = (TextView)this.findViewById
(R.id.txtcurloctitle);

FROM MyTimerTask.Run
String timeSinceUpdate = tracker.getUpdateAge();
mMyTextView .setText(Current location ( + timeSinceUpdate +
):);

IN MyActivity.onOptionsItemSelected:
AlertDialog.Builder msg = new AlertDialog.Builder(this);
msg.setTitle(Debug);
msg.setMessage(mMyTextView.getText());
msg.setPositiveButton(OK, null);
msg.show();




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Editable Spinner - 95% of the way there - But need some backup!!

2009-04-14 Thread Peter Carpenter

Hi all,

I've been slugging away at trying to get an editable spinner component
working.  I've managed to get 95% of the way there but must confess I'm
lost as to how the focus/layout system works within android - especially
inside of this thing they call an AdapterView...


What I have working:
* The spinner displays an EditText and I can type in it.
* I can add a textChangedListener to the EditText and receive updates
beautifully.
* If I register an OnItemSelectedListener on the spinner, I can update
the text field with the new selection  my textChangedListener will pick
it up.

What doesn't work:
* My EditText doesn't scale up to the size of it's parent spinner.
(Setting the layoutParams doesn't seem to help???
* When I change the selection via the spinner popup list, something
changes so that my EditText no longer receives the orange ring around it
when it has focus.  (I still get the flashing cursor and can edit fine,
it just loses the orange focus border)


Would any kind soles have any advice to offer?  Even any tips or
websites on what the philosophy behind this onMeasure, onLayout
philosophy is?  I can't seem to find any books/sites that talk about GUI
stuff that look any deeper than the xml.


My spinner class so far is below.

Cheers,

Peter.


class ApcSpinner extends Spinner implements SpinnerAdapter
{
protected EditText editText = null;
LayoutInflater inflater;
private final DataSetObservable observers = new
DataSetObservable();
ArrayListString options = new ArrayListString();

public ApcSpinner(Context c)
{
super(c);
for (int i=0; i  10; i++)
options.add(Record  + i);
inflater = (LayoutInflater)c.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);

editText = new EditText(c);
editText.setHorizontalFadingEdgeEnabled(true);
editText.setHorizontallyScrolling(true);
setStyle(editText);
if (style != null)
{
if (style.getBackgroundColour() != null)
setBackgroundColor(style.getBackgroundColour());
}

// Control ourselves...
setAdapter(this);
}

public int getCount()
{
return options.size();
}

public Object getItem(int position)
{
return options.get(position);
}

public long getItemId(int position)
{
return position;
}

public int getItemViewType(int position)
{
return 0;
}

public View getView(int position, View convertView, ViewGroup
parent)
{
return editText;
}

public View getDropDownView(int position, View convertView,
ViewGroup parent)
{
TextView textView;
if (convertView != null)
textView = (TextView)convertView;
else
textView = (TextView) inflater.inflate(
android.R.layout.simple_spinner_dropdown_item,
parent, false);
textView.setText(getItem(position).toString());
setStyle(textView);
return textView;
}

public int getViewTypeCount()
{
return 1;
}

public boolean hasStableIds()
{
return false;
}

public boolean isEmpty()
{
return options.size() == 0;
}

public void registerDataSetObserver(DataSetObserver observer)
{
observers.registerObserver(observer);
}

public void unregisterDataSetObserver(DataSetObserver observer)
{
observers.unregisterObserver(observer);
}
}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---