Looking for an example of using state with a custom control

by dm1973 » Sat, 14 Mar 2009 15:55:52 GMT


Sponsored Links
 I am writing a custom widget and would like to use   setState and the
like to handle the focus and pressed states. Is there any sample code
explaining how to do this?
--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. switch to another applications programmatically

First of all, don't use am.  All it does is call startActivity() from its
own environment, so you have just made things 10x harder for yourself,
impossible to actually integrate with your UI flow, likely to break in the
future, and not gotten to do anything more than startActivity() does.
Second, when you start an activity, it starts out at the top of its stack,
and its window has focus.  You don't need to do anything special.  I don't
know what you are doing to cause this behavior, but simply calling
startActivity() from your own activity will work.

Third, please be sure you read the application fundamentals documentation:
http://developer.android.com/guide/topics/fundamentals.html






-- 
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.

--~--~---------~--~----~------------~-------~--~----~

2. NullPointer using default ArrayAdapter

Hello,

My following code does an exception when I'm trying to display the
dropdownview. I uses the default standard object ArrayAdapter
displaying string...but there is an issue that I can't resolve. I
tried a lot of thing...So maybe i'm tired or i don't understand
something somewhere!

Thanks for your help

mRegions is an array of String, not null.
mSpinnerRegions is my spinner view.

ArrayAdapter<String> adapterRegion = new ArrayAdapter<String>(this,
                                android.R.layout.simple_spinner_item, mRegions);
                adapterRegion
                                .setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
                mSpinnerRegions.setAdapter(adapterRegion);

Exception
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):
java.lang.NullPointerException
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:
351)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.ArrayAdapter.getDropDownView(ArrayAdapter.java:371)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.Spinner$DropDownAdapter.getDropDownView(Spinner.java:
314)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.Spinner$DropDownAdapter.getView(Spinner.java:310)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.AbsListView.obtainView(AbsListView.java:1251)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.ListView.measureHeightOfChildren(ListView.java:1117)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.ListView.onMeasure(ListView.java:1030)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.View.measure(View.java:7115)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:
888)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.View.measure(View.java:7115)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:
888)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.LinearLayout.measureVertical(LinearLayout.java:350)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.LinearLayout.onMeasure(LinearLayout.java:278)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.View.measure(View.java:7115)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.View.measure(View.java:7115)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2875)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.View.measure(View.java:7115)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.ViewRoot.performTraversals(ViewRoot.java:698)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.view.ViewRoot.handleMessage(ViewRoot.java:1482)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.os.Handler.dispatchMessage(Handler.java:99)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.os.Looper.loop(Looper.java:123)
09-13 15:13:21.795: ERROR/AndroidRuntime(12503):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
--~--~---------~--~----~------------~-------~--~----~

3. Split Method

4. Device info API

5. How can I add genre info into artist a nd album list鈥

6. PMEM device

7. Basic App -- not working