Put some Log statement...

Look at the LogCat in debug mode ..u will get to know the error trace...

On Mon, Nov 3, 2008 at 10:59 AM, illiniwatcher <[EMAIL PROTECTED]>wrote:

>
> Hi, folks:
>
> I am really confused about Android at this point.  I'm writing a very
> simple application called "Counter" (a starting point) that uses a
> drawabl PNG image and no matter what I do, when I run it in the
> emulator, I get this annoying message:
>
> "Sorry! The application Counter (process mine.counter) has
> stopped unexpectedly. Please try again.  [Force close buttton]"
>
> All I want my application to do is to display a Drawable called
> "n0.png" which I have defined to my "rsc\drawable" folder.
>
> I've looked at other sample applications, including the ones in the
> SDK and tried emulating the coding, without success.  I'm very
> confused about how the Java, XML, and other files interact.  I just
> don't see why the program is freezing when I've practically followed
> the structure of other applications to the letter.
>
> Below, I've replicated the code.  Thanks for any help you can provide.
>
> Charles
>
> ***************
>
> FILE STRUCTURE
>
> Counter
>   res
>      drawable
>         n0.png
>      layout
>         bkcounter.xml
>         main.xml
>      values
>         colors.xml
>         strings.xml
>   src
>      mine
>         counter
>            Counter.java
>            CounterView.java
>            R.java
>
>
> In BKCOUNTER.XML:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!-- Demonstrates using a relative layout to create a form -->
> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>                android:layout_width="fill_parent"
>                android:layout_height="fill_parent"
>                android:padding="10px"
>                android:background="@color/blueback">
>
> <!-- My connection to the view; THIS TIES IN ANDROID CLASSES (!) -->
> <!-- "id" value will show up when using auto-complete -->
>
> <mine.counter.CounterView
>      android:id="@+id/cview"
>      android:layout_width="fill_parent"
>      android:layout_height="fill_parent" />
>
> <ImageView android:id="@+id/firstdigit"
> android:layout_height="fill_parent"
> android:layout_width="fill_parent"></ImageView>
>
> </FrameLayout>
>
>
> In MAIN.XML:
>
> <?xml version="1.0" encoding="utf-8"?>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>    android:orientation="vertical"
>    android:layout_width="fill_parent"
>    android:layout_height="fill_parent"
>    >
> <TextView
>    android:layout_width="fill_parent"
>    android:layout_height="wrap_content"
>    android:text="@string/hello"
>    />
> </LinearLayout>
>
>
> In COLORS.XML:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <resources>
>        <color name="blueback">#0071BC</color>
> </resources>
>
>
> In STRINGS.XML:
>
> <?xml version="1.0" encoding="utf-8"?>
> <resources>
>    <string name="hello">Hello World, Counter</string>
>    <string name="app_name">Counter</string>
> </resources>
>
>
> In COUNTER.JAVA:
>
> package mine.counter;
>
> import android.app.Activity;
> import android.content.DialogInterface;
> import android.content.DialogInterface.OnClickListener;
> import android.os.Bundle;
> import android.view.Window;
> import android.widget.ImageView;
> import android.widget.TextView;
>
> public class Counter extends Activity {
>
>
>        // MY CLASSES
>        private CounterView myCounterView;
>
>        // MY ELEMENTS
>
>
>    /** Called when the activity is first created. */
>    @Override
>    public void onCreate(Bundle savedInstanceState) {
>        super.onCreate(savedInstanceState);
>
>
>        setContentView(R.layout.bkcounter);             // this should
> always
> come first
>        myCounterView = (CounterView) findViewById(R.id.cview);
>
>    }
>
>
> }
>
>
> In COUNTERVIEW.JAVA:
>
> package mine.counter;
>
> import android.content.Context;
> import android.view.View;
> import android.graphics.Canvas;
> import android.graphics.drawable.Drawable;
>
>
> public class CounterView extends View {
>
>        private Drawable imgDigit0;
>
>
>        // CONSTRUCTOR FOR THIS CLASS - "NEW" INSTANCE
>
>        public CounterView(Context ctx) {
>                super(ctx);
>
>                // Set up all images
>                imgDigit0 = ctx.getResources().getDrawable(R.drawable.n0);
>
>                // Turn on focus
>                setFocusable(true);
>
>        }
>
>        @Override
>        protected void onDraw(Canvas canvas) {
>            super.onDraw(canvas);
>
>            imgDigit0.draw(canvas);
>
>        }
>
> }
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to