[android-developers] registerForContextMenu not working

2010-09-10 Thread JasonMP
Hi everyone, My context menus are not registering when called.  In
addition setOnItemClickListener is also not working.  Any ideas why
this is happening?

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.armory_header);

  TabHost mTabHost = getTabHost();


mTabHost.addTab(mTabHost.newTabSpec("1").setIndicator("Weapons").setContent(R.id.page1));

mTabHost.addTab(mTabHost.newTabSpec("2").setIndicator("Armor").setContent(R.id.page2));

mTabHost.addTab(mTabHost.newTabSpec("3").setIndicator("Accessories").setContent(R.id.page3));

  weapons = (ListView) findViewById(R.id.weaponlist);
  registerForContextMenu(weapons);
  weapons.setOnItemClickListener(new OnItemClickListener(){

@Override
public void onItemClick(AdapterView arg0, 
View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
listId = weapons.getId();
position = arg2;
showDialog(DIALOG);
}

  });

  armor = (ListView) findViewById(R.id.armorlist);
  registerForContextMenu(armor);
  armor.setOnItemClickListener(new OnItemClickListener(){

@Override
public void onItemClick(AdapterView arg0, 
View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
listId = armor.getId();
position = arg2;
showDialog(DIALOG);
}

  });
}

-- 
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 contextmenu and onItemClickListener not working

2010-09-09 Thread JasonMP
I have a tab activity with three tabs and I want to display a listview
in each tab.  The list populates correctly, but for some reason I can
not get the context menu or itemclicklistener to recognize gestures on
the listviews.  Anyone have any ideas why this might be?   Below is my
onCreate method:

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.armory_header);

  TabHost mTabHost = getTabHost();


mTabHost.addTab(mTabHost.newTabSpec("1").setIndicator("Weapons").setContent(R.id.page1));

mTabHost.addTab(mTabHost.newTabSpec("2").setIndicator("Armor").setContent(R.id.page2));

mTabHost.addTab(mTabHost.newTabSpec("3").setIndicator("Accessories").setContent(R.id.page3));


  weapons = (ListView) findViewById(R.id.weaponlist);
  registerForContextMenu(weapons);
  weapons.setOnItemClickListener(new OnItemClickListener(){

@Override
public void onItemClick(AdapterView arg0, 
View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
listId = weapons.getId();
position = arg2;
showDialog(DIALOG);
}

  });

  armor = (ListView) findViewById(R.id.armorlist);
  registerForContextMenu(armor);
  armor.setOnItemClickListener(new OnItemClickListener(){

@Override
public void onItemClick(AdapterView arg0, 
View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
listId = armor.getId();
position = arg2;
showDialog(DIALOG);
}

  });

}

-- 
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: Null pointer exception

2010-01-06 Thread JasonMP
That was it!  I took out the startManagingCursor() and it worked
fine.  My next question is what should I do to handle the life cycle
of my cursor?  Should I close it outside the switch statement?

On Jan 5, 5:41 pm, Vladimir  wrote:
> What do you think about this:
> 1. Cursor created in onContextItemSelected() is null (for some reason)
> 2. Since its lifecycle is managed by the activity (startManagingCursor
> (c)), it tries to release it when the activity is stopped (when the
> new intent is launched)
> 3. It doesn't expect managed cursor to be null and crashes (at
> android.app.Activity.performStop(Activity.java:3604))
> Does that make sense? I have little idea about how this cursor
> management works, but I would do the following:
> 1. Try removing startManagingCursor() calls to see if these are
> related
> 2. Double check if the cursor is null
> 3. Take a look inside Android source and specifically Activity.java:
> 3604
> Just a guess :)
>
> On Jan 5, 4:02 pm, JasonMP  wrote:
>
>
>
> > Ok, I tried gino's idea with initializing my arrays differently.  I
> > also changed there names so that they did not share a name with any
> > other arrays in my app:  Did not work.
>
> > I also tried calling to static variables instead of passing variables
> > between classes with intents:  This also did not work.
>
> > I can't determine which line of code causes the error.  The logcat
> > does not give me a pointer to anything in my app at all.  I tried to
> > narrow it down with breakpoints and logging and what I found is that
> > it runs through all of my code without a hitch, and then once its done
> > it throws the exception.
>
> > And again the exception only happens when I call the intent from a
> > contextMenu.
>
> > On Jan 1, 2:56 am, Wiebbe  wrote:
>
> > > Shouldnt you check if the bundle is null or not? Try to loop through
> > > it when you get there from a onContextItemSelected event. I'm guessing
> > > some value somewhere is null when it should be instantiated. Perhaps
> > > the intent is started quicker or without the bundle somehow so you get
> > > a nullpointer exception?
>
> > > On 31 dec 2009, 15:57, JasonMP  wrote:
>
> > > > yes, Select.class is another one of my files.  throughout my app there
> > > > are a few different calls to it, all done the same way i.e. "Intent i
> > > > = new Intent(this, Select.class); startActivity(i);"
>
> > > > No where in Select.class do I make a call to start Select.class or
> > > > Sheet.class.  When its done it calls finish();
>
> > > > in the onCreate() of Select.class I grab the extras from the invoking
> > > > class with this line of code:
>
> > > > public class Select extends ListActivity{
>
> > > >         DBAdapter db = new DBAdapter(this);
> > > >         String slotName = null;
>
> > > >         @Override
> > > >         public void onCreate(Bundle savedInstanceState) {
> > > >                   super.onCreate(savedInstanceState);
>
> > > >                   db.open();
>
> > > >                   ListView list = getListView();
>
> > > >                   View v = View.inflate(this, R.layout.list_header, 
> > > > null);
> > > >                   list.addHeaderView(v, null, false);
>
> > > >                   name = 
> > > > this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
> > > >         }
>
> > > > Could it be something in the .getIntent() method?  or
> > > > the .getStringExtra()?
>
> > > > On Dec 30, 7:19 pm, "Stephen @ gmail.com" 
> > > > wrote:
>
> > > > > Now that I understand your intent creation a little better, and I see 
> > > > > that
> > > > > the intent you are creating is unique from the class in which the code
> > > > > exists, I am not quite sure how it could be an infinite loop in the
> > > > > (immediate) way I was thinking.
>
> > > > > Reading this code
>
> > > > > Intent i = new Intent(this, Select.class);
>
> > > > > I have to start thinking there's something wrong with this.  I tried 
> > > > > to look
> > > > > up the "Select" class on the android developers site, and couldn't 
> > > > > find it.
> > > > > Is that a class from another of your files?  I guess I would wonder 
> > > > > if the
> > > > > code being invoked 

[android-developers] Re: Null pointer exception

2010-01-05 Thread JasonMP
Ok, I tried gino's idea with initializing my arrays differently.  I
also changed there names so that they did not share a name with any
other arrays in my app:  Did not work.

I also tried calling to static variables instead of passing variables
between classes with intents:  This also did not work.

I can't determine which line of code causes the error.  The logcat
does not give me a pointer to anything in my app at all.  I tried to
narrow it down with breakpoints and logging and what I found is that
it runs through all of my code without a hitch, and then once its done
it throws the exception.

And again the exception only happens when I call the intent from a
contextMenu.

On Jan 1, 2:56 am, Wiebbe  wrote:
> Shouldnt you check if the bundle is null or not? Try to loop through
> it when you get there from a onContextItemSelected event. I'm guessing
> some value somewhere is null when it should be instantiated. Perhaps
> the intent is started quicker or without the bundle somehow so you get
> a nullpointer exception?
>
> On 31 dec 2009, 15:57, JasonMP  wrote:
>
>
>
> > yes, Select.class is another one of my files.  throughout my app there
> > are a few different calls to it, all done the same way i.e. "Intent i
> > = new Intent(this, Select.class); startActivity(i);"
>
> > No where in Select.class do I make a call to start Select.class or
> > Sheet.class.  When its done it calls finish();
>
> > in the onCreate() of Select.class I grab the extras from the invoking
> > class with this line of code:
>
> > public class Select extends ListActivity{
>
> >         DBAdapter db = new DBAdapter(this);
> >         String slotName = null;
>
> >         @Override
> >         public void onCreate(Bundle savedInstanceState) {
> >                   super.onCreate(savedInstanceState);
>
> >                   db.open();
>
> >                   ListView list = getListView();
>
> >                   View v = View.inflate(this, R.layout.list_header, null);
> >                   list.addHeaderView(v, null, false);
>
> >                   name = 
> > this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
> >         }
>
> > Could it be something in the .getIntent() method?  or
> > the .getStringExtra()?
>
> > On Dec 30, 7:19 pm, "Stephen @ gmail.com" 
> > wrote:
>
> > > Now that I understand your intent creation a little better, and I see that
> > > the intent you are creating is unique from the class in which the code
> > > exists, I am not quite sure how it could be an infinite loop in the
> > > (immediate) way I was thinking.
>
> > > Reading this code
>
> > > Intent i = new Intent(this, Select.class);
>
> > > I have to start thinking there's something wrong with this.  I tried to 
> > > look
> > > up the "Select" class on the android developers site, and couldn't find 
> > > it.
> > > Is that a class from another of your files?  I guess I would wonder if the
> > > code being invoked there, is somehow causing this class to be invoked, 
> > > thus
> > > causing some kind of loop.  I would grep for any reference to your Sheet
> > > class, from anywhere else in your code, and that would likely be suspect.
>
> > > In general, the below is kind of a side topic, to maybe help you with
> > > generic debugging.
>
> > > All the Best, Steve.
>
> > > *Ok... the only thing I can think to really help you is to start taking
> > > advantage of logging.  In your import list, I see you don't include the
> > > logger code, so maybe you can give this a shot.
>
> > > 1) in the import list
>
> > > import android.util.Log;
>
> > > 2) and throughout your code
>
> > > Log.d( TAG, DebugText );
>
> > > where TAG is a string that is unique to you, and "DebugText" is something
> > > useful to identify the part of the program you're interested in.
>
> > > *
>
> > > On Wed, Dec 30, 2009 at 11:32 AM, JasonMP  wrote:
> > > > Ok, I'm suddenly very curious by your previous statement stephen about
> > > > the possibility of creating an infinite loop.  Upon a little more
> > > > investigation I'm now getting errors all over the place...same
> > > > errorjust at different points in the app where I try to
> > > > startActivity(intent);  As soon as the new activity receives focus is
> > > > crashes.
>
> > > > On Dec 30, 1:58 pm, JasonMP  wrote:
> > > > > pack

[android-developers] Re: Null pointer exception

2009-12-31 Thread JasonMP
This is bizarre.

It works fine from the OnItemClick() of my OnItemClickListener
attached to my ListView.  Just not inside the onContextItemSelected.
*scratches head*

On Dec 31, 9:57 am, JasonMP  wrote:
> yes, Select.class is another one of my files.  throughout my app there
> are a few different calls to it, all done the same way i.e. "Intent i
> = new Intent(this, Select.class); startActivity(i);"
>
> No where in Select.class do I make a call to start Select.class or
> Sheet.class.  When its done it calls finish();
>
> in the onCreate() of Select.class I grab the extras from the invoking
> class with this line of code:
>
> public class Select extends ListActivity{
>
>         DBAdapter db = new DBAdapter(this);
>         String slotName = null;
>
>         @Override
>         public void onCreate(Bundle savedInstanceState) {
>                   super.onCreate(savedInstanceState);
>
>                   db.open();
>
>                   ListView list = getListView();
>
>                   View v = View.inflate(this, R.layout.list_header, null);
>                   list.addHeaderView(v, null, false);
>
>                   name = this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
>         }
>
> Could it be something in the .getIntent() method?  or
> the .getStringExtra()?
>
> On Dec 30, 7:19 pm, "Stephen @ gmail.com" 
> wrote:
>
>
>
> > Now that I understand your intent creation a little better, and I see that
> > the intent you are creating is unique from the class in which the code
> > exists, I am not quite sure how it could be an infinite loop in the
> > (immediate) way I was thinking.
>
> > Reading this code
>
> > Intent i = new Intent(this, Select.class);
>
> > I have to start thinking there's something wrong with this.  I tried to look
> > up the "Select" class on the android developers site, and couldn't find it.
> > Is that a class from another of your files?  I guess I would wonder if the
> > code being invoked there, is somehow causing this class to be invoked, thus
> > causing some kind of loop.  I would grep for any reference to your Sheet
> > class, from anywhere else in your code, and that would likely be suspect.
>
> > In general, the below is kind of a side topic, to maybe help you with
> > generic debugging.
>
> > All the Best, Steve.
>
> > *Ok... the only thing I can think to really help you is to start taking
> > advantage of logging.  In your import list, I see you don't include the
> > logger code, so maybe you can give this a shot.
>
> > 1) in the import list
>
> > import android.util.Log;
>
> > 2) and throughout your code
>
> > Log.d( TAG, DebugText );
>
> > where TAG is a string that is unique to you, and "DebugText" is something
> > useful to identify the part of the program you're interested in.
>
> > *
>
> > On Wed, Dec 30, 2009 at 11:32 AM, JasonMP  wrote:
> > > Ok, I'm suddenly very curious by your previous statement stephen about
> > > the possibility of creating an infinite loop.  Upon a little more
> > > investigation I'm now getting errors all over the place...same
> > > errorjust at different points in the app where I try to
> > > startActivity(intent);  As soon as the new activity receives focus is
> > > crashes.
>
> > > On Dec 30, 1:58 pm, JasonMP  wrote:
> > > > package com.mallet.dtool;
>
> > > > import android.app.AlertDialog;
> > > > import android.app.TabActivity;
> > > > import android.app.AlertDialog.Builder;
> > > > import android.content.DialogInterface;
> > > > import android.content.Intent;
> > > > import android.content.DialogInterface.OnClickListener;
> > > > import android.content.res.Configuration;
> > > > import android.database.Cursor;
> > > > import android.graphics.Color;
> > > > import android.os.Bundle;
> > > > import android.view.ContextMenu;
> > > > import android.view.KeyEvent;
> > > > import android.view.Menu;
> > > > import android.view.MenuItem;
> > > > import android.view.View;
> > > > import android.view.ContextMenu.ContextMenuInfo;
> > > > import android.widget.AdapterView;
> > > > import android.widget.ImageView;
> > > > import android.widget.LinearLayout;
> > > > import android.widget.ListView;
> > > > import android.widget.SimpleCursorAdapter;
> > > > import android.widget.TabHost;
> > > > import android.wid

[android-developers] Re: Null pointer exception

2009-12-31 Thread JasonMP
yes, Select.class is another one of my files.  throughout my app there
are a few different calls to it, all done the same way i.e. "Intent i
= new Intent(this, Select.class); startActivity(i);"


No where in Select.class do I make a call to start Select.class or
Sheet.class.  When its done it calls finish();


in the onCreate() of Select.class I grab the extras from the invoking
class with this line of code:

public class Select extends ListActivity{

DBAdapter db = new DBAdapter(this);
String slotName = null;

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  db.open();

  ListView list = getListView();

  View v = View.inflate(this, R.layout.list_header, null);
  list.addHeaderView(v, null, false);

  name = this.getIntent().getStringExtra(DBAdapter.KEY_NAME);
}

Could it be something in the .getIntent() method?  or
the .getStringExtra()?




On Dec 30, 7:19 pm, "Stephen @ gmail.com" 
wrote:
> Now that I understand your intent creation a little better, and I see that
> the intent you are creating is unique from the class in which the code
> exists, I am not quite sure how it could be an infinite loop in the
> (immediate) way I was thinking.
>
> Reading this code
>
> Intent i = new Intent(this, Select.class);
>
> I have to start thinking there's something wrong with this.  I tried to look
> up the "Select" class on the android developers site, and couldn't find it.
> Is that a class from another of your files?  I guess I would wonder if the
> code being invoked there, is somehow causing this class to be invoked, thus
> causing some kind of loop.  I would grep for any reference to your Sheet
> class, from anywhere else in your code, and that would likely be suspect.
>
> In general, the below is kind of a side topic, to maybe help you with
> generic debugging.
>
> All the Best, Steve.
>
> *Ok... the only thing I can think to really help you is to start taking
> advantage of logging.  In your import list, I see you don't include the
> logger code, so maybe you can give this a shot.
>
> 1) in the import list
>
> import android.util.Log;
>
> 2) and throughout your code
>
> Log.d( TAG, DebugText );
>
> where TAG is a string that is unique to you, and "DebugText" is something
> useful to identify the part of the program you're interested in.
>
> *
>
>
>
> On Wed, Dec 30, 2009 at 11:32 AM, JasonMP  wrote:
> > Ok, I'm suddenly very curious by your previous statement stephen about
> > the possibility of creating an infinite loop.  Upon a little more
> > investigation I'm now getting errors all over the place...same
> > errorjust at different points in the app where I try to
> > startActivity(intent);  As soon as the new activity receives focus is
> > crashes.
>
> > On Dec 30, 1:58 pm, JasonMP  wrote:
> > > package com.mallet.dtool;
>
> > > import android.app.AlertDialog;
> > > import android.app.TabActivity;
> > > import android.app.AlertDialog.Builder;
> > > import android.content.DialogInterface;
> > > import android.content.Intent;
> > > import android.content.DialogInterface.OnClickListener;
> > > import android.content.res.Configuration;
> > > import android.database.Cursor;
> > > import android.graphics.Color;
> > > import android.os.Bundle;
> > > import android.view.ContextMenu;
> > > import android.view.KeyEvent;
> > > import android.view.Menu;
> > > import android.view.MenuItem;
> > > import android.view.View;
> > > import android.view.ContextMenu.ContextMenuInfo;
> > > import android.widget.AdapterView;
> > > import android.widget.ImageView;
> > > import android.widget.LinearLayout;
> > > import android.widget.ListView;
> > > import android.widget.SimpleCursorAdapter;
> > > import android.widget.TabHost;
> > > import android.widget.TableLayout;
> > > import android.widget.TextView;
> > > import android.widget.Toast;
> > > import android.widget.AdapterView.AdapterContextMenuInfo;
> > > import android.widget.AdapterView.OnItemClickListener;
> > > import android.widget.TabHost.OnTabChangeListener;
>
> > > public class Sheet extends TabActivity{
>
> > >         @Override public void onConfigurationChanged(Configuration
> > newConfig)
> > > { super.onConfigurationChanged(newConfig); }
> > >         DBAdapter db = new DBAdapter(this);
> > >         static Long cRowI

[android-developers] Re: Null pointer exception

2009-12-30 Thread JasonMP
Ok, I'm suddenly very curious by your previous statement stephen about
the possibility of creating an infinite loop.  Upon a little more
investigation I'm now getting errors all over the place...same
errorjust at different points in the app where I try to
startActivity(intent);  As soon as the new activity receives focus is
crashes.

On Dec 30, 1:58 pm, JasonMP  wrote:
> package com.mallet.dtool;
>
> import android.app.AlertDialog;
> import android.app.TabActivity;
> import android.app.AlertDialog.Builder;
> import android.content.DialogInterface;
> import android.content.Intent;
> import android.content.DialogInterface.OnClickListener;
> import android.content.res.Configuration;
> import android.database.Cursor;
> import android.graphics.Color;
> import android.os.Bundle;
> import android.view.ContextMenu;
> import android.view.KeyEvent;
> import android.view.Menu;
> import android.view.MenuItem;
> import android.view.View;
> import android.view.ContextMenu.ContextMenuInfo;
> import android.widget.AdapterView;
> import android.widget.ImageView;
> import android.widget.LinearLayout;
> import android.widget.ListView;
> import android.widget.SimpleCursorAdapter;
> import android.widget.TabHost;
> import android.widget.TableLayout;
> import android.widget.TextView;
> import android.widget.Toast;
> import android.widget.AdapterView.AdapterContextMenuInfo;
> import android.widget.AdapterView.OnItemClickListener;
> import android.widget.TabHost.OnTabChangeListener;
>
> public class Sheet extends TabActivity{
>
>         @Override public void onConfigurationChanged(Configuration newConfig)
> { super.onConfigurationChanged(newConfig); }
>         DBAdapter db = new DBAdapter(this);
>         static Long cRowId;
>
>         //Variable declaration
>
>         public static Integer tabState = 1;
>
>         @Override
>         public void onCreate(Bundle savedInstanceState) {
>         super.onCreate(savedInstanceState);
>         setContentView(R.layout.sheet);
>
>         db.open();
>
>         //capture Tab4 elements
>         aList = (ListView) findViewById(R.id.alist);
>         aList.setOnItemClickListener(new OnItemClickListener(){
>
>                         @Override
>                         public void onItemClick(AdapterView arg0, View 
> arg1, int arg2,
>                                         long arg3) {
>
>                                 Cursor c = db.getAll(Sheet.charName);
>
>                         c.moveToPosition(arg2 - 1);
>
>                         Builder builder2 = new 
> AlertDialog.Builder(Sheet.this);
>                     builder2.setTitle(c.getString(c.getColumnIndexOrThrow
> (DBAdapter.KEY_NAME)));
>                     builder2.setIcon(R.drawable.equipment);
>                     builder2.setMessage(c.getString(c.getColumnIndexOrThrow
> (DBAdapter.KEY_DESC)));
>                     builder2.setPositiveButton("Ok", null);
>                     builder2.show();
>
>                         }
>
>         });
>         registerForContextMenu(aList);
>
>         }
>         @Override
>         public void onResume()
>         {
>                  super.onResume();
>
>                  fillAList();
>         }
>         @Override
>         public void onDestroy(){
>                 super.onDestroy();
>                 db.close();
>         }
>
>     @Override
>         public void onCreateContextMenu(ContextMenu menu, View v,
>                         ContextMenuInfo menuInfo) {
>
>         if(v == aList){
>                 menu.add(0, 7, 0, "option 1");
>         }
>         }
>
>     @Override
>         public boolean onContextItemSelected(MenuItem item) {
>         AdapterContextMenuInfo info = (AdapterContextMenuInfo)
> item.getMenuInfo();
>         Cursor c = null;
>         startManagingCursor(c);
>         Long id;
>         Integer idInt;
>
>         switch(item.getItemId()) {
>
>         case 7:
>                 c = db.getInfo(name);
>                 c.moveToPosition(info.position - 1);
>                 Intent i = new Intent(this, Select.class);
>                 i.putExtra(DBAdapter.KEY_NAME, 
> c.getString(c.getColumnIndexOrThrow
> (DBAdapter.KEY_NAME)));
>                 startActivity(i);
>
>                 return true;
>         }
>
>                 return super.onContextItemSelected(item);
>         }
>
>     public void fillArmorList(){
>
>                 Cursor c = db.getAll(Sheet.charName);
>                 startManagingCursor(c);
>
>                 String[] from = new String[]{//DB columns};
>
>                 int[] to = new int[

[android-developers] Re: Null pointer exception

2009-12-30 Thread JasonMP
package com.mallet.dtool;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.content.res.Configuration;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TabHost;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TabHost.OnTabChangeListener;

public class Sheet extends TabActivity{


@Override public void onConfigurationChanged(Configuration newConfig)
{ super.onConfigurationChanged(newConfig); }
DBAdapter db = new DBAdapter(this);
static Long cRowId;


//Variable declaration

public static Integer tabState = 1;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sheet);

db.open();


//capture Tab4 elements
aList = (ListView) findViewById(R.id.alist);
aList.setOnItemClickListener(new OnItemClickListener(){


@Override
public void onItemClick(AdapterView arg0, View arg1, 
int arg2,
long arg3) {

Cursor c = db.getAll(Sheet.charName);


c.moveToPosition(arg2 - 1);

Builder builder2 = new AlertDialog.Builder(Sheet.this);
builder2.setTitle(c.getString(c.getColumnIndexOrThrow
(DBAdapter.KEY_NAME)));
builder2.setIcon(R.drawable.equipment);
builder2.setMessage(c.getString(c.getColumnIndexOrThrow
(DBAdapter.KEY_DESC)));
builder2.setPositiveButton("Ok", null);
builder2.show();


}

});
registerForContextMenu(aList);


}
@Override
public void onResume()
{
 super.onResume();

 fillAList();
}
@Override
public void onDestroy(){
super.onDestroy();
db.close();
}




@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {

if(v == aList){
menu.add(0, 7, 0, "option 1");
}
}

@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo)
item.getMenuInfo();
Cursor c = null;
startManagingCursor(c);
Long id;
Integer idInt;

switch(item.getItemId()) {

case 7:
c = db.getInfo(name);
c.moveToPosition(info.position - 1);
Intent i = new Intent(this, Select.class);
i.putExtra(DBAdapter.KEY_NAME, 
c.getString(c.getColumnIndexOrThrow
(DBAdapter.KEY_NAME)));
startActivity(i);

return true;
}

return super.onContextItemSelected(item);
}

public void fillArmorList(){


Cursor c = db.getAll(Sheet.charName);
startManagingCursor(c);

String[] from = new String[]{//DB columns};


int[] to = new int[]{//Layout Elements};


SimpleCursorAdapter items = new SimpleCursorAdapter(this,
R.layout.item_row, c, from, to);
aList.setAdapter(items);
}



}

On Dec 30, 1:41 pm, JasonMP  wrote:
> Hmm, Ok, I've placed the breakpoint in and everything appears to be
> fine, but it still doesn't work.  This code is essentially a copy/
> paste from another area of my app.  In that instance its being called
> from a ListView contextmenu as well and works fine.  What do you mean
> exactly by catching ALL the exceptions?  Is that something I need to
> add into the code?
>
> On Dec 30, 1:21 pm, "Stephen @ gmail.com" 
> wrote:
>
>
>
> > Sorry if this sounds silly: you might want to set a breakpoint on line:
>
> > startActivity(i);
>
> > when you hit that point, examine "i" carefully.  From your log, I wonder if
> > the act of starting the activity invokes your current code, inducing an
&g

[android-developers] Re: Null pointer exception

2009-12-30 Thread JasonMP
Hmm, Ok, I've placed the breakpoint in and everything appears to be
fine, but it still doesn't work.  This code is essentially a copy/
paste from another area of my app.  In that instance its being called
from a ListView contextmenu as well and works fine.  What do you mean
exactly by catching ALL the exceptions?  Is that something I need to
add into the code?

On Dec 30, 1:21 pm, "Stephen @ gmail.com" 
wrote:
> Sorry if this sounds silly: you might want to set a breakpoint on line:
>
> startActivity(i);
>
> when you hit that point, examine "i" carefully.  From your log, I wonder if
> the act of starting the activity invokes your current code, inducing an
> infinite loop.  Also, if it were my code, I would want to ensure I catch all
> uncaught exceptions.  Around your code that you feel is failing, I would
> catch the general "Exception" as well as the AndroidRuntimeException (cannot
> remember if I've spelled that perfectly right), and print out the stack
> frame from the exception that was caught.  that might yield additional info.
>
> Finally, further assistance from the forum, you may want to include more of
> your code.  You probably have something special in there you don't want to
> share... just make what you post generic enough so we can see the construct
> of your whole activity.
>
> all the best, steve.
>
>
>
> On Wed, Dec 30, 2009 at 10:10 AM, JasonMP  wrote:
> > Yes I'm using eclipse.  I use the debugger and when I hit that point
> > in my app i get the above error in my logcat window.  Is there another
> > way to debug in eclipse?
>
> > On Dec 30, 1:01 pm, Matt  wrote:
> > > I would just step through it with the debugger (assuming you are using
> > > Eclipse)
>
> > > On Dec 30, 8:39 am, JasonMP  wrote:
>
> > > > Anyone know what would cause this error?
>
> > > > 12-30 10:26:50.858: ERROR/AndroidRuntime(921): Uncaught handler:
> > > > thread main exiting due to uncaught exception
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):
> > > > java.lang.RuntimeException: Unable to stop activity {com.mallet.dtool/
> > > > com.mallet.dtool.Sheet}: java.lang.NullPointerException
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > android.app.ActivityThread.performStopActivityInner
> > > > (ActivityThread.java:3124)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > android.app.ActivityThread.handleStopActivity(ActivityThread.java:
> > > > 3167)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > android.app.ActivityThread.access$2400(ActivityThread.java:116)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1810)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > android.os.Handler.dispatchMessage(Handler.java:99)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > android.os.Looper.loop(Looper.java:123)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > android.app.ActivityThread.main(ActivityThread.java:4203)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > java.lang.reflect.Method.invokeNative(Native Method)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > java.lang.reflect.Method.invoke(Method.java:521)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> > > > (ZygoteInit.java:791)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > dalvik.system.NativeStart.main(Native Method)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921): Caused by:
> > > > java.lang.NullPointerException
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > android.app.Activity.performStop(Activity.java:3604)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > > > android.app.ActivityThread.performStopActivityInner
> > > > (ActivityThread.java:3121)
>
> > > > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     ... 11 more
>
> > > > This is the code it runs when I get t

[android-developers] Re: Null pointer exception

2009-12-30 Thread JasonMP
Yes I'm using eclipse.  I use the debugger and when I hit that point
in my app i get the above error in my logcat window.  Is there another
way to debug in eclipse?

On Dec 30, 1:01 pm, Matt  wrote:
> I would just step through it with the debugger (assuming you are using
> Eclipse)
>
> On Dec 30, 8:39 am, JasonMP  wrote:
>
>
>
> > Anyone know what would cause this error?
>
> > 12-30 10:26:50.858: ERROR/AndroidRuntime(921): Uncaught handler:
> > thread main exiting due to uncaught exception
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):
> > java.lang.RuntimeException: Unable to stop activity {com.mallet.dtool/
> > com.mallet.dtool.Sheet}: java.lang.NullPointerException
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > android.app.ActivityThread.performStopActivityInner
> > (ActivityThread.java:3124)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > android.app.ActivityThread.handleStopActivity(ActivityThread.java:
> > 3167)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > android.app.ActivityThread.access$2400(ActivityThread.java:116)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1810)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > android.os.Handler.dispatchMessage(Handler.java:99)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > android.os.Looper.loop(Looper.java:123)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > android.app.ActivityThread.main(ActivityThread.java:4203)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > java.lang.reflect.Method.invokeNative(Native Method)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > java.lang.reflect.Method.invoke(Method.java:521)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> > (ZygoteInit.java:791)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > dalvik.system.NativeStart.main(Native Method)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921): Caused by:
> > java.lang.NullPointerException
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > android.app.Activity.performStop(Activity.java:3604)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     at
> > android.app.ActivityThread.performStopActivityInner
> > (ActivityThread.java:3121)
>
> > 12-30 10:26:50.928: ERROR/AndroidRuntime(921):     ... 11 more
>
> > This is the code it runs when I get the error (this is a context menu
> > option from a listview)
>
> > Cursor c = db.getInfo(name);
> > c.moveToPosition(info.position - 1);
> > Intent i = new Intent(this, Select.class);
> > i.putExtra(name, c.getString(c.getColumnIndexOrThrow
> > (DBAdapter.KEY_NAME)));
>
> > startActivity(i);
>
> > this launches another activity that when opened from other areas of my
> > app work fine.  I checked to see if it had anything to do with the
> > extras and it didn't seem to(i removed them entirely).

-- 
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] Null pointer exception

2009-12-30 Thread JasonMP
Anyone know what would cause this error?

12-30 10:26:50.858: ERROR/AndroidRuntime(921): Uncaught handler:
thread main exiting due to uncaught exception

12-30 10:26:50.928: ERROR/AndroidRuntime(921):
java.lang.RuntimeException: Unable to stop activity {com.mallet.dtool/
com.mallet.dtool.Sheet}: java.lang.NullPointerException

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
android.app.ActivityThread.performStopActivityInner
(ActivityThread.java:3124)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
android.app.ActivityThread.handleStopActivity(ActivityThread.java:
3167)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
android.app.ActivityThread.access$2400(ActivityThread.java:116)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1810)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
android.os.Handler.dispatchMessage(Handler.java:99)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
android.os.Looper.loop(Looper.java:123)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
android.app.ActivityThread.main(ActivityThread.java:4203)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
java.lang.reflect.Method.invokeNative(Native Method)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
java.lang.reflect.Method.invoke(Method.java:521)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
dalvik.system.NativeStart.main(Native Method)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): Caused by:
java.lang.NullPointerException

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
android.app.Activity.performStop(Activity.java:3604)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): at
android.app.ActivityThread.performStopActivityInner
(ActivityThread.java:3121)

12-30 10:26:50.928: ERROR/AndroidRuntime(921): ... 11 more


This is the code it runs when I get the error (this is a context menu
option from a listview)

Cursor c = db.getInfo(name);
c.moveToPosition(info.position - 1);
Intent i = new Intent(this, Select.class);
i.putExtra(name, c.getString(c.getColumnIndexOrThrow
(DBAdapter.KEY_NAME)));

startActivity(i);


this launches another activity that when opened from other areas of my
app work fine.  I checked to see if it had anything to do with the
extras and it didn't seem to(i removed them entirely).

-- 
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] ListActivity and headers giving me an odd side effect

2009-12-28 Thread JasonMP
Hello,

I'm getting some odd side effects when I set a header to my
ListActivities.  The ListActivity actually allows you to scroll up
"behind" the header and click...which sends my app into a fit of
errors b/c my Lists are connected to a Cursor and selecting behind the
header returns a value of -1.  Ive noticed this doesnt happen to any
of my Lists that dont have headers.  Any ideas what would cause this/
how to fix it?

Thanks, Jason.

-- 
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] Dynamic Spinners

2009-12-23 Thread JasonMP
Hello,

I'm attempting to create and display Spinner view and an EditText view
when the user hits a button.  I can create these with .addView, and
assign Ids with .setId() but then how would I call .getSelectedItem
() or .getText() on them?

Heres some of my code:

 attrLayout = (LinearLayout) findViewById(R.id.attrlayout);
addAttr = (Button) findViewById(R.id.addattr);
addAttr.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Spinner newAttrSpinner =  new 
Spinner(arg0.getContext());
newAttrSpinner.setId(spinId);
newAttrSpinner.setAdapter(attrAdapter);

EditText newEditText = new 
EditText(arg0.getContext());
newEditText.setId(editTextId);
newEditText.setWidth(100);

attrLayout.addView(newAttrSpinner);
attrLayout.addView(newEditText);
}
});

-- 
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] Programmatically set EditText to only accept integers

2009-12-22 Thread JasonMP
Hi,

Essentially I want to achieve ' android:numeric="signed" '
programmatically.  I've looked at the setKeyListener method but feel
that I'm missing something and shouldn't have to recreate the wheel
here.  Is there a simple way to do 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] Re: Accessing images from gallery

2009-11-24 Thread JasonMP
I also get this on another error:

11-24 10:44:56.658: ERROR/AndroidRuntime(4042): Uncaught handler:
thread main exiting due to uncaught exception
11-24 10:44:56.768: ERROR/AndroidRuntime(4042):
java.lang.OutOfMemoryError: bitmap size exceeds VM budget


On Nov 23, 8:46 pm, Mark Murphy  wrote:
> JasonMP wrote:
> > Well the console view in eclipse spits this out when I start the
> > emulator:
>
> > ActivityManager: DDM dispatch reg wait timeout
> > ActivityManager: Can't dispatch DDM chunk 52454151: no handler defined
>
> That is not DDMS. That is the console, roughly equivalent to the
> command-line output you might see running commands from a Linux/OS X
> terminal or a Windows command prompt.
>
> Use adb logcat, the standalone DDMS program, or the DDMS perspective in
> Eclipse to view the Java stack trace.
>
> > but other than that it runs fine.  The errors start occurring on my
> > actual phone when I test it there.  I knew about using the logcat to
> > view errors in the emulator, is there a way to do that when I'm
> > testing on the phone?  Its an HTC G1 btw.
>
> Use the mini USB cable to connect the G1 to the PC. Then, use adb
> logcat, DDMS, or the DDMS perspective in Eclipse to view the logcat
> data, which contains the Java stack traces. You will need to tell those
> tools to examine your G1 rather than any running emulator(s) (e.g., in
> DDMS, choose your device from the list of devices in the upper left
> tree-table).
>
> http://developer.android.com/guide/developing/tools/ddms.htmlhttp://developer.android.com/guide/developing/tools/adb.html#logcat
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _Android Programming Tutorials_ Version 1.0 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: Accessing images from gallery

2009-11-24 Thread JasonMP
Ok, I'm getting a couple things that look funny.  The first is:

11-24 10:28:11.748: INFO/ActivityManager(74): Starting activity:
Intent { cmp=com.mallet.tool/.Sheet (has extras) }
11-24 10:28:14.148: INFO/System.out(3912): resolveUri failed on bad
bitmap uri: 0
11-24 10:28:14.648: INFO/System.out(3912): resolveUri failed on bad
bitmap uri: 0

when the app crashes however its due to:

11-24 10:28:52.638: ERROR/AndroidRuntime(4015): Uncaught handler:
thread main exiting due to uncaught exception

11-24 10:28:52.758: ERROR/AndroidRuntime(4015):
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.mallet.tool/com.mallet.tool.Sheet}:java.lang.NullPointerException

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2401)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2417)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
android.app.ActivityThread.access$2100(ActivityThread.java:116)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
android.os.Handler.dispatchMessage(Handler.java:99)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
android.os.Looper.loop(Looper.java:123)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
android.app.ActivityThread.main(ActivityThread.java:4203)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
java.lang.reflect.Method.invokeNative(Native Method)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
java.lang.reflect.Method.invoke(Method.java:521)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:791)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
dalvik.system.NativeStart.main(Native Method)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): Caused by:
java.lang.NullPointerException

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
com.mallet.tool.Sheet.showStats(Sheet.java:280)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
com.mallet.tool.Sheet.onCreate(Sheet.java:127)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)

11-24 10:28:52.758: ERROR/AndroidRuntime(4015): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2364)
11-24 10:28:52.758: ERROR/AndroidRuntime(4015): ... 11 more


On Nov 23, 8:46 pm, Mark Murphy  wrote:
> JasonMP wrote:
> > Well the console view in eclipse spits this out when I start the
> > emulator:
>
> > ActivityManager: DDM dispatch reg wait timeout
> > ActivityManager: Can't dispatch DDM chunk 52454151: no handler defined
>
> That is not DDMS. That is the console, roughly equivalent to the
> command-line output you might see running commands from a Linux/OS X
> terminal or a Windows command prompt.
>
> Use adb logcat, the standalone DDMS program, or the DDMS perspective in
> Eclipse to view the Java stack trace.
>
> > but other than that it runs fine.  The errors start occurring on my
> > actual phone when I test it there.  I knew about using the logcat to
> > view errors in the emulator, is there a way to do that when I'm
> > testing on the phone?  Its an HTC G1 btw.
>
> Use the mini USB cable to connect the G1 to the PC. Then, use adb
> logcat, DDMS, or the DDMS perspective in Eclipse to view the logcat
> data, which contains the Java stack traces. You will need to tell those
> tools to examine your G1 rather than any running emulator(s) (e.g., in
> DDMS, choose your device from the list of devices in the upper left
> tree-table).
>
> http://developer.android.com/guide/developing/tools/ddms.htmlhttp://developer.android.com/guide/developing/tools/adb.html#logcat
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _Android Programming Tutorials_ Version 1.0 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: Accessing images from gallery

2009-11-23 Thread JasonMP
Well the console view in eclipse spits this out when I start the
emulator:

ActivityManager: DDM dispatch reg wait timeout
ActivityManager: Can't dispatch DDM chunk 52454151: no handler defined

but other than that it runs fine.  The errors start occurring on my
actual phone when I test it there.  I knew about using the logcat to
view errors in the emulator, is there a way to do that when I'm
testing on the phone?  Its an HTC G1 btw.

On Nov 23, 8:13 pm, Mark Murphy  wrote:
> JasonMP wrote:
> > Hi,
>
> > I'm a mess.
>
> > I'm using the blow code to open the gallery and grab an image for an
> > incon im gong to store in a database and access later to populate a
> > listview attached to a simpleCursorAdapter.
> > //inside contextmenu
> >                 Intent intent = new Intent();
> >                    intent.setType("image/*");
> >                    intent.setAction(Intent.ACTION_GET_CONTENT);
> >                    startActivityForResult(intent, 1);
> > //activityresult
> > protected void onActivityResult(int requestCode, int resultCode,Intent
> > data)
> >    {
> >            if(requestCode == 1){
> >                    if(resultCode == RESULT_OK) {
> >                            db.open();
> >                    db.updateDB(data.getData().toString());  //this updates
> > the columns in the DB that will later get used for the adapter
> >                    db.close();
> >                    }
> >            }
>
> >    }
>
> > The code runs, and then starts force closing (what seems like)
> > randomly.  I'm convinced that I've gotten something confused somewhere
> > but since the force closure happens at all different points of my app
> > I dont know where to start looking.
>
> Start by looking at your Java stack trace to see what's blowing up. You
> can access that via adb logcat, DDMS, or the DDMS perspective in Eclipse.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Training in Germany, 18-22 January 2010:http://bignerdranch.com

-- 
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] Accessing images from gallery

2009-11-23 Thread JasonMP
Hi,

I'm a mess.

I'm using the blow code to open the gallery and grab an image for an
incon im gong to store in a database and access later to populate a
listview attached to a simpleCursorAdapter.
//inside contextmenu
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(intent, 1);
//activityresult
protected void onActivityResult(int requestCode, int resultCode,Intent
data)
{
if(requestCode == 1){
if(resultCode == RESULT_OK) {
db.open();
db.updateDB(data.getData().toString());  //this updates
the columns in the DB that will later get used for the adapter
db.close();
}
}

}


The code runs, and then starts force closing (what seems like)
randomly.  I'm convinced that I've gotten something confused somewhere
but since the force closure happens at all different points of my app
I dont know where to start looking.




-- 
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: binding images from assets to a simpleCursorAdapter

2009-11-23 Thread JasonMP
Well then I am probably doing this the wrong way.  Essentially what i
want to accomplish is for a user to be able to select a picture from
the sdcard as an avatar/logo/profile pic/etc and have that image
reference stored in my database.  Is there an easy way to do this?

On Nov 23, 3:05 pm, Mark Murphy  wrote:
> Jason Mallet-Prevost wrote:
> > I am trying it like this:
>
> > ImageView.setImageUri(Uri.parse(file:///android_asset/image.jpeg));
>
> > and its displaying a blank screen.  Am I missing something?  
>
> Besides quotes around your string, no, I would have hoped that this
> would work. Beyond that, I do not know of a Uri scheme that accesses assets.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> _Android Programming Tutorials_ Version 1.0 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] binding images from assets to a simpleCursorAdapter

2009-11-23 Thread JasonMP
Hello,

I was poking around in the documentation for the simpleCursorAdapter
and I read that if the simpleCursorAdapter doesn't identify your
images as resources it will assume they are URIs.  My question is how
do i retrieve the URI for an image placed into the asset folder of my
application?

-- 
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: MediaStore returning loop of images and not entire directory

2009-11-23 Thread JasonMP
I implemented a bit of code at the end there before you recycle the
bitmap to open a fileoutput stream and write the image to the /data/
data//file directory and save it there after the scaling.
What I need to figure out is how to grab that images URI so that I can
bind it to a simpleCursorAdapter.  Does the image even have a URI
after I place it into the apps file dir?  or should I instead of
copying it to the file dir just reference the original image on the
sdcard?

On Nov 23, 11:23 am, Mihai Fonoage  wrote:
> Happy it does. I posted a very brief description of the code at the
> beginning of the blog; that, together with code comments should help a
> bit. Let me know if you have any questions.
>
> Mihai Fonoage
>
> On Nov 23, 10:52 am, Jason Mallet-Prevost 
> wrote:
>
>
>
> > Mihai,
>
> > It works!  Like a charm too.  Thanks for your help on this.  I'll have to
> > tinker around with it and see how it works exactly.
>
> > On Mon, Nov 23, 2009 at 10:27 AM, Mihai Fonoage  wrote:
> > > No, you can take that line out (I updated the code with this change).
> > > Thanks for noticing that.
>
> > > Mihai Fonoage
>
> > > On Nov 23, 10:04 am, Jason Mallet-Prevost 
> > > wrote:
> > > > Do I need to be including any other classes for this to run?  What is a
> > > > PuzzleView?  Is that something in Android 2.0?
>
> > > > On Mon, Nov 23, 2009 at 9:59 AM, Jason Mallet-Prevost
> > > > wrote:
>
> > > > > Hi Mihai,
>
> > > > > I have an HTC G1 running Android 1.6.  I'm working on getting your new
> > > code
> > > > > implemented this morning.  I'll let you know how it goes.  And thank
> > > you.
>
> > > > > On Mon, Nov 23, 2009 at 7:56 AM, Mihai Fonoage  > > >wrote:
>
> > > > >> Hi Jason,
>
> > > > >> Have you tried the updated version of my code (http://
> > > > >> mihaifonoage.blogspot.com/2009/11/displaying-images-from-sd-card-
> > > > >> in.html<
> > >http://mihaifonoage.blogspot.com/2009/11/displaying-images-from-sd-ca...>)
> > > > >> ? I am curious if you'll encounter the same problem with it.
> > > > >> I am still using MediaStore, so you might. It would also be
> > > > >> interesting to know what is wrong with the above code. I remember
> > > > >> getting the same behavior on the emulator once, but I deleted the 
> > > > >> AVD,
> > > > >> created a new one, and could not reproduce it afterwards.
>
> > > > >> By the way, what phone are you using, and what version of the SDK do
> > > > >> you have on it?
>
> > > > >> Mihai Fonoage
>
> > > > >> On Nov 22, 1:38 pm, JasonMP  wrote:
> > > > >> > Hello, I'm testing some code from a demo found in a forum and I'm
> > > > >> > getting some strange results.  My goal is to be able to allow users
> > > to
> > > > >> > access the pictures on their device to choose an avatar/logo.  This
> > > > >> > code run flawlessly except that I only get a handful of images on
> > > the
> > > > >> > phone.  And its not even always the same images.  Whats more is 
> > > > >> > that
> > > > >> > it loads those images into a gridview and repeats them for what
> > > looks
> > > > >> > like a number of times equal to the actual number of images that 
> > > > >> > are
> > > > >> > on the device.  And on top of that if I scroll down the through the
> > > > >> > pictures, and scroll back up, it reorders the pictures from what
> > > they
> > > > >> > were previously.  Each time I load the app the pictures seem to be
> > > > >> > different as well.  I have around 400 pictures stored on my phone,
> > > and
> > > > >> > thats what I'm using to test.  If someone could shed some light on
> > > > >> > this for me that would be great.  This is my first time using a URI
> > > to
> > > > >> > access content to I'm not sure where to start troubleshooting this
> > > > >> > one.
>
> > > > >> > public class gallery extends Activity {
>
> > > > >> >     /**
> > > > >> >      * Cursor used to access the results from querying for images 
> > > > >> &

[android-developers] MediaStore returning loop of images and not entire directory

2009-11-22 Thread JasonMP
Hello, I'm testing some code from a demo found in a forum and I'm
getting some strange results.  My goal is to be able to allow users to
access the pictures on their device to choose an avatar/logo.  This
code run flawlessly except that I only get a handful of images on the
phone.  And its not even always the same images.  Whats more is that
it loads those images into a gridview and repeats them for what looks
like a number of times equal to the actual number of images that are
on the device.  And on top of that if I scroll down the through the
pictures, and scroll back up, it reorders the pictures from what they
were previously.  Each time I load the app the pictures seem to be
different as well.  I have around 400 pictures stored on my phone, and
thats what I'm using to test.  If someone could shed some light on
this for me that would be great.  This is my first time using a URI to
access content to I'm not sure where to start troubleshooting this
one.

public class gallery extends Activity {

/**
 * Cursor used to access the results from querying for images on
the SD card.
 */
private Cursor cursor;
/*
 * Column index for the Thumbnails Image IDs.
 */
private int columnIndex;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gallery);

// Set up an array of the Thumbnail Image ID column we want
String[] projection = {MediaStore.Images.Thumbnails._ID};
// Create the cursor pointing to the SDCard
cursor = managedQuery
( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
projection, // Which columns to return
null,   // Return all rows
null,
MediaStore.Images.Thumbnails.IMAGE_ID);
// Get the column index of the Thumbnails Image ID
columnIndex = cursor.getColumnIndexOrThrow
(MediaStore.Images.Thumbnails._ID);

GridView sdcardImages = (GridView) findViewById(R.id.sdcard);
sdcardImages.setAdapter(new ImageAdapter(this));

// Set up a click listener
sdcardImages.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView parent, View v, int
position, long id) {
// Get the data location of the image
String[] projection = {MediaStore.Images.Media.DATA};
cursor = managedQuery
( MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
projection, // Which columns to return
null,   // Return all rows
null,
null);
columnIndex = cursor.getColumnIndexOrThrow
(MediaStore.Images.Media.DATA);
cursor.moveToPosition(position);
// Get image filename
String imagePath = cursor.getString(columnIndex);
// Use this path to do further processing, i.e. full
screen display
}
});
}

/**
 * Adapter for our image files.
 */
private class ImageAdapter extends BaseAdapter {

private Context context;

public ImageAdapter(Context localContext) {
context = localContext;
}

public int getCount() {
return cursor.getCount();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup
parent) {
ImageView picturesView;
if (convertView == null) {
picturesView = new ImageView(context);
// Move cursor to current position
cursor.moveToPosition(position);
// Get the current value for the requested column
int imageID = cursor.getInt(columnIndex);
// Set the content of the image based on the provided
URI
picturesView.setImageURI(Uri.withAppendedPath(
 
MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, "" + imageID));
picturesView.setScaleType
(ImageView.ScaleType.FIT_CENTER);
picturesView.setPadding(8, 8, 8, 8);
picturesView.setLayoutParams(new GridView.LayoutParams
(100, 100));
}
else {
picturesView = (ImageView)convertView;
}
return picturesView;
}
}
}

-- 
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: storing imageview reference in database, need help retrieving

2009-11-21 Thread JasonMP
Its ImageView.setImageResource();

On Nov 21, 10:01 pm, JasonMP  wrote:
> Nevermind, got it.
>
> On Nov 21, 9:56 pm, JasonMP  wrote:
>
>
>
> > Hi,
>
> > I'm having trouble retrieving image references from my database and
> > then setting them to an ImageView.  When I pass R.drawable.icon into
> > my database its compiled and stored as an Integer.  how would I then
> > pull this Integer out and use ImageView.setImageDrawable(); ???

-- 
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: storing imageview reference in database, need help retrieving

2009-11-21 Thread JasonMP
Nevermind, got it.

On Nov 21, 9:56 pm, JasonMP  wrote:
> Hi,
>
> I'm having trouble retrieving image references from my database and
> then setting them to an ImageView.  When I pass R.drawable.icon into
> my database its compiled and stored as an Integer.  how would I then
> pull this Integer out and use ImageView.setImageDrawable(); ???

-- 
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] storing imageview reference in database, need help retrieving

2009-11-21 Thread JasonMP
Hi,

I'm having trouble retrieving image references from my database and
then setting them to an ImageView.  When I pass R.drawable.icon into
my database its compiled and stored as an Integer.  how would I then
pull this Integer out and use ImageView.setImageDrawable(); ???

-- 
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: ListActivity addHeader???

2009-11-20 Thread JasonMP
Mark...I'm offically you're biggest fan haha, j/k.  But thanks,
seriously.

On Nov 20, 7:27 pm, "Mark Murphy"  wrote:
> > I can add a header to my listview within another activity with:
>
> > list = (ListView) findViewById(R.layout.list_view);
>
> > View v = View.inflate(this, R.layout.skill_list_header, null);
> >         TextView t = (TextView) v.findViewById(R.id.skillHeader);
> >         list.addHeaderView(v);
>
> > this doesnt work however for ListActivity.
>
> It should. You can ask the ListActivity to getListView(), IIRC.
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> Android App Developer Books:http://commonsware.com/books.html

-- 
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] ListActivity addHeader???

2009-11-20 Thread JasonMP
Hi,

I can add a header to my listview within another activity with:

list = (ListView) findViewById(R.layout.list_view);

View v = View.inflate(this, R.layout.skill_list_header, null);
TextView t = (TextView) v.findViewById(R.id.skillHeader);
list.addHeaderView(v);

this doesnt work however for ListActivity.  Can anyoneadd some insight
to this?  Sorry if this is obvious.

-- 
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: TabActivity Lifecycle

2009-11-20 Thread JasonMP
Heres another concern.  I previously had 2 separate contextmenus and 2
separate options menus for my first tab and my second tab.  Now that
they are in the same activity do they have to share the same menus?
I'm guessing I can always run a switch statement or something when I
open the menu based off which tab is presently open but that just
seems like the wrong way to do it.  I'm sorry if these are painfully
obvious, I'm still learning the ropes here.

On Nov 20, 3:36 pm, Jason Mallet-Prevost  wrote:
> Yeah, I think I got a little carried away there.  I slowed down and got it
> figured out.  Thanks again Mark.
>
> On Fri, Nov 20, 2009 at 3:32 PM, Jason Proctor <
>
>
>
> jason.android.li...@gmail.com> wrote:
> > >Please, the order of these steps is important -- we don't want any
> > >accidents related to CUI (Coding Under the Influence).
>
> > not necessarily --
>
> >http://xkcd.com/323/
>
> > :-)
>
> > --
> > jason.vp.engineering.particle
>
> > --
> > 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 > cr...@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: TabActivity Lifecycle

2009-11-20 Thread JasonMP
Reason for confusion:

I start my app and it loads to default TAB1.

I select TAB2 at the top and it switches to TAB2...in my onResume()
for TAB2 I display a Toast "Hello" and it is displayed.

I go back to TAB1everything ok here.

i go back to TAB2no Toast displayed from the onResume().

What am I missing?

On Nov 20, 2:02 pm, JasonMP  wrote:
> Hi,
>
> Can someone explain to me, or point me to a reference document
> describing a TabActivities Lifecycle?  I have a tab that runs an
> activity.  When does that activities onCreate, onResume, onPause take
> place?

-- 
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: Refreshing a ListActivity within a TabView

2009-11-20 Thread JasonMP
Does that go in he onCreate? onResume?

On Nov 20, 12:15 pm, Mark Murphy  wrote:
> JasonMP wrote:
> > Hi,
>
> > I'm running into some issues here with my app.  I have 4 tabs run
> > through a tabActivity.  One tab sends an intent and run my
> > ListActivity that populates the screen from a simpleCursorAdapter.  My
> > problem is that when I change back to this tab, after the first time
> > its run, the list never refreshes regardless of the changes made to
> > the database via other tabs.  Is there something I can call from
> > onTabChanged to refresh my ListActivity?
>
> Call requery() on the Cursor wrapped by your SimpleCursorAdapter. The
> rest should take care of itself.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Consulting/App Development:http://commonsware.com/consulting

-- 
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] TabActivity Lifecycle

2009-11-20 Thread JasonMP
Hi,

Can someone explain to me, or point me to a reference document
describing a TabActivities Lifecycle?  I have a tab that runs an
activity.  When does that activities onCreate, onResume, onPause take
place?

-- 
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: RESET SQLite AUTOINCREMENT

2009-11-20 Thread JasonMP
Yes, I realize that.  Not to mention it would take longer.  I'll just
query the rows current ROW_ID and pass it along.

The issue came up b/c when i do delete rows i get gaps.  gaps were bad
for my code :).  I'm not sure I understand what a general transaction
abort is.  Is this something that happens often?

On Nov 20, 1:46 pm, jotobjects  wrote:
> On Nov 20, 6:04 am, JasonMP  wrote:
>
>
>
> > if my autoincrements skips numbers then I can get an error trying to
> > update a row that doesn't exist.
>
> What if you delete a row later?  That will cause a gap.  Are you sure
> that will never happen?  In general transaction aborts may result in
> rows that were created but not inserted so there are gaps from that.
> You are going to pay a performance penalty for trying to create your
> own auto incrementing keys, assuming you can get it to work at all.

-- 
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] Refreshing a ListActivity within a TabView

2009-11-20 Thread JasonMP
Hi,

I'm running into some issues here with my app.  I have 4 tabs run
through a tabActivity.  One tab sends an intent and run my
ListActivity that populates the screen from a simpleCursorAdapter.  My
problem is that when I change back to this tab, after the first time
its run, the list never refreshes regardless of the changes made to
the database via other tabs.  Is there something I can call from
onTabChanged to refresh my ListActivity?

-- 
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: RESET SQLite AUTOINCREMENT

2009-11-20 Thread JasonMP
I'm very new to all of this so I greatly appreciate your advice.  But
to clarify, you mean instead of using AUTOINCREMENT i create a column
to hold an integer value that I set, and can therefore control rather
than let SQLite do it automatically?  This was what I was expecting to
have to do if there wasn't a work around.  I had read that deleting
the table row from the sqlite_sequence table would reset it, however,
this didn't seem to work for me.

On Nov 20, 10:11 am, Mark Murphy  wrote:
> JasonMP wrote:
> > I use a do/while that runs through one of my tables based on the
> > number of entries on another table and makes changes.
>
> > Example:
>
> > Integer i = 1;
>
> > Cursor c = db.querryFunction();
> > Integer rowCount = c.getCount();
>
> > do{
> >     //does work on the database
> >     db.updateRow(table, args, KEY_ROWID + "=" + i, null);
> >     i++;
> > }
> > while(i <= rowCount);
>
> > if my autoincrements skips numbers then I can get an error trying to
> > update a row that doesn't exist.
>
> I wouldn't recommend that structure in general. Making assumptions on
> the nature of primary keys always struck me as dangerous.
>
> AUTOINCREMENT is not going to be reliable for your situation, in any case:
>
> "Note that 'monotonically increasing' does not imply that the ROWID
> always increases by exactly one. One is the usual increment. However, if
> an insert fails due to (for example) a uniqueness constraint, the ROWID
> of the failed insertion attempt might not be reused on subsequent
> inserts, resulting in gaps in the ROWID sequence. AUTOINCREMENT
> guarantees that automatically chosen ROWIDs will be increasing but not
> that they will be sequential."
>
> (fromhttp://www.sqlite.org/autoinc.html)
>
> Personally, I'd avoid making the assumptions on the primary key values,
> and do your updates based on real primary keys. But, that's just me.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Training in Germany, 18-22 January 2010:http://bignerdranch.com

-- 
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: RESET SQLite AUTOINCREMENT

2009-11-20 Thread JasonMP
I use a do/while that runs through one of my tables based on the
number of entries on another table and makes changes.

Example:

Integer i = 1;

Cursor c = db.querryFunction();
Integer rowCount = c.getCount();

do{
//does work on the database
db.updateRow(table, args, KEY_ROWID + "=" + i, null);
i++;
}
while(i <= rowCount);


if my autoincrements skips numbers then I can get an error trying to
update a row that doesn't exist.


On Nov 20, 8:47 am, Mark Murphy  wrote:
> JasonMP wrote:
> > I need my rows in my
> > database to stay ascending and in increments of 1.
>
> Why?
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Warescription: Three Android Books, Plus Updates, $35/Year

-- 
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] RESET SQLite AUTOINCREMENT

2009-11-20 Thread JasonMP
Hello, I have a database that will be editable inside my android app.
I'm having an issue where when a row is deleted, its spot in the
autoincrement array is still taken, and subsequent entries into that
table pick up after that number.  This leaves me with a list of rows
whos autoincrement id values can jump around.  I need my rows in my
database to stay ascending and in increments of 1.  Is there an easy
way to do this?  Or will I need to rewrite the autoincrement column to
all my rows each time an item is deleted?

-- 
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] Need help with using multiple views within a Listview

2009-11-14 Thread JasonMP
Hi all,

I,m trying to build a custom Listview and Adapter to populate the
screen with items from a database.  I need to have a checkbox in each
view that when clicked will display a number in a textview from the
database within that particular Listview item, and then also update
the checked status in the database.  Anyone have an example of how I
could make this work?

-- 
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] no reply from android beginners....can anyone help?

2009-10-19 Thread JasonMP

Im trying to fill a spinner with data from a table.  That part works
fine.  What i cant figure out is how to use the selection made
through
the spinner.  if i use :
 String someString = (String) classSpin.getSelectedItem().toString();
i get some sort of SQL reference.  Am i missing a step?  Im new to
both java and android so i hope this is something very obvious im
missing.
heres some of my code for the spinner:
Cursor classCur = db.getClasses();
startManagingCursor(classCur);
from = new String[]{DBAdapterStats2.KEY_CLASS};
to = new int[]{android.R.id.text1};
SimpleCursorAdapter classAdapter = new SimpleCursorAdapter(this,
android.R.layout.simple_spinner_item, classCur, from, to);
classAdapter.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
classSpin.setAdapter(classAdapter);

--~--~-~--~~~---~--~~
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] R.java not compiling properly? need help :(

2009-10-09 Thread JasonMP

Im having an issue with Eclipse where it will suddenly not be able to
read my R.java file and all of my resource references get errors.  Ive
tried doing a fresh install of Eclipse and that did not help.
Rebuilding apps does not help.  Fixing project properties does not
help.  Here's an example of one of my errors within my R.java {Illegal
modifier for the class id; only public, abstract & final are
permitted}...there arent any modifiers other than what is permitted b/
c its automatically generated and i cant edit it.  What in the world
have I done?  And is there a way to fix it?
--~--~-~--~~~---~--~~
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] Editing Strings.xml from inside .java

2009-10-05 Thread JasonMP

Is it possible to edit a string in my strings.xml from within my java
code?  I'd like my app_name to be changed dynamically based off of
user input.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---