[android-developers] Dynamic array ListView problem

2011-02-02 Thread sisko
Hi guys,

I am experimenting with locations and listviews. I am getting location
results back and I am trying to create a listview of my locations
results using the following code:

ListView locationList   =   
(ListView)findViewById(R.id.ListView01);
String[] items = new String[]{};

try {
Geocoder geocoder   =   new 
Geocoder(this, Locale.getDefault());
List addresses =   
geocoder.getFromLocation(LATITUDE,
LONGITUDE, 5);
address_textview.setText( ""+addresses );

Address[] addresses_array   =   new 
Address[addresses.size()];
addresses.toArray(addresses_array);

for( int i = 0; i < addresses_array.length; i++ ){
items[i]=   
addresses_array[i].getPostalCode();
}

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

ArrayAdapter adapter=   new 
ArrayAdapter(this,
R.layout.list_item, items);
locationList.setAdapter(adapter);

My problem is, when I try to write into my items array ( items[i]   =
addresses_array[i].getPostalCode(); )  in the forloop, my application
crashes.

Can anyone please help. I am stuck at this point.

-- 
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: Eclipse ADT update ruins XML layout files development

2011-01-07 Thread sisko

Thanks for all you help.

ADT 9 helps with the up and down positioning stuff and CNTL + SHIFT F
also helps organizing  the code for manual editing
On Jan 4, 2:10 am, Julian  wrote:
> Try the preview version of adt 9, it has the up and downs arrows.
>
> http://tools.android.com/download
>
> 2011/1/3 sisko 
>
> > I am a beginner and I am having trouble getting accurate results hand-
> > coding the XML but I will give it a shot.
>
> > Thanks.
>
> > On Jan 4, 1:45 am, John Lussmyer  wrote:
> > > Use the xml tab and edit the xml directly.
> > > MUCH easier.
> > > Also helps if you use ctrl-F to reformat the XML to be legible.  (I also
> > > change the XML formatting preferences to put each attribute on a new
> > line.)
>
> > > On Mon, Jan 3, 2011 at 5:38 PM, sisko  wrote:
> > > > Thanks for responding.
>
> > > > If you mean we are supposed to drag elements into place, I got ta
> > > > say ... It simply does not work.
>
> > > > I have an existing project with a very complex layout in one of my
> > > > views. Any attempt to reorganize the layout by dragging things around
> > > > ends in disaster.
>
> > > > Please help. Important projects are on hold until I can convinitenly
> > > > do comple layouts again.
>
> > --
> > 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] Re: Eclipse ADT update ruins XML layout files development

2011-01-03 Thread sisko
I am a beginner and I am having trouble getting accurate results hand-
coding the XML but I will give it a shot.

Thanks.

On Jan 4, 1:45 am, John Lussmyer  wrote:
> Use the xml tab and edit the xml directly.
> MUCH easier.
> Also helps if you use ctrl-F to reformat the XML to be legible.  (I also
> change the XML formatting preferences to put each attribute on a new line.)
>
> On Mon, Jan 3, 2011 at 5:38 PM, sisko  wrote:
> > Thanks for responding.
>
> > If you mean we are supposed to drag elements into place, I got ta
> > say ... It simply does not work.
>
> > I have an existing project with a very complex layout in one of my
> > views. Any attempt to reorganize the layout by dragging things around
> > ends in disaster.
>
> > Please help. Important projects are on hold until I can convinitenly
> > do comple layouts again.

-- 
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: Eclipse ADT update ruins XML layout files development

2011-01-03 Thread sisko
Thanks for responding.

If you mean we are supposed to drag elements into place, I got ta
say ... It simply does not work.

I have an existing project with a very complex layout in one of my
views. Any attempt to reorganize the layout by dragging things around
ends in disaster.

Please help. Important projects are on hold until I can convinitenly
do comple layouts again.

On Jan 3, 10:29 pm, TreKing  wrote:
> On Mon, Jan 3, 2011 at 4:26 PM, sisko  wrote:
> > Can anyone please help me. My eclipse update has removed the very vital
> > control elements on the outline tab (shown here
> >http://www.mathcs.org/java/android/images/xml_converter_outline.jpg).I am
> > referring to the plus, minus, up and down arrow buttons.
>
> I believe this was intentional as the new tool is supposed to rely on
> drag-n-drop.
>
> See here for more info:http://tools.android.com/download
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

-- 
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: Eclipse ADT update ruins XML layout files development

2011-01-03 Thread sisko
Can anyone please help me. My eclipse update has removed the very
vital control elements on the outline tab (shown here
http://www.mathcs.org/java/android/images/xml_converter_outline.jpg
).I am referring to the plus, minus, up and down arrow buttons.

On Jan 3, 2:23 pm, sisko  wrote:
> Don't know what happened. Here is the image link again 
> -http://www.mathcs.org/java/android/images/xml_converter_outline.jpg
>
> On Jan 3, 3:05 am, sisko  wrote:
>
> > This image (http://www.mathcs.org/java/android/images/
> > xml_converter_outline.jpg) shows what I am refering to.
>
> > The update has removed all the images and associated functionality for
> > the plus, minus, up and down buttons on the outline tab.
>
> > On Jan 2, 8:19 pm, sisko  wrote:
>
> > > I recently updated my eclipse installation with which I develop my
> > > Android apps.
> > > Soon I found my layout files have lost the up and down arrows
> > > associated with each VIEW and LAYOUT which helps to organize my
> > > layouts.
>
> > > I don't know whatelse the update, if anything, has messed up but I
> > > wonder and would appreciate any information on how to fix this issue
> > > so I can get my developments back on track, please.
>
> > > Thanks

-- 
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: Eclipse ADT update ruins XML layout files development

2011-01-03 Thread sisko
Don't know what happened. Here is the image link again -
http://www.mathcs.org/java/android/images/xml_converter_outline.jpg

On Jan 3, 3:05 am, sisko  wrote:
> This image (http://www.mathcs.org/java/android/images/
> xml_converter_outline.jpg) shows what I am refering to.
>
> The update has removed all the images and associated functionality for
> the plus, minus, up and down buttons on the outline tab.
>
> On Jan 2, 8:19 pm, sisko  wrote:
>
> > I recently updated my eclipse installation with which I develop my
> > Android apps.
> > Soon I found my layout files have lost the up and down arrows
> > associated with each VIEW and LAYOUT which helps to organize my
> > layouts.
>
> > I don't know whatelse the update, if anything, has messed up but I
> > wonder and would appreciate any information on how to fix this issue
> > so I can get my developments back on track, please.
>
> > Thanks

-- 
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: Eclipse ADT update ruins XML layout files development

2011-01-02 Thread sisko
This image (http://www.mathcs.org/java/android/images/
xml_converter_outline.jpg) shows what I am refering to.

The update has removed all the images and associated functionality for
the plus, minus, up and down buttons on the outline tab.

On Jan 2, 8:19 pm, sisko  wrote:
> I recently updated my eclipse installation with which I develop my
> Android apps.
> Soon I found my layout files have lost the up and down arrows
> associated with each VIEW and LAYOUT which helps to organize my
> layouts.
>
> I don't know whatelse the update, if anything, has messed up but I
> wonder and would appreciate any information on how to fix this issue
> so I can get my developments back on track, please.
>
> Thanks

-- 
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] Eclipse ADT update ruins XML layout files development

2011-01-02 Thread sisko
I recently updated my eclipse installation with which I develop my
Android apps.
Soon I found my layout files have lost the up and down arrows
associated with each VIEW and LAYOUT which helps to organize my
layouts.

I don't know whatelse the update, if anything, has messed up but I
wonder and would appreciate any information on how to fix this issue
so I can get my developments back on track, please.

Thanks

-- 
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] OOP objects + complex view

2010-12-22 Thread sisko
Hi guys,

I am developing an app that need to display information on the stock
of a store. Each activity will have upto 100 items.

My plan is to layout this information in a 10 * 10 grid. Each box in
the grid represents an item of stock. Each of these items will be
represented by an icon and a piece of text beneath the icon (the
name). I setup a new layout which has an ImageView and a TextView for
this. I called the layout Tab.xml

So, I need to know if it is possible to write a java class which will
use the Tab.xml as the layout.
Then I can programmatically create each java class item, setting the
image and text as I go along.

Can anyone please give me some direction about this?

-- 
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] DatePickerDialog onDateSet crashes my code

2010-11-13 Thread sisko
I am trying to get my first DatePickerDialog working but bizarrely,
the app keeps crashing just as my onDateSet() function is encountered.

My code is below:
protected Dialog onCreateDialog(int id){
//super.onCreateDialog(id);

Log.e("TRACKING", "Just outside onDateSet()");

switch(id){
case DATE_DIALOG_ID:
Log.e("TRACKING", "entering onDateSet()");
final TextView dob  =   
(TextView)findViewById(R.id.DOB);

Log.e("TRACKING", "reaching#1");

DatePickerDialog dateDialog =   
new DatePickerDialog(this, new
DatePickerDialog.OnDateSetListener() {

@Override
public void 
onDateSet(DatePicker view, int year,
int 
monthOfYear, int dayOfMonth) {
// TODO Auto-generated 
method stub

}

/*...@override
public void 
onDateSet(DatePicker view, int year, int
monthOfYear, int dayOfMonth){
Log.e("TRACKING", 
"reaching#2");
// TODO Auto-generated 
method stub
Time dateOfBirth
=   new Time();

dateOfBirth.set(dayOfMonth, monthOfYear, year);
long dtDob  
=   dateOfBirth.toMillis(true);

dob.setText(DateFormat.format(" dd ", dtDob));

Editor editor   =   
mGameSettings.edit();

editor.putLong(GAME_PREFERENCES_DOB, dtDob);
editor.commit();
}

}, 0, 0, 0);
Log.e("TRACKING", "end of onDateSet()");
return dateDialog;

//return new DatePickerDialog(this, 
mDateSetListener, 0, 0,
0);


default:
break;
}

return null;

}

As normal, I call my dialog by showDialog(DATE_DIALOG_ID);

The log message Log.e("TRACKING", "reaching#2"), is never logged.

Please 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] Re: Fetch Spinner value outside setOnItemSelectedListener

2010-11-12 Thread sisko
Tried your suggestion and it's worked.

Sorry for wasting your time. I'm a newbie following what has turned
out to be a flawed tutorial.

Thanks for your patience and help.

On Nov 12, 3:29 pm, TreKing  wrote:
> On Fri, Nov 12, 2010 at 5:05 AM, sisko  wrote:
> > So the input is set in a sharedpreference and writing that value back into
> > the EditView whenever the activity is "restarted".
>
> Then just do the same thing with the index of the spinner.
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

-- 
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: Fetch Spinner value outside setOnItemSelectedListener

2010-11-12 Thread sisko
Hey, thanks for the clarification.

As for the EditViews, I am using the following code:

final EditText input_field  =   (EditText) findViewById(editViewINT);
if( mGameSettings.contains(preference) ){
input_field.setText( 
mGameSettings.getString(preference, "does not
exist") );
//Toast.makeText(QuizSettingsActivity.this, "Exists 
with value : "
+ input_field.getText() , Toast.LENGTH_SHORT ).show();
}

/*
 * implementing the nickname input
 */

input_field.setOnKeyListener( new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, 
KeyEvent event) {
// TODO Auto-generated method stub

String processed_input  =   
input_field.getText().toString();
Editor editor   =   
mGameSettings.edit();
editor.putString(preference, 
processed_input);
editor.commit();


//Toast.makeText(QuizSettingsActivity.this, "checking :
"+preference, Toast.LENGTH_SHORT ).show();

return false;
}

});

}

So the input is set in a sharedpreference and writing that value back
into the EditView whenever the activity is "restarted".

On Nov 12, 2:39 am, TreKing  wrote:
> On Thu, Nov 11, 2010 at 5:35 PM, sisko  wrote:
> > Then click the "menu" button on the phone. It should give you 2 options (
> > Settings and Help ).
> > Please select "setting". The view will reload.
>
> AFAICT, you're not "reloading", you're starting a new instance of the same
> activity (if you press back, the previous instance is shown, with what you
> had selected in it's drop down).
>
> I think you're confused in thinking that the spinner in the second activity
> is the same as the spinner in the first activity. It's not.
>
> What are you doing right now to save and restore the EditText values? You
> can probably do something similar for this.
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

-- 
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: Fetch Spinner value outside setOnItemSelectedListener

2010-11-11 Thread sisko
Hi,

thanks for your continued assistance.

Perhaps it would be better if you saw my app in action.
Would you mind downloading it from 
http://www.icerge.com/sites/default/files/TriviaQuiz.tar_.gz

It's harmless and only takes text input and remembers them when the
app is closed and reopened ( reload the activity ).

The first two EditText fields will take some input and remember that
input for the next visit. ( Please ignore the 2 following buttons ).

The spinner is right at the bottom of the view. Open it and select any
option.

Then click the "menu" button on the phone. It should give you 2
options ( Settings and Help ).
Please select "setting". The view will reload.

Whatever input you may have put into the 2 EditViews at the top are
retained but not the previously selected value on the spinner - which
is what I have been trying to deal with.

On Nov 11, 3:32 pm, TreKing  wrote:
> On Thu, Nov 11, 2010 at 8:33 AM, sisko  wrote:
> > simply put, when I revisit the current "page" by touching the menu linking
> > to the same view
>
> I'm not following.
>
> Could you describe the sequence of steps you take in your app and where the
> activities start and end?
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

-- 
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: Fetch Spinner value outside setOnItemSelectedListener

2010-11-11 Thread sisko
> What do you mean by "when the activity is re-loaded" ?

simply put, when I revisit the current "page" by touching the menu
linking to the same view

On Nov 10, 8:16 pm, TreKing  wrote:
> On Wed, Nov 10, 2010 at 1:52 PM, sisko  wrote:
> > But, the very next line I am using the same function call but my
> > spinner does not set to the previously selected value when the
> > activity is re-loaded.
>
> > However, if I simply give spinner.selection a static argument, e:g 2, it
> > works fine upon re-loading the activity.
>
> What do you mean by "when the activity is re-loaded" ?
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

-- 
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: Fetch Spinner value outside setOnItemSelectedListener

2010-11-10 Thread sisko
Thanks for responding. I have the following code:

final Spinner spinner   =   (Spinner)findViewById(R.id.Spinner_gender);

spinner.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
public void 
onItemSelected(AdapterView parent, View
itemSelected, int selectedItemPosition, long selected){
Editor editor   =   
mGameSettings.edit();

editor.putLong(GAME_PREFERENCES_GENDER,
selectedItemPosition);
editor.commit();
}

@Override
public void 
onNothingSelected(AdapterView arg0) {
// TODO Auto-generated 
method stub

}

}
);

ArrayAdapter adapter =   
ArrayAdapter.createFromResource(this,
spinnerID, android.R.layout.simple_spinner_item);
 
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
if( mGameSettings.contains(GAME_PREFERENCES_GENDER) ){
Toast.makeText(QuizSettingsActivity.this, 
"Detected(again): " +
spinner.getSelectedItemPosition(), Toast.LENGTH_SHORT).show();
spinner.setSelection( spinner.getSelectedItemPosition() 
);
}

Towards the end, I am checking that a sharedPreference value is set
and simply printing the selectedIndex in my Toast.
But, the very next line I am using the same function call but my
spinner does not set to the previously selected value when the
activity is re-loaded.

However, if I simply give spinner.selection a static argument, e:g 2,
it works fine upon re-loading the activity.

I don't know why it won't work ... please help!

On Nov 10, 5:47 pm, TreKing  wrote:
> On Tue, Nov 9, 2010 at 5:58 PM, sisko  wrote:
> > Please enlighten me as to why the getSelectedItemPosition() function
> > displays the currently selected value in my toast but
> > as I try using it in my seSelection call, my spinner never sets to the
> > value confirmed in my above toast ?
>
> This doesn't make sense. If getSelectedItemPosition returns the correct
> selected value, then calling setSelection() with that value will have no
> effect and the spinner will not change because you're already on the correct
> item, so how is it that the spinner "never sets to the value confirmed"?
>
> I think you need to elaborate.
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

-- 
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: Fetch Spinner value outside setOnItemSelectedListener

2010-11-09 Thread sisko
Hey, please do excuse my ignorance.

Based on you very suggestion, I wrote the following code :

Toast.makeText(QuizSettingsActivity.this, "Detected(again): " +
spinner.getSelectedItemPosition(), Toast.LENGTH_SHORT).show();
spinner.setSelection( spinner.getSelectedItemPosition() );

Please enlighten me as to why the getSelectedItemPosition() function
displays the currently selected value in my toast but
as I try using it in my seSelection call, my spinner never sets to the
value confirmed in my above toast ?

I also tried assigning the getSelectedItemPosition() return value to a
variable and giving it to the toast and the setSelection function as
well as casting
the return value to an integer .. didn't resolve my problem.

Please help me!

On Nov 7, 11:12 pm, Mark Murphy  wrote:
> On Sun, Nov 7, 2010 at 6:09 PM,sisko wrote:
> > Hi guys,
>
> > I have a spinner successfully working but I am trying to use the
> > spinner.setSelection method to "remember" the previous spinner value
> > when the activity is reloaded.
>
> > Outside of setOnItemSelectedListener, is there a function of the
> > spinner that can give me the selected index?
>
> getSelectedItemPosition()
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 3.2 Available!

-- 
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: Fetch Spinner value outside setOnItemSelectedListener

2010-11-08 Thread sisko
Thanks A.Elk

On Nov 8, 6:15 pm, "A. Elk"  wrote:
> In the Android 2.2 SDK there's a sample app (new for 2.2) called
> "Spinner" that demonstrates how to do this using SharedPreferences. It
> will save the state of the spinner across pause() and resume(), and
> also across app shutdown and restart.
>
> Even better, it comes with a test package project called SpinnerTest
> that demonstrates the unit test for this.
>
> And best of all, the Activity Testing tutorial uses this app and its
> test package to demonstrate unit testing in Android.
>
> Enjoy!
>
> The Elk
>
> On Nov 7, 3:09 pm,sisko wrote:
>
> > Hi guys,
>
> > I have a spinner successfully working but I am trying to use the
> > spinner.setSelection method to "remember" the previous spinner value
> > when the activity is reloaded.
>
> > Outside of setOnItemSelectedListener, is there a function of the
> > spinner that can give me the selected index?
>
> > The following code is my function code to both setup the spinner and
> > then my attempt to set the spinner with the index previously selected:
>
> > private void setSpinner(int spinnerID){
> >                 final Spinner spinner   =
> > (Spinner)findViewById(R.id.Spinner_gender);
> >                 int spinner_value;
>
> >                 spinner.setOnItemSelectedListener(
> >                                 new AdapterView.OnItemSelectedListener() {
> >                                         public void 
> > onItemSelected(AdapterView parent, View
> > itemSelected, int selectedItemPosition, long selected){
> >                                                 spinner_value   =       
> > selectedItemPosition;
> >                                                 Editor editor   =       
> > mGameSettings.edit();
> >                                                 
> > editor.putLong(GAME_PREFERENCES_GENDER,
> > selectedItemPosition);
> >                                                 editor.commit();
> >                                                 
> > Toast.makeText(QuizSettingsActivity.this, "selected:
> > "+GAME_PREFERENCES_GENDER+"("+ spinner_value +")",
> > Toast.LENGTH_SHORT).show();
> >                                         }
>
> >                                                 @Override
> >                                                 public void 
> > onNothingSelected(AdapterView arg0) {
> >                                                         // TODO 
> > Auto-generated method stub
>
> >                                                 }
>
> >                                         }
> >                 );
>
> >                 ArrayAdapter adapter   =       
> > ArrayAdapter.createFromResource(this,
> > spinnerID, android.R.layout.simple_spinner_item);
>
> > adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_it 
> > em);
> >                 spinner.setAdapter(adapter);
> >                 if( mGameSettings.contains(GAME_PREFERENCES_GENDER) ){
> >                         spinner.setSelection(spinner_value);
> >                 }
>
> >         }
>
> > All I am trying to do here is use spinner_value to remember the
> > selected index so I can set the spinner to that index.
> > However, the spinner_value is never holding the desired value at
> > spinner.setSelection(spinner_value); in the last lines of code

-- 
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: Fetch Spinner value outside setOnItemSelectedListener

2010-11-08 Thread sisko
Thanks Mark.

On Nov 7, 11:12 pm, Mark Murphy  wrote:
> On Sun, Nov 7, 2010 at 6:09 PM,sisko wrote:
> > Hi guys,
>
> > I have a spinner successfully working but I am trying to use the
> > spinner.setSelection method to "remember" the previous spinner value
> > when the activity is reloaded.
>
> > Outside of setOnItemSelectedListener, is there a function of the
> > spinner that can give me the selected index?
>
> getSelectedItemPosition()
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 3.2 Available!

-- 
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] Fetch Spinner value outside setOnItemSelectedListener

2010-11-07 Thread sisko
Hi guys,

I have a spinner successfully working but I am trying to use the
spinner.setSelection method to "remember" the previous spinner value
when the activity is reloaded.

Outside of setOnItemSelectedListener, is there a function of the
spinner that can give me the selected index?

The following code is my function code to both setup the spinner and
then my attempt to set the spinner with the index previously selected:

private void setSpinner(int spinnerID){
final Spinner spinner   =
(Spinner)findViewById(R.id.Spinner_gender);
int spinner_value;


spinner.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
public void 
onItemSelected(AdapterView parent, View
itemSelected, int selectedItemPosition, long selected){
spinner_value   =   
selectedItemPosition;
Editor editor   =   
mGameSettings.edit();

editor.putLong(GAME_PREFERENCES_GENDER,
selectedItemPosition);
editor.commit();

Toast.makeText(QuizSettingsActivity.this, "selected:
"+GAME_PREFERENCES_GENDER+"("+ spinner_value +")",
Toast.LENGTH_SHORT).show();
}

@Override
public void 
onNothingSelected(AdapterView arg0) {
// TODO Auto-generated 
method stub

}

}
);

ArrayAdapter adapter =   
ArrayAdapter.createFromResource(this,
spinnerID, android.R.layout.simple_spinner_item);
 
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
if( mGameSettings.contains(GAME_PREFERENCES_GENDER) ){
spinner.setSelection(spinner_value);
}

}

All I am trying to do here is use spinner_value to remember the
selected index so I can set the spinner to that index.
However, the spinner_value is never holding the desired value at
spinner.setSelection(spinner_value); in the last lines of code

-- 
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: Remembering Shared Preferences

2010-11-07 Thread sisko
Hey Kostya,

thank you very much for your patience and your suggestion.

You were correct and that's helped me move my project along.

Thanks again.

On Nov 4, 2:10 pm, Kostya Vasilyev  wrote:
> It seems that the place where you are trying to restore the value from a
> Settings object is not the right place.
>
> You placed it into the edit text's click handler, whereas it should be
> outside of that - presumably, your onCreate function.
>
> --
> Kostya Vasilyev --http://kmansoft.wordpress.com
>
> 04.11.2010 16:58 пользователь "TreKing"  написал:
>
> On Thu, Nov 4, 2010 at 6:01 AM, sisko  wrote:
>
> > PLEASE - download my small sam...
>
> Sorry, I don't have time for that.
>
> Are you stepping through the debugger to see what's going on?
> Are you sure you want to set the text value when the user clicks the
> EditText and not, say, when the Settings screen is first started?
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers"...

-- 
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: Remembering Shared Preferences

2010-11-04 Thread sisko
Really sorry my message was not very detailed. I'm learning Androis
and so I confused about a number of things.

PLEASE - download my small sample app from here :
http://www.icerge.com/sites/default/files/TriviaQuiz.rar

When you start the app you will see the "View Scores" screen, hit the
"menu" button and select "settings".
The "settings" activity is where the problem is.

Now, the nickname EditText is where the problem is. As I understand
it, when you enter text and hit return, the code is supposed to check
if
GAME_PREFERENCES_NICKNAME is set. If it isn't, it is set in the
SharedPreferences and if it was previously set output it into the
EditText box.

So, I enter a nickname and hit return but the text reverts to "INPUT
NICKNAME" which was the temporaying in EditText label.
Also, when I press menu and settings again, my previous entry is not
in the EditText box as I expect it to be.

The code is in QuizSettingsActivity.java, the SharedPrefernces
information is set in QuizActivity.java and the layout is
settings.xml.

I would really appreciate your help. I am a bit lost.

Thanks.


On Nov 2, 9:47 pm, TreKing  wrote:
> On Tue, Nov 2, 2010 at 4:34 PM, sisko  wrote:
> > The problem is, when I revisit the activity, the EditView never contains
> > the text I input the last time.
>
> What do you mean "when you revisit"? What are the steps involved in the
> problem you're seeing?
>
> > I actually contains the above TextView content and I can't then edit it.
>
> What TextView? Can't edit what? The EditText or this TextView?
>
> >  I know that's not really clear but does anyone have any ideas to help with
> > seting and retrieving shared preferences properly ??
>
> Check to make sure your value exists somewhere else in your code and just
> write it out to the log to make sure.
>
> -
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices

-- 
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] Remembering Shared Preferences

2010-11-02 Thread sisko
Hi guys,

I am using the following code to set the input from an EditView in a
SharePreference.
But I am also trying to read the input back into the EditView.

final EditText input_nickname   =   (EditText)
findViewById(R.id.EditText_Nickname);
input_nickname.setOnKeyListener( new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, 
KeyEvent event) {
// TODO Auto-generated method stub
if( 
mGameSettings.contains(GAME_PREFERENCES_NICKNAME) ){

Toast.makeText(QuizSettingsActivity.this, "Exists",
Toast.LENGTH_SHORT ).show();

input_nickname.setText( mGameSettings.getString(GAME_PREFERENCES_NICKNAME,
"") );
}else{
String processed_nickname   
=   input_nickname.getText().toString();

Toast.makeText(QuizSettingsActivity.this, "Not Exists",
Toast.LENGTH_SHORT ).show();
Editor editor   =   
mGameSettings.edit();

editor.putString(GAME_PREFERENCES_NICKNAME, processed_nickname);
editor.commit();
}
return false;
}

});

The problem is, when I revisit the activity, the EditView never
contains the text I input the last time. I actually contains the above
TextView content and I can't then edit it.

I know that's not really clear but does anyone have any ideas to help
with seting and retrieving shared preferences properly ??

-- 
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 visibility problem

2010-10-20 Thread sisko
I had began with the layout_width set to wrap_content but it did not
have the desired effect.
I'll admit I don't fully understand the layout concepts so I'm
experienting alot.

Any good material that can bring me up to speed is welcome, please!

On 19 Oct, 15:50, letlite  wrote:
> The default orientation for LinearLayout is horizontal. It looks odd
> that the last TextView view has android:layout_width="fill_parent".
>
> On Oct 18, 2:43 pm,sisko wrote:
>
> > Hi guys,
>
> > the code I pasted below works great with the exception of the last
> > view - the textView.
>
> > The TextView does not display:
>
> >  >         xmlns:android="http://schemas.android.com/apk/res/android";
> >         android:id="@+id/LinearLayout01"
> >         android:background="@drawable/bkgrnd"
> > android:layout_height="fill_parent"
> > android:layout_width="fill_parent">
> >          >                 android:id="@+id/RelativeLayout01"
> >                 android:layout_width="wrap_content"
> > android:layout_height="wrap_content">
> >                          >                                 android:id="@+id/ImageView01"
> >                                 android:layout_width="wrap_content"
> >                                 android:layout_height="wrap_content"
> >                                 android:background="@drawable/quizicon"
> >                                 android:layout_alignParentLeft="true"
> >                                 android:layout_alignParentTop="true">
> >                         
> >                          >                                 android:id="@+id/TextView01"
> >                                 android:layout_width="wrap_content"
> >                                 android:layout_height="wrap_content"
> >                                 android:text="@string/help"
> >                                 android:layout_alignParentTop="true"
> >                                 android:layout_centerHorizontal="true"
> >                                 android:textSize="@dimen/menuxmlTitleSize"
> >                                 
> > android:textColor="@color/menuxmlTitleColor">
> >                         
> >                          >                                 android:id="@+id/ImageView02"
> >                                 android:layout_width="wrap_content"
> >                                 android:layout_height="wrap_content"
> >                                 android:background="@drawable/quizicon"
> >                                 android:layout_alignParentRight="true"
> >                                 android:layout_alignParentTop="true">
> >                         
>
> > 
> >  > android:text="@+id/TextView02"
> > android:id="@+id/TextView_HelpText"
> > android:layout_width="fill_parent"
> > android:layout_height="wrap_content">
> > 
> > 
>
> > I had a similar problem which came down to an XML layout issue and I'm
> > sure it's a similar issue here only I don't know how to resolve it.
>
> > Can someone please help and tell me how I can get the TextView to
> > display and perhaps more importantly, direct me to some good android
> > xml layout material?
>
> > Thanks.

-- 
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 visibility problem

2010-10-20 Thread sisko
You are right.
When I move the TextView up it is squashed but visible.

Can you advice on how I can make it visible beneath the relative
layout

On 20 Oct, 03:22, metal mikey  wrote:
> It might be because the TextView is positioned offscreen. Try putting
> it prior to the RelativeLayout, if you can see it then then it's
> likely the RelativeLayout is "pushing it" offscreen when the TextView
> is placed after the RelativeLayout.
>
> On Oct 20, 10:07 am,sisko wrote:
>
> > The following code is causing me problems as the last view, the
> > TextView, does not display :
>
> >  >         xmlns:android="http://schemas.android.com/apk/res/android";
> >         android:id="@+id/LinearLayout01"
> >         android:background="@drawable/bkgrnd"
> > android:layout_height="fill_parent"
> > android:layout_width="fill_parent">
> >          >                 android:id="@+id/RelativeLayout01"
> >                 android:layout_width="wrap_content"
> > android:layout_height="wrap_content">
> >                          >                                 android:id="@+id/ImageView01"
> >                                 android:layout_width="wrap_content"
> >                                 android:layout_height="wrap_content"
> >                                 android:background="@drawable/quizicon"
> >                                 android:layout_alignParentLeft="true"
> >                                 android:layout_alignParentTop="true">
> >                         
> >                          >                                 android:id="@+id/TextView01"
> >                                 android:layout_width="wrap_content"
> >                                 android:layout_height="wrap_content"
> >                                 android:text="@string/help"
> >                                 android:layout_alignParentTop="true"
> >                                 android:layout_centerHorizontal="true"
> >                                 android:textSize="@dimen/menuxmlTitleSize"
> >                                 
> > android:textColor="@color/menuxmlTitleColor">
> >                         
> >                          >                                 android:id="@+id/ImageView02"
> >                                 android:layout_width="wrap_content"
> >                                 android:layout_height="wrap_content"
> >                                 android:background="@drawable/quizicon"
> >                                 android:layout_alignParentRight="true"
> >                                 android:layout_alignParentTop="true">
> >                         
>
> > 
> >  >         android:text="@+id/TextView02"
> >         android:id="@+id/TextView_HelpText"
> >         android:layout_width="fill_parent"
> >         android:layout_height="wrap_content">
> > 
>
> > 
>
> > Can anyone offer suggestions as to why the TextView does not showup in
> > the present format?
> > Also, please suggest good online resourse(s) that can help me learn
> > good Android XML layout techniques, please.
>
> > Thanks :-)

-- 
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] TextView visibility problem

2010-10-19 Thread sisko
The following code is causing me problems as the last view, the
TextView, does not display :

http://schemas.android.com/apk/res/android";
android:id="@+id/LinearLayout01"
android:background="@drawable/bkgrnd"
android:layout_height="fill_parent"
android:layout_width="fill_parent">














Can anyone offer suggestions as to why the TextView does not showup in
the present format?
Also, please suggest good online resourse(s) that can help me learn
good Android XML layout techniques, please.

Thanks :-)

-- 
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] TextView visibility problem

2010-10-18 Thread sisko
Hi guys,

the code I pasted below works great with the exception of the last
view - the textView.

The TextView does not display:

http://schemas.android.com/apk/res/android";
android:id="@+id/LinearLayout01"
android:background="@drawable/bkgrnd"
android:layout_height="fill_parent"
android:layout_width="fill_parent">













I had a similar problem which came down to an XML layout issue and I'm
sure it's a similar issue here only I don't know how to resolve it.

Can someone please help and tell me how I can get the TextView to
display and perhaps more importantly, direct me to some good android
xml layout material?

Thanks.

-- 
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: ListView problem

2010-10-11 Thread sisko
Thank you both very much.

I am such a newbie. I have been stuck on this point for weeks.

Very appreciated.

On Oct 2, 4:44 am, Ramaraju naga  wrote:
> even I did, it works fine.
>
> see this code
>
>   ListView menuList =(ListView) findViewById(R.id.ListView_Menu);
>
>         String[] items={ getResources().getString(R.string.menu_item_play),
>                 getResources().getString(R.string.menu_item_scores),
>                 getResources().getString(R.string.menu_item_settings),
>                 getResources().getString(R.string.menu_item_help) };
>
>         ArrayAdapter adapt = new ArrayAdapter(this,
> R.layout.*menu_item*,items);
>         menuList.setAdapter(adapt);
>
> i think ur mistake where i put in redcolor. it is xml how the items should
> display.
>
> the xml look like (menu_item.xml)
>      xmlns:android="http://schemas.android.com/apk/res/android";
>     android:layout_width="fill_parent"
>     android:textSize="@dimen/menu_item_size"
>     android:text="test string"
>     android:layout_gravity="center_horizontal"
>     android:layout_height="wrap_content"
>     android:shadowRadius="5"
>     android:gravity="center"
>     android:textColor="@color/menu_color"
>     android:shadowColor="@color/menu_glow"
>     android:shadowDy="3"
>     android:shadowDx="3" />
>
> Thanks & Regards
> Ramaraju
>
> On Sat, Oct 2, 2010 at 8:59 AM, JPBerrocal  wrote:
> > Your problem in not in the listview, is in the layout.
> > More precisely the ImageView03 is using all the space available in the
> > screen so your listview doesnt show.
>
> > Use wrap_content or specify the correct size of the image instead.
>
> >  >     android:layout_alignParentBottom="true"
> >     android:scaleType="fitEnd"
> >      android:layout_width="wrap_content"
> >     android:layout_height="wrap_content">
> > 
>
> > --
> > 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 problem

2010-10-01 Thread sisko
In following a tutorial from "SAMS Android Application Development in
24 hours" I hit a problem with my first ListView example.

Basically, my java code is firing according to log messages I set but
my ListView does not display when I execute my app. The App runs fine
without crashing so syntactically all seems to be well.

Since I can't attach documents, please bear with me as I paste some
code but you can download the entire sample app from
http://www.icerge.com/android-sample-app-download

My layout file is called Menu.xml and is as below:

http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">






















The java file is called QuizMenuActivity.java and is as follows:
package com.androidbook.triviaquiz;

import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class QuizMenuActivity extends QuizActivity {
private final String LOGID  =   "Track";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);

Log.i(LOGID, "Begining!");

ListView menuList   =   (ListView)
findViewById(R.id.ListView_Menu);
/*String[] items=
{ getResources().getString(R.string.menu_item_play),

getResources().getString(R.string.menu_item_scores),

getResources().getString(R.string.menu_item_settings),

getResources().getString(R.string.menu_item_help) };*/
String[] items  ={"test#1","test#2","test3","test#4"} ;
ArrayAdapter adapt  =   new ArrayAdapter(this,
android.R.layout.simple_list_item_1, items);
menuList.setAdapter(adapt);


Log.i(LOGID, "Reaching this point!");
}
}

Finally, there is a Menu_item.xml which defines my TextView that the
java file above attempts to write array data to. It is as follows:
http://schemas.android.com/apk/res/android";
android:layout_width="match_parent"
android:text="testing testing"
android:layout_gravity="center_horizontal"
android:shadowRadius="5"
android:gravity="center"
android:textColor="@color/listview_items_color"
android:shadowDx="3"
android:shadowDy="3"
android:textSize="@dimen/menuxml_item_size"
android:shadowColor="@color/listview_items_color_glow">


As I don't want to overwhelm you with code you will have to take my
word for it that all the resources are in place and are not the
problem.


Can anyone offer some insight? Please download the app from
http://www.icerge.com/android-sample-app-download to examine the code
better and see what I mean.

Thanks.

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