Good site for standard cookbook style examples - date pickers, etc.?

by Preston » Fri, 23 Apr 2010 08:02:08 GMT


Sponsored Links
 Right now I'm trying to find out what the most commonly used Android
date picker is. It seems to me that it's probably cumbersome to always
use the DatePicker proper. Just because of the size of it and the fact
that many people for a given date field would want to enter data
manually. So I'm thinking someone out there must have come up with a
pattern where you click on a TextEdit field and it brings up a modal
Activity with a DatePicker, after which it returns that value to the
previous Window. Anyone know of such a thing? Or better yet a site
where noobs such as myself can see examples in cookbook fashion and
work the rest out ourselves.

Thanks,

Preston

--



Other Threads

1. Error starting tools in 1.6 on Mac OS - SOLUTION

Hi,

I've been unable to run any of the tools in the Donut SDK, using Snow
Leopard - it seems to be due to the 64bit nature of the OS.

Followed the steps in the upgrade guide, but when it comes to starting
any of the tools (android, ddms etc), they refuse to start with the
error message:

"David-Horns-MacBook:tools David$ ./ddms
SWT folder '/Users/David/Desktop/Eclipse IDE/android-sdk-
mac_x86-1.6_r1/tools/lib/x86_64' does not exist.
Please export ANDROID_SWT to point to the folder containing swt.jar
for your platform."

There is no x86-64 folder, but I've come up with a bit of a bodge that
works.  Open the file in a handy text editor, and look for the lines:

# Combine the swtpath and the framework dir path.
if [ -d "$swtpath" ]; then
    frameworkdir="${swtpath}:${frameworkdir}"
else
    echo "SWT folder '${swtpath}' does not exist."
    echo "Please export ANDROID_SWT to point to the folder containing
swt.jar for your platform."
    exit 1
fi

Replace them with this, substituting your own path in to the lib
folder.

# Combine the swtpath and the framework dir path.
    frameworkdir="/Users/David/Desktop/Eclipse IDE/android-sdk-
mac_x86-1.6_r1/tools/lib/x86:${frameworkdir}"

Hope this helps (not sure if this is a problem unique to me, or
whether it's affecting everyone on Snow Leopard).

Dave.
--~--~---------~--~----~------------~-------~--~----~

2. Extending a view class

Hoi

I try to create my custom view inside a linearlayout. For example

<View  android:id="@+id/ViewPaint"
class="com.example.android.helloactivity.HelloActivity$DrawingView"/>

In the java source I created a DrawingView class which extends View.
Unfortunatly it does not get instantiated. I tried to overwrite the
ondraw() but without success :-(

Help is very much appreciated.
Jasper

Java Code
   public static class DrawingView extends View
    {
        private final Paint mPaint;
        /*
         * Constructor that is called when inflating a view from XML.
         */
        DrawingView(Context context, AttributeSet attrs){
                super(context,attrs);

            mPaint = new Paint();
            mPaint.setAntiAlias(true);
            mPaint.setARGB(255, 255, 255, 255);
        }

        @Override
        protected void onDraw(Canvas canvas) {
                float yPos;
                float xPos;
                int   xOffset = 20;
                int   yOffset = 50;
                int   cxScreen = canvas.getWidth();
                int   cyScreen = canvas.getHeight();
                int   cx = cxScreen - (2*xOffset);
                int   cy = cyScreen - (2*yOffset);
                int   cxStepSize = cx/10 - 1;
                int   cyStepSize = cy/10 - 1;

            // Makes the complete screen white!
            //canvas.drawColor(0xFFFFFFFF);
            yPos = (float)yOffset;
            xPos = (float)xOffset;
            for (int i=0; i <= 10; i++)
            {   // xstart, ystrt,xend,yend
                canvas.drawLine((float)xOffset, yPos, (float)cx, (float)
yPos, mPaint);
                yPos += cyStepSize;
            }
            for (int i=0; i <= 10; i++)
            {   // xstart, ystrt,xend,yend

                canvas.drawLine((float)xPos, (float)yOffset, (float)xPos,
(float)cy, mPaint);
                xPos += cxStepSize;
            }
        }
    }

XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
    android:orientation="vertical"
    android:padding="10dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dip"
        android:text="Please select a planet:"
    />

    <Spinner
        android:id="@+id/spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="true"
        android:prompt="@string/planet_prompt"
    />
     <TextView android:id="@+id/dateDisplay"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="No date yet"/>

       <Button android:id="@+id/pickDate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Change the date"/>

    <TextView android:id="@+id/timeDisplay"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="No time yet"/>

    <Button android:id="@+id/pickTime"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Verander the time"/>

<View  android:id="@+id/ViewPaint"
class="com.example.android.helloactivity.HelloActivity$DrawingView"/>
</LinearLayout>

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

3. Get the current assigned google account

4. Aplikasi lucu

5. Scroll image like a WebView

6. How to prematurely stop a long-running SQLite query?

7. The MultiBubbles Online tournament has started. Win prizes while playing MultiBubbles on your Android device!