The Christmas-Calendar - A TableLayout with SubActivity

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Postby ronenfe » Wed Sep 10, 2008 8:10 pm

thank you plusminus, you helped me to narrow my number of errors to only one.
i used:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Toast.makeText(this,"Today is: " + dateString + "\n\t\tdon't cheat Wink",Toast.LENGTH_LONG).show();
  3.  
  4.  
  5.  
  6.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

instead of the notificationmanger, and i hope it will work, but i am still left with:
Description Resource Path Location Type
ERROR Error: No resource found that matches the given name attribute: 'android:normalTextColor' value: 'id'. styles.xml CristmasCalendar/res/values line 13 aapt Problem
it is strange because there are 2 lines similar to this with no problems in the same file:


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.         <item name="android:background">@color/door_background</item>
  3.  
  4.  <item name="android:textColor">@color/door_caption_color_selected</item>
  5.  
  6.         <item name="android:normalTextColor">@color/door_caption_color</item>
  7.  
  8.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4

the last line caused this error, altough i did change id to android:id in all locations.
ronenfe
Freshman
Freshman
 
Posts: 4
Joined: Tue Sep 09, 2008 5:12 pm

Top

Postby plusminus » Wed Sep 10, 2008 8:33 pm

ronenfe wrote:thank you plusminus, you helped me to narrow my number of errors to only one.
i used:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Toast.makeText(this,"Today is: " + dateString + "\n\t\tdon't cheat Wink",Toast.LENGTH_LONG).show();
  2.  
  3.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

instead of the notificationmanger, and i hope it will work, but i am still left with:
Description Resource Path Location Type
ERROR Error: No resource found that matches the given name attribute: 'android:normalTextColor' value: 'id'. styles.xml CristmasCalendar/res/values line 13 aapt Problem
it is strange because there are 2 lines similar to this with no problems in the same file:


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.         <item name="android:background">@color/door_background</item>
  2.  <item name="android:textColor">@color/door_caption_color_selected</item>
  3.         <item name="android:normalTextColor">@color/door_caption_color</item>
  4.  
Parsed in 0.001 seconds, using GeSHi 1.0.8.4

the last line caused this error, altough i did change id to android:id in all locations.


[font=Courier New]android:normalTextColor[/font] is gone since SDK-version since m5, so just delete that line. That should not change much, except the number on the 'door' might have the defaultcolor.

The "Toast"-line looks good.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

error in startActivityForResult(i, IMAGESUBACTIVITY_ID);

Postby hw3699 » Tue Sep 30, 2008 7:08 pm

Got an error when step through startActivityForResult(i, IMAGESUBACTIVITY_ID);
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. [2008-09-30 13:51:33 - ChristmasCalendar] Application already exists. Attempting to re-install instead...
  2.  
  3. [2008-09-30 13:51:35 - ChristmasCalendar] Success!
  4.  
  5. [2008-09-30 13:51:35 - ChristmasCalendar] Starting activity org.anddev.android.christmascalendar.ChristmasCalendar on device
  6.  
  7. [2008-09-30 13:51:36 - ChristmasCalendar] ActivityManager: Starting: Intent { comp={org.anddev.android.christmascalendar/org.anddev.android.christmascalendar.ChristmasCalendar} }
  8.  
  9. [2008-09-30 13:51:36 - ChristmasCalendar] Attempting to connect debugger to 'org.anddev.android.christmascalendar' on port 8624
Parsed in 0.036 seconds, using GeSHi 1.0.8.4



how to resolve it?
hw3699
Freshman
Freshman
 
Posts: 3
Joined: Tue Sep 30, 2008 7:03 pm

Postby plusminus » Tue Sep 30, 2008 10:25 pm

Hi hw3699,

that line of code does not seem to be the problem (at least as I can see it from here ;) ).

Does debugging work at all :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

The debugger is working for other samples.

Postby hw3699 » Wed Oct 01, 2008 3:32 pm

The ChrismasCalender.java is followed:


package org.anddev.android.christmascalendar;

import android.app.Activity;
// import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
// import android.util.DateUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class ChristmasCalendar extends Activity {

// Just random unique ints!
public static final int NOTIFICATION_ID = 0x1337;
public static final int IMAGESUBACTIVITY_ID = 0x7331;

public static final String DRAWABLE_RESID_MARKER = "DRAWABLE_RESID_MARKER";
public static final String CAPTION_TO_SHOW_MARKER = "CAPTION_TO_SHOW_MARKER";

public OnClickListener myOcl = new OnClickListener(){
// @Override
public void onClick(View aView) {
/* It definitely was a button that was
* clicked, as we assigne only Buttons
* to this OnClickListener */
Button clickedButton = (Button)aView;
String buttonCaption = clickedButton.getText().toString();
Integer buttonNumber = Integer.parseInt(buttonCaption);

int drawableResID = 0;
switch(buttonNumber){
case 1: drawableResID = R.drawable.door_1; break;
case 2: drawableResID = R.drawable.door_2; break;
case 3: drawableResID = R.drawable.door_3; break;
case 4: drawableResID = R.drawable.door_4; break;
case 5: drawableResID = R.drawable.door_5; break;
case 6: drawableResID = R.drawable.door_6; break;
case 7: drawableResID = R.drawable.door_7; break;
case 8: drawableResID = R.drawable.door_8; break;
case 9: drawableResID = R.drawable.door_9; break;
case 10: drawableResID = R.drawable.door_10; break;
case 11: drawableResID = R.drawable.door_11; break;
case 12: drawableResID = R.drawable.door_12; break;
case 13: drawableResID = R.drawable.door_13; break;
case 14: drawableResID = R.drawable.door_14; break;
case 15: drawableResID = R.drawable.door_15; break;
case 16: drawableResID = R.drawable.door_16; break;
case 17: drawableResID = R.drawable.door_17; break;
case 18: drawableResID = R.drawable.door_18; break;
case 19: drawableResID = R.drawable.door_19; break;
case 20: drawableResID = R.drawable.door_20; break;
case 21: drawableResID = R.drawable.door_21; break;
case 22: drawableResID = R.drawable.door_22; break;
case 23: drawableResID = R.drawable.door_23; break;
case 24: drawableResID = R.drawable.door_24; break;
}

/* This Intent will start the Viewing
* of the image behind the door later */
Intent i = new Intent(ChristmasCalendar.this, ImageDisplayer.class);

/* We want to send two extra-datasets
* (the ResID of the Drawable and some text)
* to our ImageDisplayer */
// A Bundle is just like a pimped HashMap
Bundle myExtras = new Bundle(2);
// Add those to extra datasets
myExtras.putString(CAPTION_TO_SHOW_MARKER, "Behind door " + buttonCaption + " is...");
myExtras.putInt(DRAWABLE_RESID_MARKER, drawableResID);

/* Assign the Bundle to the Intent.
* The Intent will 'carry' it to the
* SubActivity, where we will read the values back */
i.putExtras(myExtras);

// We use SUB_ACTIVITY_REQUEST_CODE as an 'identifier'
startActivityForResult(i, IMAGESUBACTIVITY_ID);

}
};





/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.calendar_layout);


// Apply the Button-Listener to all Buttons from the xml-file
applyListenerToButtons(myOcl);

}

private void applyListenerToButtons(OnClickListener aOcl){
// 1 to 10
findViewById(R.id.cmd_door_1).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_2).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_3).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_4).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_5).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_6).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_7).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_8).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_9).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_10).setOnClickListener(aOcl);
// 11 to 20
findViewById(R.id.cmd_door_11).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_12).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_13).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_14).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_15).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_16).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_17).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_18).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_19).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_20).setOnClickListener(aOcl);
// 21 to 24
findViewById(R.id.cmd_door_21).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_22).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_23).setOnClickListener(aOcl);
findViewById(R.id.cmd_door_24).setOnClickListener(aOcl);
}
}



It died after I click on the number. Can you please check and let me know what happened? Thanks!
hw3699
Freshman
Freshman
 
Posts: 3
Joined: Tue Sep 30, 2008 7:03 pm

Re: The debugger is working for other samples.

Postby hw3699 » Wed Oct 01, 2008 3:49 pm

The problem solved. Thanks! I added Imagedisplayer as activity in AndroidManifest.xml.
hw3699
Freshman
Freshman
 
Posts: 3
Joined: Tue Sep 30, 2008 7:03 pm

Top

Re: The Christmas-Calendar - A TableLayout with SubActivity

Postby aviundefined » Tue Oct 26, 2010 12:15 pm

Are the calendar API is public???
aviundefined
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Jul 22, 2010 1:08 pm

Top
Previous

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 6 guests