[android-developers] List view and using a loader

2016-12-14 Thread Sebastian Prax
Hello, i have problem with using this code: 
developer.android.com/guide/topics/ui/layout/listview.html
I used the code, everything same, but i had error at this part:

getLoaderManager().initLoader(0, null, this);


This is exception. It has problem with "this":

(MainActivity looking like: public class MainActivity extends ListActivity 
implements LoaderManager.LoaderCallbacks)

Error:(71, 27) error: method initLoader in class LoaderManager cannot be 
applied to given types;
required: int,Bundle,LoaderCallbacks
found: int,,MainActivity
reason: cannot infer type-variable(s) D
(argument mismatch; MainActivity cannot be converted to LoaderCallbacks)
where D is a type-variable:
D extends Object declared in method 
initLoader(int,Bundle,LoaderCallbacks)

Okey, so i tried to make new loader like:

android.app.LoaderManager.LoaderCallbacks loader = new 
android.app.LoaderManager.LoaderCallbacks() {

public Loader onCreateLoader(int id, Bundle args) {
return new CursorLoader(getApplicationContext(), 
ContactsContract.Data.CONTENT_URI,
PROJECTION, SELECTION, null, null);
}

public void onLoadFinished(Loader loader, Cursor data) {
mAdapter.swapCursor(data);
}

public void onLoaderReset(Loader loader) {
mAdapter.swapCursor(null);
}
}

And used "loader" instead of "this" (initLoader(0, null, loader)), but i 
wasnt working too, because of incompatibilty Loader and CursorLoader
 in:

public Loader onCreateLoader(int id, Bundle args) {
return new CursorLoader(getApplicationContext(), 
ContactsContract.Data.CONTENT_URI,
PROJECTION, SELECTION, null, null);

}

Please, can someone help me with solving this problem? 
Thanks very much, Sebastian :)

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/bc7acca8-e81c-4467-a927-75fbfd3cee4f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[android-developers] List View View Replicated when scrolling down and movie the stroller towards to up.

2012-08-16 Thread Gourab Singha
List View View Replicated when scrolling down and movie the stroller 
towards to up.   How i Solve 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] list view doubt

2012-05-08 Thread Jagadeesh
Hi

in my list view i need to expand clicking on item need expand

List
samsung-another page should populate ---here i need specify one hyperlink
philips  -another page should populate here i need specify one
hyperlink


can any one give idea how i need to do

/// here my code

public class CompaniesActivity extends ListActivity {
public ListView lv;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setListAdapter(new ArrayAdapterString(this,
android.R.layout.simple_list_item_1, LISTITEMS));

lv = getListView();
lv.setTextFilterEnabled(true);

lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView? parent, View view, int
position,long id) {


}
});
}
static final String[] LISTITEMS = new String[] {
Philips Healthcare, samsung, siemens Healthcare, 
mindtree
};


}

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


Re: [android-developers] list view doubt

2012-05-08 Thread Jim Graham
On Wed, May 09, 2012 at 07:49:41AM +0530, Jagadeesh wrote:
 
 in my list view i need to expand clicking on item need expand
 
 List
 samsung-another page should populate ---here i need specify one hyperlink
 philips  -another page should populate here i need specify one
 hyperlink

If I understand correctly, you want the selection of one item to select
one link, and another item selects another link (and so on, I assume).
Ok.  Well, unless you left some bits in this code out, here's the problem:

  lv.setOnItemClickListener(new OnItemClickListener() {
 public void onItemClick(AdapterView? parent,
   View view, int position,long id) {


Where's the code that should be here, getting and reacting to the
selection made by the user?  Did you just leave this out?  Or is it
just not there in the first place?  If the former, something is wrong
in the code that goes here, but nobody can tell you more than that, as
you left it out, and nobody (as far as I know...) can read your mind.
If the latter, u...well, that would be THE problem.


 }
 });

 static final String[] LISTITEMS = new String[] {
   Philips Healthcare, samsung, siemens Healthcare, mindtree
 };

Later,
   --jim

-- 
THE SCORE:  ME:  2  CANCER:  0
73 DE N5IAL (/4)MiSTie #49997   Running FreeBSD 7.0 
spooky1...@gmail.com ICBM/Hurricane: 30.44406N 86.59909W

sigh, once upon a time T-1 was fast
   --seen in alt.sysadmin.net-abuse.email

Android Apps Listing at http://www.jstrack.org/barcodes.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] List view row background.

2012-04-09 Thread Put_tiMe
I want to add a background image for each row of a list-view control.
I have written a custom adapter for the list view.
 
What is the best way of doing 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

Re: [android-developers] List view row background.

2012-04-09 Thread Bin Yang
Define common list item layout file.
Using  LayoutInflater to create view of Adpater.

在 2012年4月9日 下午4:30,Put_tiMe putt...@gmail.com写道:

 I want to add a background image for each row of a list-view control.
 I have written a custom adapter for the list view.

 What is the best way of doing 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

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

Re: [android-developers] List view row background.

2012-04-09 Thread Farhan Tariq
In the getView method of the adapter, use the index of the row to set
background to. Suppose every row is a textView, then
textView.setBackgroundColor(Color.BLACK) would do the trick.
For different indices, you could do this...

public View getView(int index, View convertView, ViewGroup parent) {

textView.setText()
...
...

if(index %2 == 0){
textView.setBackgroundColor(Color.BLACK);
}else{
textView.setBackgroundColor(Color.BLUE);
}

return textView;
}

Something like that I guess is what you are looking for. Hope that helps
On Mon, Apr 9, 2012 at 1:30 PM, Put_tiMe putt...@gmail.com wrote:

 I want to add a background image for each row of a list-view control.
 I have written a custom adapter for the list view.

 What is the best way of doing 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

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

Re: [android-developers] List view row background.

2012-04-09 Thread Put_tiMe
I also need to change the drawable when a listview item is selected.
 
How can I achieve this?

On Monday, April 9, 2012 2:19:39 PM UTC+5:30, bin yang wrote:

 Define common list item layout file. 
 Using  LayoutInflater to create view of Adpater.

 在 2012年4月9日 下午4:30,Put_tiMe putt...@gmail.com写道:

 I want to add a background image for each row of a list-view control.
 I have written a custom adapter for the list view.
  
 What is the best way of doing 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




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

Re: [android-developers] List view row background.

2012-04-09 Thread Put_tiMe
Ok, I kind of got it together.
 
For the row, I'm setting the background to my bitmap image.
For selection, I'm setting the ListView attribute:
android:listSelector=@drawable/xxx
 
 
It kind of works. But I can't see the selection.
i.e. when a row is selected (or clicked) I don't see the color change.
This happens when I set the background for the rows.
 
To counter that I tried setting this attr: android:drawSelectorOnTop=true
 
But the problem with that is that the row contents are completely hidden.
 
What should I do in this case?
 
 

On Monday, April 9, 2012 3:39:13 PM UTC+5:30, Put_tiMe wrote:

 I also need to change the drawable when a listview item is selected.
  
 How can I achieve this?

 On Monday, April 9, 2012 2:19:39 PM UTC+5:30, bin yang wrote:

 Define common list item layout file. 
 Using  LayoutInflater to create view of Adpater.

 在 2012年4月9日 下午4:30,Put_tiMe putt...@gmail.com写道:

 I want to add a background image for each row of a list-view control.
 I have written a custom adapter for the list view.
  
 What is the best way of doing 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




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

Re: [android-developers] List view row background.

2012-04-09 Thread Put_tiMe
I have another issue that I'm facing.
 
I have registered for a callback on item click.
Whenever I click on a row, it remains selected.
I want to clear the selection. How do I do it?
 
I tried various functions, but none of them worked.
 
 

On Monday, April 9, 2012 4:01:43 PM UTC+5:30, Put_tiMe wrote:

 Ok, I kind of got it together.
  
 For the row, I'm setting the background to my bitmap image.
 For selection, I'm setting the ListView attribute:
 android:listSelector=@drawable/xxx
  
  
 It kind of works. But I can't see the selection.
 i.e. when a row is selected (or clicked) I don't see the color change.
 This happens when I set the background for the rows.
  
 To counter that I tried setting this attr: android:drawSelectorOnTop=true
  
 But the problem with that is that the row contents are completely hidden.
  
 What should I do in this case?
  
  

 On Monday, April 9, 2012 3:39:13 PM UTC+5:30, Put_tiMe wrote:

 I also need to change the drawable when a listview item is selected.
  
 How can I achieve this?

 On Monday, April 9, 2012 2:19:39 PM UTC+5:30, bin yang wrote:

 Define common list item layout file. 
 Using  LayoutInflater to create view of Adpater.

 在 2012年4月9日 下午4:30,Put_tiMe putt...@gmail.com写道:

 I want to add a background image for each row of a list-view control.
 I have written a custom adapter for the list view.
  
 What is the best way of doing 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




-- 
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] List view is not perform selection

2012-02-15 Thread Sathya g
List view is not clikable when i am using cutombase adapter i.e using
cutom view for list view. i mention in listview as
android:focusable=true its not perform even selection operation...
please help me to achieve this selection

-- 
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] List View with Check box multiselection

2012-01-10 Thread chander
Hi all,

In my application, i created a custom file adapter and i am using
ListView with checkboxes, upto this point everything working great.
But now i have to take the values of Checked listView items in an
Array list. In my list view, i am listing Files present on the SD card
so i have to take Files for further processing by storing it in an
Array List.

I am confused here how i pass multiple files for the processing, can
someone help me in how i pass checked Files to further processing, or
do i need to change my FileAdapter also ?

My Adapter class code :--

public class FileAdapter extends ArrayAdapterFile
{
  Context context;
  File[] files;
  CheckBox Check;


  public FileAdapter(Context context, File[] files)
  {
super(context, -1, files);
this.context = context;
this.files = files;


  }


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


Re: [android-developers] List View with Check box multiselection

2012-01-10 Thread Mukesh Srivastav
Hi Chander,

I wish if i could help with the whole source. The problem is the design.

let me tell you the real approach.

1. create a model class which holds the data that is name and checkbox with
setters and getters. below is the example

/** Holds Music data. */
private static class Music {
private String name = ;
private boolean checked = false;

public Music() {
}

  have the setters and getters for name and checked

2.Create a View adapter class which holds the child view data. below is the
example

private static class MusicViewHolder {
private CheckBox checkBox;
private TextView textView;

public MusicViewHolder() {
}

public MusicViewHolder(TextView textView, CheckBox checkBox) {
this.checkBox = checkBox;
this.textView = textView;
}

public CheckBox getCheckBox() {
return checkBox;
}

public void setCheckBox(CheckBox checkBox) {
this.checkBox = checkBox;
}

public TextView getTextView() {
return textView;
}

public void setTextView(TextView textView) {
this.textView = textView;
}
}


3. your custom adapter  which actally extends the Arrayadapter should be
like this

/** Custom adapter for displaying an array of Music objects. */
private static class MusicArrayAdapter extends ArrayAdapterMusic {

private LayoutInflater inflater;

public MusicArrayAdapter(Context context, ListMusic musicList) {
super(context, R.layout.simplerow, R.id.rowTextView, musicList);
// Cache the LayoutInflate to avoid asking for a new one each time.
inflater = LayoutInflater.from(context);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
// Music to display
Music music = (Music) this.getItem(position);

// The child views in each row.
CheckBox checkBox;
TextView textView;

// Create a new row view
if (convertView == null) {
convertView = inflater.inflate(R.layout.simplerow, null);

// Find the child views.
textView = (TextView) convertView
.findViewById(R.id.rowTextView);
textView.setTextColor(Color.BLACK);
checkBox = (CheckBox) convertView.findViewById(R.id.CheckBox01);

 convertView.setTag(new MusicViewHolder(textView, checkBox));

 checkBox.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v;
Music music = (Music) cb.getTag();
music.setChecked(cb.isChecked());
}
});
}
 else {
 MusicViewHolder viewHolder = (MusicViewHolder) convertView
.getTag();
checkBox = viewHolder.getCheckBox();
textView = viewHolder.getTextView();
}

 checkBox.setTag(music);

 checkBox.setChecked(music.isChecked());
textView.setText(music.getName());

return convertView;
}

}


4.finally your setItemclicklisteners should be

Music music = listAdapter.getItem(position);
music.toggleChecked();
MusicViewHolder viewHolder = (MusicViewHolder) item
.getTag();
viewHolder.getCheckBox().setChecked(music.isChecked());



That's it. as i said, i have done this earlier, it requries the whole
process. bascially you need to create and store the data in private Music[]
musiclistarray;


Warm Regards,
*Mukesh Kumar*,
Android Consultant/Freelancer,
India,Hyderabad.

On Wed, Jan 11, 2012 at 12:11 PM, chander mohan.c...@gmail.com wrote:

 Hi all,

 In my application, i created a custom file adapter and i am using
 ListView with checkboxes, upto this point everything working great.
 But now i have to take the values of Checked listView items in an
 Array list. In my list view, i am listing Files present on the SD card
 so i have to take Files for further processing by storing it in an
 Array List.

 I am confused here how i pass multiple files for the processing, can
 someone help me in how i pass checked Files to further processing, or
 do i need to change my FileAdapter also ?

 My Adapter class code :--

 public class FileAdapter extends ArrayAdapterFile
 {
  Context context;
  File[] files;
  CheckBox Check;


  public FileAdapter(Context context, File[] files)
  {
super(context, -1, files);
this.context = context;
this.files = files;


  }


 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




--

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

Re: [android-developers] List View with Check box multiselection

2012-01-10 Thread Chander mourya
Hello mukesh, thanks a lot, i will try the same procedure as you described
Thanks

On 1/11/12, Mukesh Srivastav mukicha...@gmail.com wrote:
 Hi Chander,

 I wish if i could help with the whole source. The problem is the design.

 let me tell you the real approach.

 1. create a model class which holds the data that is name and checkbox with
 setters and getters. below is the example

 /** Holds Music data. */
 private static class Music {
 private String name = ;
 private boolean checked = false;

 public Music() {
 }

   have the setters and getters for name and checked

 2.Create a View adapter class which holds the child view data. below is the
 example

 private static class MusicViewHolder {
 private CheckBox checkBox;
 private TextView textView;

 public MusicViewHolder() {
 }

 public MusicViewHolder(TextView textView, CheckBox checkBox) {
 this.checkBox = checkBox;
 this.textView = textView;
 }

 public CheckBox getCheckBox() {
 return checkBox;
 }

 public void setCheckBox(CheckBox checkBox) {
 this.checkBox = checkBox;
 }

 public TextView getTextView() {
 return textView;
 }

 public void setTextView(TextView textView) {
 this.textView = textView;
 }
 }


 3. your custom adapter  which actally extends the Arrayadapter should be
 like this

 /** Custom adapter for displaying an array of Music objects. */
 private static class MusicArrayAdapter extends ArrayAdapterMusic {

 private LayoutInflater inflater;

 public MusicArrayAdapter(Context context, ListMusic musicList) {
 super(context, R.layout.simplerow, R.id.rowTextView, musicList);
 // Cache the LayoutInflate to avoid asking for a new one each time.
 inflater = LayoutInflater.from(context);
 }

 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
 // Music to display
 Music music = (Music) this.getItem(position);

 // The child views in each row.
 CheckBox checkBox;
 TextView textView;

 // Create a new row view
 if (convertView == null) {
 convertView = inflater.inflate(R.layout.simplerow, null);

 // Find the child views.
 textView = (TextView) convertView
 .findViewById(R.id.rowTextView);
 textView.setTextColor(Color.BLACK);
 checkBox = (CheckBox) convertView.findViewById(R.id.CheckBox01);

  convertView.setTag(new MusicViewHolder(textView, checkBox));

  checkBox.setOnClickListener(new View.OnClickListener() {
 public void onClick(View v) {
 CheckBox cb = (CheckBox) v;
 Music music = (Music) cb.getTag();
 music.setChecked(cb.isChecked());
 }
 });
 }
  else {
  MusicViewHolder viewHolder = (MusicViewHolder) convertView
 .getTag();
 checkBox = viewHolder.getCheckBox();
 textView = viewHolder.getTextView();
 }

  checkBox.setTag(music);

  checkBox.setChecked(music.isChecked());
 textView.setText(music.getName());

 return convertView;
 }

 }


 4.finally your setItemclicklisteners should be

 Music music = listAdapter.getItem(position);
 music.toggleChecked();
 MusicViewHolder viewHolder = (MusicViewHolder) item
 .getTag();
 viewHolder.getCheckBox().setChecked(music.isChecked());



 That's it. as i said, i have done this earlier, it requries the whole
 process. bascially you need to create and store the data in private Music[]
 musiclistarray;


 Warm Regards,
 *Mukesh Kumar*,
 Android Consultant/Freelancer,
 India,Hyderabad.

 On Wed, Jan 11, 2012 at 12:11 PM, chander mohan.c...@gmail.com wrote:

 Hi all,

 In my application, i created a custom file adapter and i am using
 ListView with checkboxes, upto this point everything working great.
 But now i have to take the values of Checked listView items in an
 Array list. In my list view, i am listing Files present on the SD card
 so i have to take Files for further processing by storing it in an
 Array List.

 I am confused here how i pass multiple files for the processing, can
 someone help me in how i pass checked Files to further processing, or
 do i need to change my FileAdapter also ?

 My Adapter class code :--

 public class FileAdapter extends ArrayAdapterFile
 {
  Context context;
  File[] files;
  CheckBox Check;


  public FileAdapter(Context context, File[] files)
  {
super(context, -1, files);
this.context = context;
this.files = files;


  }


 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




 --

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


-- 
Chandra Mohan Mourya

-- 
You 

[android-developers] List View multiselection problem

2012-01-09 Thread chander
hi all,

I am creating an application in which i used a List view to list all
files present in SD card, but for some purpose i need to make ListView
checkable or selectable by user.
i created my own Array adapter of Files, i tried getChoiceMode
property as Multiselection but its not working. can someone help me in
correcting my code if there is any missing thing.

ListView listFiles;
FileAdapter adapter;
File[] files;   // Full path to the files
File file;  // Current file
 public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.filelist);

Home = this.getFilesDir();

// Finding Buttons for listing files

btnBack = (Button)findViewById(R.id.btnBack);
btnBack.setOnClickListener(this);

btnSDCard = (Button)findViewById(R.id.btnSDCard);
btnSDCard.setOnClickListener(this);

btnHome = (Button)findViewById(R.id.btnHome);
btnHome.setOnClickListener(this);

btnRoot = (Button)findViewById(R.id.btnRoot);
btnRoot.setOnClickListener(this);

listFiles = (ListView)findViewById(R.id.listFiles);
listFiles.setOnItemClickListener(this);

listFiles.setAdapter(new
ArrayAdapterFile(this,android.R.layout.simple_list_item_multiple_choice,files));
adapter = new FileAdapter(this,files);
listFiles.setAdapter(adapter);
listFiles.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}


When i am running this code its giving Null Pointer exception,can
someone help me how i rectify or correct this problem.


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


Re: [android-developers] List View multiselection problem

2012-01-09 Thread Mukesh Srivastav
Mohan, I have done this before, where i am reading all the music files in
SDCard and able to show it in Listview with checkbox.

Please follow the below points which will help you in resolving.

1. Create a class which extends the ArrayAdapter

2.In the getView method of the Adapterclass have the following.

// The child views in each row.
CheckBox checkBox;
TextView textView;

// Create a new row view
if (convertView == null) {
convertView = inflater.inflate(R.layout.simplerow, null);

// Find the child views.
textView = (TextView) convertView
.findViewById(R.id.rowTextView);
textView.setTextColor(Color.BLACK);
checkBox = (CheckBox) convertView.findViewById(R.id.CheckBox01);

 convertView.setTag(new MusicViewHolder(textView, checkBox));

 checkBox.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
CheckBox cb = (CheckBox) v;
Music music = (Music) cb.getTag();
music.setChecked(cb.isChecked());
}
});
}



in onCreate bind the Adapter with your list.

listAdapter = new MusicArrayAdapter(this, musicList);
mainListView.setAdapter(listAdapter);


Warm Regards,
*Mukesh Kumar*,
Android Consultant/Freelancer,
India,Hyderabad



On Tue, Jan 10, 2012 at 11:09 AM, chander mohan.c...@gmail.com wrote:

 hi all,

 I am creating an application in which i used a List view to list all
 files present in SD card, but for some purpose i need to make ListView
 checkable or selectable by user.
 i created my own Array adapter of Files, i tried getChoiceMode
 property as Multiselection but its not working. can someone help me in
 correcting my code if there is any missing thing.

ListView listFiles;
FileAdapter adapter;
File[] files;   // Full path to the files
File file;  // Current file
  public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.filelist);

Home = this.getFilesDir();

// Finding Buttons for listing files

btnBack = (Button)findViewById(R.id.btnBack);
btnBack.setOnClickListener(this);

btnSDCard = (Button)findViewById(R.id.btnSDCard);
btnSDCard.setOnClickListener(this);

btnHome = (Button)findViewById(R.id.btnHome);
btnHome.setOnClickListener(this);

btnRoot = (Button)findViewById(R.id.btnRoot);
btnRoot.setOnClickListener(this);

listFiles = (ListView)findViewById(R.id.listFiles);
listFiles.setOnItemClickListener(this);

listFiles.setAdapter(new

 ArrayAdapterFile(this,android.R.layout.simple_list_item_multiple_choice,files));
adapter = new FileAdapter(this,files);
listFiles.setAdapter(adapter);
listFiles.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
 }


 When i am running this code its giving Null Pointer exception,can
 someone help me how i rectify or correct this problem.


 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




-- 
.

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

Re: [android-developers] List View multiselection problem

2012-01-09 Thread Chander mourya
Thanks a lot mukesh, it worked


On 1/10/12, Mukesh Srivastav mukicha...@gmail.com wrote:
 Mohan, I have done this before, where i am reading all the music files in
 SDCard and able to show it in Listview with checkbox.

 Please follow the below points which will help you in resolving.

 1. Create a class which extends the ArrayAdapter

 2.In the getView method of the Adapterclass have the following.

 // The child views in each row.
 CheckBox checkBox;
 TextView textView;

 // Create a new row view
 if (convertView == null) {
 convertView = inflater.inflate(R.layout.simplerow, null);

 // Find the child views.
 textView = (TextView) convertView
 .findViewById(R.id.rowTextView);
 textView.setTextColor(Color.BLACK);
 checkBox = (CheckBox) convertView.findViewById(R.id.CheckBox01);

  convertView.setTag(new MusicViewHolder(textView, checkBox));

  checkBox.setOnClickListener(new View.OnClickListener() {
 public void onClick(View v) {
 CheckBox cb = (CheckBox) v;
 Music music = (Music) cb.getTag();
 music.setChecked(cb.isChecked());
 }
 });
 }



 in onCreate bind the Adapter with your list.

 listAdapter = new MusicArrayAdapter(this, musicList);
 mainListView.setAdapter(listAdapter);


 Warm Regards,
 *Mukesh Kumar*,
 Android Consultant/Freelancer,
 India,Hyderabad



 On Tue, Jan 10, 2012 at 11:09 AM, chander mohan.c...@gmail.com wrote:

 hi all,

 I am creating an application in which i used a List view to list all
 files present in SD card, but for some purpose i need to make ListView
 checkable or selectable by user.
 i created my own Array adapter of Files, i tried getChoiceMode
 property as Multiselection but its not working. can someone help me in
 correcting my code if there is any missing thing.

ListView listFiles;
FileAdapter adapter;
File[] files;   // Full path to the files
File file;  // Current file
  public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.filelist);

Home = this.getFilesDir();

// Finding Buttons for listing files

btnBack = (Button)findViewById(R.id.btnBack);
btnBack.setOnClickListener(this);

btnSDCard = (Button)findViewById(R.id.btnSDCard);
btnSDCard.setOnClickListener(this);

btnHome = (Button)findViewById(R.id.btnHome);
btnHome.setOnClickListener(this);

btnRoot = (Button)findViewById(R.id.btnRoot);
btnRoot.setOnClickListener(this);

listFiles = (ListView)findViewById(R.id.listFiles);
listFiles.setOnItemClickListener(this);

listFiles.setAdapter(new

 ArrayAdapterFile(this,android.R.layout.simple_list_item_multiple_choice,files));
adapter = new FileAdapter(this,files);
listFiles.setAdapter(adapter);
listFiles.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
 }


 When i am running this code its giving Null Pointer exception,can
 someone help me how i rectify or correct this problem.


 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




 --
 .

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


-- 
Chandra Mohan Mourya

-- 
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] List View Focus Problem!

2011-10-16 Thread abi
Hi,

I have a list view and a bottom bar in a layout. I can't focus the
bottom bar after focusing the list view.
How to find focus lost from list view. At that time I need to focus
that bottom bar.

Please Suggest...

Regards,
Abi

-- 
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] List View based on Database Cursor Not Showing Full Screen and Scrolling

2011-07-27 Thread usafrmajor
I am having a problem getting my list view based on retrieved data
from a database to show the full screen and scroll.  For some reason
neither the fill_parent or wrap_content values for my layout height
setting is being recognized. Right now my view only shows about a
quarter of the screen.  However, if I put in a hard codded number for
the height it works, but that is not a good solution because the user
can enter unlimited number of entries that could be displayed on the
list.   Without the hard coded size I can see that something is being
displayed behind the list for a couple seconds.  I am assuming it is
an error message but cannot figure out how to find out what it is
saying.

It worked correctly at one time but I cannot figure out what now is
preventing the screen from using the whole size with scrolling if
needed.  The code I use is below.

---

?xml version=1.0 encoding=utf-8?
LinearLayout xmlns:android=http://schemas.android.com/apk/res/
android
 android:orientation=vertical
 android:layout_width=fill_parent
 android:layout_height=fill_parent
 
 ListView
 android:id=@android:id/list
 android:layout_width=fill_parent
 android:layout_height=1600px // tired fill_parent and
wrap_content as well
 android:padding=5px/
 TextView android:id=@android:id/empty
 android:layout_width=fill_parent
 android:layout_height=fill_parent
 android:gravity=center
 android:text=No Locations Have Been Marked /

 /LinearLayout


?xml version=1.0 encoding=utf-8?
  LinearLayout xmlns:android=http://schemas.android.com/apk/res/
android
  android:layout_width=match_parent
  android:layout_height=wrap_content
  android:orientation=vertical
  android:background=#89B6FF 

  TextView android:id=@+id/loc_id
  android:layout_width=match_parent
  android:layout_height=wrap_content
  android:textColor=#00
  android:text=LOC ID: 
  android:textStyle=bold /

  TextView android:id=@+id/display
  android:layout_width=match_parent
  android:layout_height=wrap_content
  android:textColor=#00/

 /LinearLayout


super.onCreate(savedInstanceState);
setContentView(R.layout.main_selected);
Criteria locationCriteria = new Criteria();

  locationCriteria.setAccuracy(Criteria.ACCURACY_FINE);
MapBack.loc_manager.requestLocationUpdates(MapBack.loc_manager.getBestProvider(locationCriteria,
true), 0, 0, MapBack.loc_listener);

try
 {
  lv_err_msg = Error creating DB Adapter;
  DBAdapter db = new DBAdapter(this);

  lv_err_msg = Error retrieving DB Cursor;
  db.open();
  lv_cursor = db.getAllLocations();

  lv_err_msg = Error starting Cursor Manager;
  startManagingCursor(lv_cursor);

  String[] from = new String[] { loc_display ,_id };
  int[] to = new int[] { R.id.display ,R.id.loc_id };

  lv_err_msg = Error creating Simple Cursor Adapter;
  final SimpleCursorAdapter LocationList = new SimpleCursorAdapter
  ( this
   
,R.layout.main_selected_row
   ,lv_cursor
   ,from
   ,to);

  lv_err_msg = Error setting List Adapter;
  setListAdapter(LocationList);
  lv_err_msg = Error setting up ArrayAdapter data set changed;
  lv_adapter = ((SimpleCursorAdapter)getListAdapter());
  db.close();

  int lv_height = LocationList.getCount() * 120;

  lv_err_msg = Error setting up list Action Selections;
  ListView lv = getListView();
  lv.setOnItemClickListener(new AdapterView.OnItemClickListener()
   {
public void onItemClick(AdapterView? av, View v, int pos, long
id)
 { show_action_list(LocationList,v,pos,id); }
});
 }
catch (Exception e)
 {
  AlertDialog.Builder DrawListAlertBox = new
AlertDialog.Builder(this);
  DrawListAlertBox.setMessage(lv_err_msg +  -  + e);
  DrawListAlertBox.setNeutralButton(OK, new
DialogInterface.OnClickListener() {
  public void onClick(DialogInterface arg0, int arg1) { } } );
  DrawListAlertBox.show();
 }

-- 
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] List View and Simple Cursor Adapter

2011-07-16 Thread juliagrig
Hi all,

I have a listview in my app and a SimpleCursor Adapter in a different
class. In getView method I tried to  set properties fom the text view
of each list item.
It works fine, but I have a log.i(,) message in the end of the
getView() method and I see that this method run 3 times.
 So , I see in the logat

07-16 07:48:58.401: INFO/(341): GetView done
07-16 07:48:58.421: INFO/(341): GetView done
07-16 07:48:58.541: INFO/(341): GetView done

Why is this happening?

Thanks in advance.

-- 
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] List View and Simple Cursor Adapter

2011-07-16 Thread juliagrig
Hi all,

I have a listview in my app and a SimpleCursor Adapter in a different
class. In getView method I tried to  set properties fom the text view
of each list item.
It works fine, but I have a log.i(,) message in the end of the
getView() method and I see that this method run 3 times.
 So , I see in the logat

07-16 07:48:58.401: INFO/(341): GetView done
07-16 07:48:58.421: INFO/(341): GetView done
07-16 07:48:58.541: INFO/(341): GetView done

Why is this happening?

Thanks in advance.

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


Re: [android-developers] List View and Simple Cursor Adapter

2011-07-16 Thread Mark Murphy
getView() will be called many times, not necessarily only the number
of times you might expect or in the order you expect. Please just make
your getView() implementation be efficient and let Android call
getView() as it sees fit.

On Sat, Jul 16, 2011 at 3:56 AM, juliagrig iouliag...@gmail.com wrote:
 Hi all,

 I have a listview in my app and a SimpleCursor Adapter in a different
 class. In getView method I tried to  set properties fom the text view
 of each list item.
 It works fine, but I have a log.i(,) message in the end of the
 getView() method and I see that this method run 3 times.
  So , I see in the logat

 07-16 07:48:58.401: INFO/(341): GetView done
 07-16 07:48:58.421: INFO/(341): GetView done
 07-16 07:48:58.541: INFO/(341): GetView done

 Why is this happening?

 Thanks in advance.

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




-- 
Mark Murphy (a Commons Guy) http://commonsware.com |
http://github.com/commonsguy http://commonsware.com/blog |
http://twitter.com/commonsguy Android Training...At Your Office:
http://commonsware.com/training

-- 
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] list view with alpha transparency effect

2011-06-18 Thread Greg Donald
I have a list view using a layout that has a background color of #8000.

When I scroll the list, the list item background color change to a
solid color, in this case black.  Seems it's ignoring the alpha
transparency value on scroll.

Is there a way to make it not do that?


Thanks.


-- 
Greg Donald
destiney.com | gregdonald.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


Re: [android-developers] list view with alpha transparency effect

2011-06-18 Thread Dianne Hackborn
Use this:

http://developer.android.com/reference/android/widget/AbsListView.html#setCacheColorHint(int)

http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:cacheColorHint

Note that doing this means that ListView can't use important drawing
optimizations, so on many devices this will cause scrolling to be noticeably
less smooth.

On Sat, Jun 18, 2011 at 10:27 AM, Greg Donald gdon...@gmail.com wrote:

 I have a list view using a layout that has a background color of #8000.

 When I scroll the list, the list item background color change to a
 solid color, in this case black.  Seems it's ignoring the alpha
 transparency value on scroll.

 Is there a way to make it not do that?


 Thanks.


 --
 Greg Donald
 destiney.com | gregdonald.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




-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

Re: [android-developers] list view with alpha transparency effect

2011-06-18 Thread Greg Donald
On Sat, Jun 18, 2011 at 1:48 PM, Dianne Hackborn hack...@android.com wrote:
 Use this:
 http://developer.android.com/reference/android/widget/AbsListView.html#setCacheColorHint(int)
 http://developer.android.com/reference/android/widget/AbsListView.html#attr_android:cacheColorHint

 Note that doing this means that ListView can't use important drawing
 optimizations, so on many devices this will cause scrolling to be noticeably
 less smooth.

The View passed to me in getView() in my CursorAdapter does not appear
to have setCacheColorHint().

Looks like setCacheColorHint() exists for the list view itself but my
problem is with list items, not the list.



-- 
Greg Donald
destiney.com | gregdonald.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


Re: [android-developers] list view with alpha transparency effect

2011-06-18 Thread Greg Donald
On Sat, Jun 18, 2011 at 3:09 PM, Greg Donald gdon...@gmail.com wrote:
 The View passed to me in getView() in my CursorAdapter does not appear
 to have setCacheColorHint().

 Looks like setCacheColorHint() exists for the list view itself but my
 problem is with list items, not the list.

I found something with a similar name but it doesn't work.

int color = Color.argb( 80, 0, 0, 0 );
v.setDrawingCacheBackgroundColor( color );



-- 
Greg Donald
destiney.com | gregdonald.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


Re: [android-developers] list view with alpha transparency effect

2011-06-18 Thread Romain Guy
You need to call setCacheColorHint() on the ListView itself. You need
do this only once.

On Sat, Jun 18, 2011 at 1:10 PM, Greg Donald gdon...@gmail.com wrote:
 On Sat, Jun 18, 2011 at 3:09 PM, Greg Donald gdon...@gmail.com wrote:
 The View passed to me in getView() in my CursorAdapter does not appear
 to have setCacheColorHint().

 Looks like setCacheColorHint() exists for the list view itself but my
 problem is with list items, not the list.

 I found something with a similar name but it doesn't work.

        int color = Color.argb( 80, 0, 0, 0 );
        v.setDrawingCacheBackgroundColor( color );



 --
 Greg Donald
 destiney.com | gregdonald.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




-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

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


Re: [android-developers] list view with alpha transparency effect

2011-06-18 Thread Greg Donald
On Sat, Jun 18, 2011 at 3:46 PM, Romain Guy romain...@android.com wrote:
 You need to call setCacheColorHint() on the ListView itself. You need
 do this only once.

Like this?

list = (ListView) findViewById( R.id.list );
int color = Color.argb( 80, 0, 0, 0 );
list.setCacheColorHint( color );

If that's what you meant, it makes it worse.  My list view items never
even become transparent again after scrolling now.



-- 
Greg Donald
destiney.com | gregdonald.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


Re: [android-developers] list view with alpha transparency effect

2011-06-18 Thread Romain Guy
You need to set the cache color hint to 0,0,0,0, not 80,0,0,0. And you
still set the background color of your items the way you want.

On Sat, Jun 18, 2011 at 2:59 PM, Greg Donald gdon...@gmail.com wrote:
 On Sat, Jun 18, 2011 at 3:46 PM, Romain Guy romain...@android.com wrote:
 You need to call setCacheColorHint() on the ListView itself. You need
 do this only once.

 Like this?

    list = (ListView) findViewById( R.id.list );
    int color = Color.argb( 80, 0, 0, 0 );
    list.setCacheColorHint( color );

 If that's what you meant, it makes it worse.  My list view items never
 even become transparent again after scrolling now.



 --
 Greg Donald
 destiney.com | gregdonald.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




-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

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


Re: [android-developers] list view with alpha transparency effect

2011-06-18 Thread Greg Donald
On Sat, Jun 18, 2011 at 5:49 PM, Romain Guy romain...@android.com wrote:
 You need to set the cache color hint to 0,0,0,0, not 80,0,0,0. And you
 still set the background color of your items the way you want.

Still black when scrolling, only becoming transparent after the
scrolling ends.  And a lot of the time I have to actually touch an
item to get the transparency back.

I'm just gonna go with solid black.  No flicker to worry about.  Thanks anyway.


-- 
Greg Donald
destiney.com | gregdonald.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] List view problem

2011-04-27 Thread Kumar Bibek
I have a list view which display multiple kinds of items (Basically
3).

I have overridden all the methods, and it works almost fine.

Basically, For those three types of views, I need to change the
gravity to either left/right or center (Simple TextViews).

This works.

In addition to this, I also have different background images for these
views. I don't understand why it doesn't work. It just picks up one
image and keeps setting it to random items, and for some, I don't even
get a background image.

getItemViewType(int position) - Overridden
getViewTypeCount() - Overridden (Always returns 3)

I was going through the docs, and I found this.

public int getViewTypeCount ()

Returns the number of types of Views that will be created by
getView(int, View, ViewGroup). Each type represents a set of views
that can be converted in getView(int, View, ViewGroup). If the adapter
always returns the same type of View for all items, this method should
return 1.

This method will only be called when when the adapter is set on the
the AdapterView.

Returns

The number of types of Views that will be created by this adapter

What exactly does this This method will only be called when when the
adapter is set on the the AdapterView. mean?


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


Re: [android-developers] List view problem

2011-04-27 Thread Mark Murphy
On Wed, Apr 27, 2011 at 2:17 PM, Kumar Bibek coomar@gmail.com wrote:
 getItemViewType(int position) - Overridden
 getViewTypeCount() - Overridden (Always returns 3)

 I was going through the docs, and I found this.

 public int getViewTypeCount ()

 Returns the number of types of Views that will be created by
 getView(int, View, ViewGroup). Each type represents a set of views
 that can be converted in getView(int, View, ViewGroup). If the adapter
 always returns the same type of View for all items, this method should
 return 1.

 This method will only be called when when the adapter is set on the
 the AdapterView.

 Returns

    The number of types of Views that will be created by this adapter

 What exactly does this This method will only be called when when the
 adapter is set on the the AdapterView. mean?

It means this method will only be called when setAdapter() is called
on the AdapterView.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 3.3 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


Re: [android-developers] List view problem

2011-04-27 Thread Kumar Bibek
Thanks Mark.

I don't really understand what it means. I have a list view, and I attach
the adapter through the setAdapter method of the ListView. Should I be doing
something else?

Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



On Wed, Apr 27, 2011 at 11:53 PM, Mark Murphy mmur...@commonsware.comwrote:

 On Wed, Apr 27, 2011 at 2:17 PM, Kumar Bibek coomar@gmail.com wrote:
  getItemViewType(int position) - Overridden
  getViewTypeCount() - Overridden (Always returns 3)
 
  I was going through the docs, and I found this.
 
  public int getViewTypeCount ()
 
  Returns the number of types of Views that will be created by
  getView(int, View, ViewGroup). Each type represents a set of views
  that can be converted in getView(int, View, ViewGroup). If the adapter
  always returns the same type of View for all items, this method should
  return 1.
 
  This method will only be called when when the adapter is set on the
  the AdapterView.
 
  Returns
 
 The number of types of Views that will be created by this adapter
 
  What exactly does this This method will only be called when when the
  adapter is set on the the AdapterView. mean?

 It means this method will only be called when setAdapter() is called
 on the AdapterView.

 --
 Mark Murphy (a Commons Guy)
 http://commonsware.com | http://github.com/commonsguy
 http://commonsware.com/blog | http://twitter.com/commonsguy

 _Android Programming Tutorials_ Version 3.3 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

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

Re: [android-developers] List view problem

2011-04-27 Thread Kostya Vasilyev

It probably means it won't be called by itself.

Re: background. A ListView changes its item's backgrounds at runtime to 
show selection state, so you should not be changing the background of 
the root view of your items.


As a workaround, inject another view group inside the item's top level 
layout, give it the same size, and change the background on that.


-- Kostya

27.04.2011 22:17, Kumar Bibek пишет:

What exactly does this This method will only be called when when the
adapter is set on the the AdapterView. mean?



--
Kostya Vasilyev -- http://kmansoft.wordpress.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


Re: [android-developers] List view problem

2011-04-27 Thread Mark Murphy
On Wed, Apr 27, 2011 at 2:29 PM, Kostya Vasilyev kmans...@gmail.com wrote:
 It probably means it won't be called by itself.

Precisely. Sometime after you call setAdapter(), then (and only then)
will getViewTypeCount() be called.

I'm not quite sure why they are emphasizing the point.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_Android Programming Tutorials_ Version 3.3 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


Re: [android-developers] List view problem

2011-04-27 Thread Kostya Vasilyev

27.04.2011 22:33, Mark Murphy пишет:

On Wed, Apr 27, 2011 at 2:29 PM, Kostya Vasilyevkmans...@gmail.com  wrote:

It probably means it won't be called by itself.

Precisely. Sometime after you call setAdapter(), then (and only then)
will getViewTypeCount() be called.


Right.


I'm not quite sure why they are emphasizing the point.


Long term goal - self-writing software, using some new Thought-To-Code 
service ?


:) :) :)

--
Kostya Vasilyev -- http://kmansoft.wordpress.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


Re: [android-developers] List view problem

2011-04-27 Thread Kumar Bibek
Hmm, I tried injecting a view group at the root of the items, but still it
doesn't work. Weird.
When I put logs, correct view types get returned, and morever, the gravity
stuff works fine, but the backgrounds just dont work.

Damn!! I thought I knew list views very well.

Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



On Thu, Apr 28, 2011 at 12:11 AM, Kostya Vasilyev kmans...@gmail.comwrote:

 27.04.2011 22:33, Mark Murphy пишет:

  On Wed, Apr 27, 2011 at 2:29 PM, Kostya Vasilyevkmans...@gmail.com
  wrote:

 It probably means it won't be called by itself.

 Precisely. Sometime after you call setAdapter(), then (and only then)
 will getViewTypeCount() be called.


 Right.


  I'm not quite sure why they are emphasizing the point.


 Long term goal - self-writing software, using some new Thought-To-Code
 service ?

 :) :) :)


 --
 Kostya Vasilyev -- http://kmansoft.wordpress.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


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

Re: [android-developers] List view problem

2011-04-27 Thread Kostya Vasilyev

27.04.2011 22:44, Kumar Bibek пишет:
Hmm, I tried injecting a view group at the root of the items, but 
still it doesn't work. Weird.


Did you adjust the code to change the background of this newly injected 
view group? And leave the root view group alone?


When I put logs, correct view types get returned, and morever, the 
gravity stuff works fine, but the backgrounds just dont work.


Damn!! I thought I knew list views very well.

Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



--
Kostya Vasilyev -- http://kmansoft.wordpress.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


Re: [android-developers] List view problem

2011-04-27 Thread Kumar Bibek
I am a little confused here.

I inflate a layout, which has a single TextView inside a LinearLayout.

In the adapter, I use the convertView to recycle views, so, now I don't try
to change the convertView's backgound, rather, I am now changing the
LinearLayout's background. I also tried to change the TextView's background.
Similar results. I have started feeling that there's a silly mistake
somewhere, which I am not able to detect. However, strangely enough, the
Logs say everything's fine.


Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



On Thu, Apr 28, 2011 at 12:19 AM, Kostya Vasilyev kmans...@gmail.comwrote:

 27.04.2011 22:44, Kumar Bibek пишет:

  Hmm, I tried injecting a view group at the root of the items, but still it
 doesn't work. Weird.


 Did you adjust the code to change the background of this newly injected
 view group? And leave the root view group alone?


  When I put logs, correct view types get returned, and morever, the gravity
 stuff works fine, but the backgrounds just dont work.

 Damn!! I thought I knew list views very well.

 Kumar Bibek
 http://techdroid.kbeanie.com
 http://www.kbeanie.com



 --
 Kostya Vasilyev -- http://kmansoft.wordpress.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


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

Re: [android-developers] List view problem

2011-04-27 Thread Kostya Vasilyev

What works for me is something like this:

res/layout/item_layout.xml

LinearLayout id=@+id/item_top
LinearLayout id=@+id/item_root
TextView1 TextView2 etc.
/LinearLayout
/LinearLayout

Now in getItem(), I change the background of R.id.item_root, not of 
R.id.item_top (which is left intact).


-- Kostya

27.04.2011 22:59, Kumar Bibek пишет:

I am a little confused here.

I inflate a layout, which has a single TextView inside a LinearLayout.

In the adapter, I use the convertView to recycle views, so, now I 
don't try to change the convertView's backgound, rather, I am now 
changing the LinearLayout's background. I also tried to change the 
TextView's background. Similar results. I have started feeling that 
there's a silly mistake somewhere, which I am not able to detect. 
However, strangely enough, the Logs say everything's fine.



Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



On Thu, Apr 28, 2011 at 12:19 AM, Kostya Vasilyev kmans...@gmail.com 
mailto:kmans...@gmail.com wrote:


27.04.2011 22:44, Kumar Bibek пишет:

Hmm, I tried injecting a view group at the root of the items,
but still it doesn't work. Weird.


Did you adjust the code to change the background of this newly
injected view group? And leave the root view group alone?


When I put logs, correct view types get returned, and morever,
the gravity stuff works fine, but the backgrounds just dont work.

Damn!! I thought I knew list views very well.

Kumar Bibek
http://techdroid.kbeanie.com
http://www.kbeanie.com



-- 
Kostya Vasilyev -- http://kmansoft.wordpress.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
mailto:android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
mailto:android-developers%2bunsubscr...@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 



--
Kostya Vasilyev -- http://kmansoft.wordpress.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] List view focus is not working

2011-04-18 Thread prakrati
Hi,

-- 
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] List view focus is not working

2011-04-18 Thread prakrati
Hi,
   I have created an app with three theme red, white and black
background and setting this theme in oncreate() activity

public void onCreate(Bundle savedInstanceState) {

switch (LaunchTheme.value) {

case X:
{
setTheme(R.style.WhiteBackground);
break;
}
case Y:
{
setTheme(R.style.BlackBackground);
break;
}
case Z:
{
setTheme(R.style.RedBackground);
break;
}
}


but my activity has list view after setting the theme my listview
focus will not work..any help how 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] List view focus is not working

2011-04-18 Thread prakrati
Hi,
   I have created an app with three theme red, white and black
background and setting this theme in oncreate() activity

public void onCreate(Bundle savedInstanceState) {

switch (LaunchTheme.value) {

case X:
{
setTheme(R.style.WhiteBackground);
break;
}
case Y:
{
setTheme(R.style.BlackBackground);
break;
}
case Z:
{
setTheme(R.style.RedBackground);
break;
}
}


but my activity has list view after setting the theme my listview
focus will not work..any help how 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] list view: scrolling resizes the items in a weird way

2011-03-24 Thread Erik
Hi,

I have a problem with the list view and its items. When scrolling up/
down the listview I noticed that the items slightly resize(about one
pixel) and in my application it looks like ^. The divider between two
items should be one pixel high(used default android behavior), but
when scrolling the divider is sometimes 2 pixels or 0 pixels(not
visible). This is bad since it looks like the two items form one list
item.

Has anyone a solution for this weird resizing problem when scrolling
inside a listview?

My development device is the HTC Wildfire with firmware version 2.1-
update1. Emulator is set to:Android 2.1-update1, skin WVGA800 and
hw.lcd.density=240.

?xml version=1.0 encoding=utf-8?
RelativeLayout
xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=?android:attr/listPreferredItemHeight
android:background=#F0F0F0
ImageView
android:id=@+id/test_icon
android:layout_height=fill_parent
android:layout_width=wrap_content
android:src=@drawable/icon
android:layout_alignParentRight=true
android:layout_alignParentTop=true
android:scaleType=centerInside
/ImageView
TextView
android:id=@+id/testTextView1
android:layout_width=fill_parent
android:layout_height=fill_parent
android:layout_alignParentTop=true
android:layout_alignWithParentIfMissing=true
android:layout_toLeftOf=@+id/test_icon
android:text=test
android:textColor=#55 /
/RelativeLayout


The ListView is filled with the following item layout and I used
default settings for the listview:

-- 
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] List view from database

2011-03-18 Thread Brad Stintson
I want to display two columns retrieved from database in a list view, which
can be clicked. How to do that?

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

Re: [android-developers] List view from database

2011-03-18 Thread Mark Murphy
Query the database and put the results in a CursorAdapter of some form.

Here is a sample project that does just that:

https://github.com/commonsguy/cw-android/tree/master/Database/Constants

On Fri, Mar 18, 2011 at 8:49 AM, Brad Stintson geek.bin...@gmail.com wrote:
 I want to display two columns retrieved from database in a list view, which
 can be clicked. How to do that?

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



-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
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] List View with multiple columns

2011-02-22 Thread Ganesh VK
i am  trying  to  add  multiple  columns ... will  please help me  out  for
 the  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

Re: [android-developers] List View with multiple columns

2011-02-22 Thread TreKing
On Thu, Feb 17, 2011 at 1:47 PM, Ganesh VK akkhi...@gmail.com wrote:

 i am  trying  to  add  multiple  columns ... will  please help me  out  for
  the  code..


http://developer.android.com/reference/android/widget/TableLayout.html

-
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

Re: [android-developers] List View with multiple columns

2011-02-22 Thread Ankit Kasliwal
Using Compound  view. for  showing multiple column in listview

On Wed, Feb 23, 2011 at 12:29 AM, TreKing treking...@gmail.com wrote:

 On Thu, Feb 17, 2011 at 1:47 PM, Ganesh VK akkhi...@gmail.com wrote:

 i am  trying  to  add  multiple  columns ... will  please help me  out
  for  the  code..


 http://developer.android.com/reference/android/widget/TableLayout.html


 -
 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




-- 

Thanks and Regards,

Ankit Kasliwal
kasliwalankit2...@gmail.com
+91-9300-940-136

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

Re: [android-developers] List view

2011-02-12 Thread TreKing
On Fri, Feb 11, 2011 at 11:25 PM, jubin jubinmeht...@gmail.com wrote:

 I want to create above type of view and want to dynamic this.


Read the documentation and play with some samples. Creating simple, static
layouts is Android 101.

-
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] List view

2011-02-11 Thread jubin
Hi,


How can i create the quiz type of view  on android using json ?

I want to create question and answers type view for example :

1) Q.What us xyz ?
1. option1 2.option2
3. option3 4. option4

I want to create above type of view and want to dynamic this.



Thanks,
Jubin Mehta

-- 
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] list view row number.

2011-01-06 Thread Amit Mangal
Hi Any one,
Is there any way to get row number in list view in which i clicked ? suppose
that if i clicked on row 5 how can i get which number of roe i clicked ?

thank you

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

Re: [android-developers] list view row number.

2011-01-06 Thread Kapil Lokhande
Hi Amit,

you have to override onListItemClick event in your activity extending
listactivity.
in that event you wull get position or row number of list item.
--
Thanks  Regards,
Kapil Lokhande | Dexter Advisory Pvt. Ltd. http://dexterltd.com/ | Android
Developer
[image: dexterlogo.jpg]


On Thu, Jan 6, 2011 at 5:04 PM, Amit Mangal forum.amit.man...@gmail.comwrote:

 Hi Any one,
 Is there any way to get row number in list view in which i clicked ?
 suppose that if i clicked on row 5 how can i get which number of roe i
 clicked ?

 thank you

  --
 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.comandroid-developers%2bunsubscr...@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=endexterlogo.jpg

Re: [android-developers] list view row number.

2011-01-06 Thread Amit Mangal
which function i need to call ?
do you have some code snippet i am new to android and don know any thing.

thank you

On Thu, Jan 6, 2011 at 5:58 PM, Kapil Lokhande kpl.lokha...@gmail.comwrote:

 Hi Amit,

 you have to override onListItemClick event in your activity extending
 listactivity.
 in that event you wull get position or row number of list item.
 --
 Thanks  Regards,
 Kapil Lokhande | Dexter Advisory Pvt. Ltd. http://dexterltd.com/ |
 Android Developer
 [image: dexterlogo.jpg]


 On Thu, Jan 6, 2011 at 5:04 PM, Amit Mangal 
 forum.amit.man...@gmail.comwrote:

 Hi Any one,
 Is there any way to get row number in list view in which i clicked ?
 suppose that if i clicked on row 5 how can i get which number of roe i
 clicked ?

 thank you

  --
 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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@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

Re: [android-developers] list view row number.

2011-01-06 Thread Kapil Lokhande
here is the snippet

import android.app.ListActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;

public class SimpleListView extends ListActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter(this,
android.R.layout.simple_list_item_1, WORLDCUP2010));
getListView().setTextFilterEnabled(true);
}

static final String[] WORLDCUP2010 = new String[] {
Algeria,  Argentina, Australia,
Brazil, Cote d'Ivoire, Cameroon,
Chile, Costa Rica, Denmark,
England, France, Germany,
Ghana,  Greece, Honduras,
Italy,  Japan, Netherlands,
New Zealand, Nigeria, North Korea,
Paraguay, Portugal,Serbia,
Slovakia, Slovenia, South Africa,
South Korea,  Spain, Switzerland,
United States, Uruguay };
}
public void onListItemClick(ListView parent, View v,
int position,long id) {
selection.setText(WORLDCUP2010[position]);
}

}

--
Thanks  Regards,
Kapil Lokhande | Dexter Advisory Pvt. Ltd. http://dexterltd.com/ | Android
Developer
[image: dexterlogo.jpg]


On Thu, Jan 6, 2011 at 6:05 PM, Amit Mangal forum.amit.man...@gmail.comwrote:

 which function i need to call ?
 do you have some code snippet i am new to android and don know any thing.

 thank you


 On Thu, Jan 6, 2011 at 5:58 PM, Kapil Lokhande kpl.lokha...@gmail.comwrote:

 Hi Amit,

 you have to override onListItemClick event in your activity extending
 listactivity.
 in that event you wull get position or row number of list item.
 --
 Thanks  Regards,
 Kapil Lokhande | Dexter Advisory Pvt. Ltd. http://dexterltd.com/ |
 Android Developer
 [image: dexterlogo.jpg]


 On Thu, Jan 6, 2011 at 5:04 PM, Amit Mangal 
 forum.amit.man...@gmail.comwrote:

 Hi Any one,
 Is there any way to get row number in list view in which i clicked ?
 suppose that if i clicked on row 5 how can i get which number of roe i
 clicked ?

 thank you

  --
 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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@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=endexterlogo.jpg

Re: [android-developers] list view row number.

2011-01-06 Thread Amit Mangal
thank you i am trying to get row number using this code.

On Thu, Jan 6, 2011 at 4:44 AM, Kapil Lokhande kpl.lokha...@gmail.comwrote:

 here is the snippet

 import android.app.ListActivity;
 import android.os.Bundle;
 import android.widget.ArrayAdapter;

 public class SimpleListView extends ListActivity
 {
 /** Called when the activity is first created. */

   @Override
   public void onCreate(Bundle savedInstanceState)
 {
   super.onCreate(savedInstanceState);
   setListAdapter(new ArrayAdapter(this,
   android.R.layout.simple_list_item_1, WORLDCUP2010));

   getListView().setTextFilterEnabled(true);
   }
   
   static final String[] WORLDCUP2010 = new String[] {
   Algeria,  Argentina, Australia,
   Brazil, Cote d'Ivoire, Cameroon,

   Chile, Costa Rica, Denmark,
   England, France, Germany,
   Ghana,  Greece, Honduras,
   Italy,  Japan, Netherlands,

   New Zealand, Nigeria, North Korea,
   Paraguay, Portugal,Serbia,
   Slovakia, Slovenia, South Africa,

   South Korea,  Spain, Switzerland,
   United States, Uruguay };
 }
 public void onListItemClick(ListView parent, View v,
   int position,long id) {

   selection.setText(WORLDCUP2010[position]);
   }
   
 }

 --
 Thanks  Regards,
 Kapil Lokhande | Dexter Advisory Pvt. Ltd. http://dexterltd.com/ |
 Android Developer
 [image: dexterlogo.jpg]


 On Thu, Jan 6, 2011 at 6:05 PM, Amit Mangal 
 forum.amit.man...@gmail.comwrote:

 which function i need to call ?
 do you have some code snippet i am new to android and don know any thing.

 thank you


 On Thu, Jan 6, 2011 at 5:58 PM, Kapil Lokhande kpl.lokha...@gmail.comwrote:

 Hi Amit,

 you have to override onListItemClick event in your activity extending
 listactivity.
 in that event you wull get position or row number of list item.
 --
 Thanks  Regards,
 Kapil Lokhande | Dexter Advisory Pvt. Ltd. http://dexterltd.com/ |
 Android Developer
 [image: dexterlogo.jpg]


 On Thu, Jan 6, 2011 at 5:04 PM, Amit Mangal forum.amit.man...@gmail.com
  wrote:

 Hi Any one,
 Is there any way to get row number in list view in which i clicked ?
 suppose that if i clicked on row 5 how can i get which number of roe i
 clicked ?

 thank you

  --
 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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@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

Re: [android-developers] list view row number.

2011-01-06 Thread Mark Murphy
The position parameter to the onListItemClick() method is the row number,
insofar as such a concept exists.

On Thu, Jan 6, 2011 at 7:51 AM, Amit Mangal forum.amit.man...@gmail.comwrote:

 thank you i am trying to get row number using this code.


 On Thu, Jan 6, 2011 at 4:44 AM, Kapil Lokhande kpl.lokha...@gmail.comwrote:

 here is the snippet

 import android.app.ListActivity;
 import android.os.Bundle;


 import android.widget.ArrayAdapter;

 public class SimpleListView extends ListActivity
 {
 /** Called when the activity is first created. */

  @Override
  public void onCreate(Bundle savedInstanceState)
 {
  super.onCreate(savedInstanceState);
  setListAdapter(new ArrayAdapter(this,
  android.R.layout.simple_list_item_1, WORLDCUP2010));



  getListView().setTextFilterEnabled(true);
  }
  
  static final String[] WORLDCUP2010 = new String[] {
  Algeria,  Argentina, Australia,
  Brazil, Cote d'Ivoire, Cameroon,



  Chile, Costa Rica, Denmark,
  England, France, Germany,
  Ghana,  Greece, Honduras,
  Italy,  Japan, Netherlands,



  New Zealand, Nigeria, North Korea,
  Paraguay, Portugal,Serbia,
  Slovakia, Slovenia, South Africa,



  South Korea,  Spain, Switzerland,
  United States, Uruguay };
 }
 public void onListItemClick(ListView parent, View v,
  int position,long id) {



  selection.setText(WORLDCUP2010[position]);
  }
  
 }

 --
 Thanks  Regards,
 Kapil Lokhande | Dexter Advisory Pvt. Ltd. http://dexterltd.com/ |
 Android Developer
 [image: dexterlogo.jpg]


 On Thu, Jan 6, 2011 at 6:05 PM, Amit Mangal 
 forum.amit.man...@gmail.comwrote:

 which function i need to call ?
 do you have some code snippet i am new to android and don know any thing.

 thank you


 On Thu, Jan 6, 2011 at 5:58 PM, Kapil Lokhande 
 kpl.lokha...@gmail.comwrote:

 Hi Amit,

 you have to override onListItemClick event in your activity extending
 listactivity.
 in that event you wull get position or row number of list item.
 --
 Thanks  Regards,
 Kapil Lokhande | Dexter Advisory Pvt. Ltd. http://dexterltd.com/ |
 Android Developer
 [image: dexterlogo.jpg]


 On Thu, Jan 6, 2011 at 5:04 PM, Amit Mangal 
 forum.amit.man...@gmail.com wrote:

 Hi Any one,
 Is there any way to get row number in list view in which i clicked ?
 suppose that if i clicked on row 5 how can i get which number of roe i
 clicked ?

 thank you

  --
 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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@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.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 2.3 Programming Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the 

Re: [android-developers] List View inside a Layout

2010-12-29 Thread Manoj Maurya
It will be done same way. I m working on similar thing. Exactly, where are
you stuck? You have to get listview's id and use set adapter in same way as
it is done for a normal listview.

Thanks
Manoj Kumar Maurya
 Hi all..

 What I want to do is:

 I have a layout with some textviews and buttons.

 I want to add to this layout a simple listView with a String, i mean.
 a simple ListView not a custom one.

 this is my layout more or less:

 Layout screen
 TextView/
 Button/
 ListView/
 /LayoutScreen

 So, I did a lot of google, but all the examples that i found is for an
 activity which layout only contains a ListView, simple or custom, but
 just only a ListView.

 In my case i don't know how to populate the my list View... I don't
 know what i am doing bad


 Can you help me?

 --
 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.comandroid-developers%2bunsubscr...@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] List View inside a Layout

2010-12-28 Thread Sergio Luceno
Hi all..

What I want to do is:

I have a layout with some textviews and buttons.

I want to add to this layout a simple listView with a String, i mean.
a simple ListView not a custom one.

this is my layout more or less:

Layout screen
TextView/
Button/
ListView/
/LayoutScreen

So, I did a lot of google, but all the examples that i found is for an
activity which layout only contains a ListView, simple or custom, but
just only a ListView.

In my case i don't know how to populate the my list View... I don't
know what i am doing bad


Can you help me?

-- 
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] List view selector states

2010-12-17 Thread Roman Mazur
Hi.
Is there some place where possible states of list view selector and items
are described?


-- 
Best regards,
Roman Mazur

Tech Lead at Stanfy (http://stanfy.com.ua)
Skype: roman.mazur.f
LinkedIn: http://ua.linkedin.com/in/romanmazur
Twitter: http://twitter.com/roman_mazur

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

Re: [android-developers] List view selector states

2010-12-17 Thread Kostya Vasilyev

If the resources provided with the SDK are any indication, they are:

disabled
focus
longpress
pressed

( look in android-sdk-windows\platforms\android-8\data\res\drawable-hdpi )

-- Kostya

17.12.2010 15:48, Roman Mazur пишет:

Hi.
Is there some place where possible states of list view selector and 
items are described?



--
Best regards,
Roman Mazur

Tech Lead at Stanfy (http://stanfy.com.ua)
Skype: roman.mazur.f
LinkedIn: http://ua.linkedin.com/in/romanmazur
Twitter: http://twitter.com/roman_mazur

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



--
Kostya Vasilyev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.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] list view two columns

2010-10-06 Thread Varun Khanduja
Hello all,

I am trying to see if someone can help me with a simple list view I am
tying to make. I am specifically facing problem trying to introduce a
new column in this list view. Label 3 in xml code below is the new
column I m trying to make. Should I have a new linear layout and wrap
two text views in it or is there some other option?


?xml version=1.0 encoding=utf-8?
LinearLayout xmlns:android=
   http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=wrap_content
android:orientation=horizontal
ImageView
android:id=@+id/icon
android:layout_width=22px
android:paddingLeft=2px
android:paddingRight=2px
android:paddingTop=2px
android:layout_height=wrap_content
android:src=@drawable/icon/
LinearLayout
android:layout_width=wrap_content
android:layout_height=wrap_content
android:orientation=vertical
TextView
android:id=@+id/label1
android:layout_width=wrap_content
android:layout_height=wrap_content
android:textSize=24sp/
TextView
android:id=@+id/label2
android:layout_width=wrap_content
android:layout_height=wrap_content
android:textSize=24sp/
TextView
android:id=@+id/label3
  android:layout_height=wrap_content
android:layout_width=wrap_content
android:layout_toRightOf=@+id/label1
android:textColor=#ffFFffFF
android:layout_marginRight=25dip
android:text=score
/

/LinearLayout
/LinearLayout

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


Re: [android-developers] list view two columns

2010-10-06 Thread TreKing
On Wed, Oct 6, 2010 at 12:55 PM, Varun Khanduja varunkhand...@gmail.comwrote:

 I am trying to see if someone can help me with a simple list view I am
 tying to make. I am specifically facing problem trying to introduce a new
 column in this list view. Label 3 in xml code below is the new column I m
 trying to make. Should I have a new linear layout and wrap two text views in
 it or is there some other option?


I'm not sure what you're trying to achieve. Pictures usually help with
layout problems. But if you want a column after the LinearLayout that has
two view, then do just that - add the new TextView after the inner
LinearLayout. That should be all you need.

-
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] List view with clickable items and clickable buttons in the items

2010-08-18 Thread newobj
Hi,

I'm trying to implement a list view where each item consists of some
text, an image, and two buttons. Clicking on the buttons should
perform one action (sharing in this case), and clicking anywhere
else in the item should perform another action (in this case, start
an activity to provide a more detailed view of the item.)

I can't seem to find the right combination of focus settings to allow
this. Out of the box I was getting clickable buttons but an otherwise
unclickable list item behind them. I added android:focusable=false
android:focusableInTouchMode=false to the buttons, and now I have a
clickable liste item in the background and the buttons are clickable,
except if i click the general list item area, BOTH buttons highlight
(and a I presume get click events?)

How can I set it up so that I can detect button clicks within the list
items as well as general/elsewhere clicks in the list item?

Thanks,
Brain

-- 
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] List View : text on left and right not working

2010-06-29 Thread elubin
In a ListView, I am trying to display some text on the left and a
number on the right.  I got it working with a RelativeView, but if the
text on the left is too long, my number doesn't appear?

http://www.elubin.com/images/Capture.jpg

Here is my layout:
LinearLayout
xmlns:android=http://schemas.android.com/apk/res/android;
android:layout_width=fill_parent
android:layout_height=wrap_content
android:orientation=horizontal
RelativeLayout xmlns:android=http://schemas.android.com/apk/res/
android
android:layout_width=fill_parent
android:layout_height=wrap_content
android:padding=6dip
TextView android:id=@+id/text1
android:textSize=18sp
android:layout_width=wrap_content
android:layout_height=wrap_content
android:gravity=left /

TextView android:id=@+id/text2
android:textSize=18sp
android:layout_width=fill_parent
android:layout_height=wrap_content
android:layout_toRightOf=@+id/text1
android:gravity=right  /
/RelativeLayout
/LinearLayout

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


Re: [android-developers] List View Item Strange Behavior

2010-04-09 Thread Agus
You are using convertView object which is a recycled view.

On Thu, Apr 8, 2010 at 2:42 AM, Binesy ross.bi...@gmail.com wrote:

 Hi,

 I have been having some strange behavior when refreshing a listview
 from a button in a list item.  Say you have a list of 4 items, indexes
 0-3 and you click on item 4, and print the index.  3 is printed
 correctly, then i refresh the list.  I click on item 4 again, but this
 time index 0 is printed, click again and we are back to 3.  Why is
 this happening and how can I fix it?

 I have included some source below for you to have a look at how I have
 done this.  Any help is much appreciated

 Binesy

 public class CrazyList extends Activity {

private static final String TAG = CRAZY LIST;

public class Item {
public String name = null;
public int counter = -1;

public Item(String n) {
name = n;
counter = 0;
}
}

private ArrayListItem names = null;
private MyAdapter adapter = null;


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

names = new ArrayListItem();
names.add(new Item(Ross));
names.add(new Item(Fred));
names.add(new Item(Bob));
names.add(new Item(Frank));

ListView list = (ListView)findViewById(R.id.ListView01);
adapter = new MyAdapter();
list.setAdapter(adapter);
}

private void updateButtonText(int index) {
names.get(index).counter++;
adapter.notifyDataSetChanged();
}

private class MyAdapter extends BaseAdapter {

@Override
public int getCount() {
return names.size();
}

@Override
public Object getItem(int position) {
return names.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView,
 ViewGroup
 parent) {
Container c = null;

if(convertView == null) {
convertView =
 View.inflate(getApplicationContext(), R.layout.item,
 null);
c = new Container();

c.text = (TextView)
 convertView.findViewById(R.id.TextView01);
c.button = (Button)
 convertView.findViewById(R.id.Button01);
c.button.setTag(position);

c.button.setOnClickListener(new
 OnClickListener() {

@Override
public void onClick(View v) {
int number =
 (Integer)v.getTag();
Log.d(TAG, Button clicked
 is  + number);
updateButtonText(number);
}
});

convertView.setTag(c);
}
else
c = (Container) convertView.getTag();

c.text.setText(names.get(position).name);
c.button.setText(names.get(position).counter + );

return convertView;
}

public class Container {
public TextView text = null;
public Button button = null;
 }
}
 }

 --
 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.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

 To unsubscribe, reply using remove me as the subject.


-- 
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] List View Item Strange Behavior

2010-04-08 Thread Binesy
Hi,

I have been having some strange behavior when refreshing a listview
from a button in a list item.  Say you have a list of 4 items, indexes
0-3 and you click on item 4, and print the index.  3 is printed
correctly, then i refresh the list.  I click on item 4 again, but this
time index 0 is printed, click again and we are back to 3.  Why is
this happening and how can I fix it?

I have included some source below for you to have a look at how I have
done this.  Any help is much appreciated

Binesy

public class CrazyList extends Activity {

private static final String TAG = CRAZY LIST;

public class Item {
public String name = null;
public int counter = -1;

public Item(String n) {
name = n;
counter = 0;
}
}

private ArrayListItem names = null;
private MyAdapter adapter = null;


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

names = new ArrayListItem();
names.add(new Item(Ross));
names.add(new Item(Fred));
names.add(new Item(Bob));
names.add(new Item(Frank));

ListView list = (ListView)findViewById(R.id.ListView01);
adapter = new MyAdapter();
list.setAdapter(adapter);
}

private void updateButtonText(int index) {
names.get(index).counter++;
adapter.notifyDataSetChanged();
}

private class MyAdapter extends BaseAdapter {

@Override
public int getCount() {
return names.size();
}

@Override
public Object getItem(int position) {
return names.get(position);
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup
parent) {
Container c = null;

if(convertView == null) {
convertView = 
View.inflate(getApplicationContext(), R.layout.item,
null);
c = new Container();

c.text = (TextView) 
convertView.findViewById(R.id.TextView01);
c.button = (Button) 
convertView.findViewById(R.id.Button01);
c.button.setTag(position);

c.button.setOnClickListener(new 
OnClickListener() {

@Override
public void onClick(View v) {
int number = 
(Integer)v.getTag();
Log.d(TAG, Button clicked is  
+ number);
updateButtonText(number);
}
});

convertView.setTag(c);
}
else
c = (Container) convertView.getTag();

c.text.setText(names.get(position).name);
c.button.setText(names.get(position).counter + );

return convertView;
}

public class Container {
public TextView text = null;
public Button button = null;
}
}
}

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

To unsubscribe, reply using remove me as the subject.


Re: [android-developers] List View Item Strange Behavior

2010-04-08 Thread ~ TreKing
On Thu, Apr 8, 2010 at 4:42 AM, Binesy ross.bi...@gmail.com wrote:

 3 is printed correctly, then i refresh the list.


Refresh the list how?
Also, what's the point of the Container class? AFAICT, it's completely
redundant and unnecessary.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

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

To unsubscribe, reply using remove me as the subject.


Re: [android-developers] List View Item Strange Behavior

2010-04-08 Thread ~ TreKing
On Thu, Apr 8, 2010 at 4:42 AM, Binesy ross.bi...@gmail.com wrote:

 Why is this happening and how can I fix it?


The ListView will re-use views it uses, as you see by the convertView. These
are not guaranteed to be in the same order as you scroll the list and items
are cycled, AFAIK.

My guess is your items are being re-arranged and you're seeing the behavior
you're seeing since you're not updating the tag on the button where you
store in the index.

I would recommend you completely update the view you're getting even if
there is an existing convertView.
In this case just do c.button.setTag(position) after the if / else clause
instead of inside the if clause.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
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] LIST VIEW

2010-02-08 Thread warrior
LIST VIEW
   1) Consider i have 7 items in a list view (and each item in a list
has in turn has many views like a image,and text views).
   2) Now when i use setListadapter() all the items in the list are
displayed in a same fashion.
  Now my ques is can i display each item in the List differently?
I mean to say that for the first item in the list i need the details
and the other items i just need one text view.
  how can i achieve this..?
  would be looking forward for your help
Thank you

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


Re: [android-developers] LIST VIEW

2010-02-08 Thread TreKing
On Fri, Feb 5, 2010 at 11:22 PM, warrior chandu.ku...@gmail.com wrote:

 Now my ques is can i display each item in the List differently?
 I mean to say that for the first item in the list i need the details
 and the other items i just need one text view.
  how can i achieve this..?


I haven't used it but I think the ListView has a headerView you can set
that's different that the main contents. Maybe that will work?
Or you can make a custom adapter and override the getView() function to
return the appropriate view for the position you're interested in.

-
TreKing - Chicago transit tracking app for Android-powered devices
http://sites.google.com/site/rezmobileapps/treking

-- 
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] List view with textviews and imageview, best practices

2009-12-10 Thread Patrick Plaatje
Hi All,

i'm developing an application which has an listview. I'm currently creating
the list item view dynamically from code (linearlayout, which includes 2
textviews and 1 imageview), but i'd like to use an XML resource for this. I
read it isresource intensive when getting this view using findViewById
within a loop. I thougth of using a custom adapter for this, but am not sure
on how to include lazy loading of the image then. Anyone has some
suggestions for this?

Regards,

Patrick

-- 
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] List view problem

2009-11-10 Thread c.a.jeffer...@googlemail.com
Hi,
I am using a list view and and the onListItemClick() method. The
problem I am having is that when I press the back button and tap on
another item on the list the position value stays the same. Has anyone
else encountered this problem?

thanks,

Clive

-- 
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] List View

2009-11-05 Thread Sasikumar.S
Hi,

When we r using list view. I got one problem.

my list view items:-

1. apple
2. bannana
3. super
4. supply
5. water

In that list if search is enabled,

when i'm searching for a text started with 's'
It will show only

super
supply

when i click the super.
I need the id of that.
super id is 3.
But i'm getting is 1.
B'coz when we searching for 's' super will become to first position.


Now i need how to get the super position is 3 when we search also.

can any one know about this?

Thanks in advance...


-- 
Thanks  Regards
Sasikumar.S

-- 
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] list view

2009-09-07 Thread Sasi Kumar

I have a list view with 2300 items.

When i'm using settextfilterenabled=true.

It is very slow to get the data.
there is any way to get the data very fast..
any one can suggess some idea for this.

thanks in andvance...
--~--~-~--~~~---~--~~
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] List View multiple choice slow to update

2009-08-13 Thread kec6227

I am having trouble with a list aspect of my app. Essentially, it has
a multiple choice listview(simple_list_item_multiple_choice) on the
right and a text view on the left.

When an item of the list view is checked off, I want to add it to the
text view or remove it if it gets unchecked. This almost works except
that the updates on what is checked seems to be one click behind.

I.E. check something off the first time and nothing happens. Uncheck
it or check something else and the first thing appears. Check below
the list choices (but still in the list view) and it updates.

I was not able to get setOnItemSelectedListener to respond as all, so
I am using onTouchListener:

private void loadContacts(){

String[] contacts = new String[] {People.NAME};
final String[] cols = new String[] {
Contacts.People.NAME,
Contacts.People._ID,
Contacts.People.NUMBER
  };

final Cursor C = getContentResolver().query
(People.CONTENT_URI, cols, null, null, null);
startManagingCursor(C);

lv = (ListView)findViewById(R.id.contact_list);
ListAdapter mAdapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_multiple_choice,
C,
cols,
new int[] {android.R.id.text1} );
lv.setAdapter(mAdapter);

tv = (TextView)findViewById(R.id.contact_text);

lv.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
chosen = lv.getCheckedItemPositions();
updateAttendance(chosen, C);
//C.moveToPosition(lv.getCheckedItemPosition());
//tv.append(C.getString(0));
tv.invalidate();
return false;
}
});
//lv.setItemsCanFocus(false);
lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

lv.invalidate();
}

private void updateAttendance(SparseBooleanArray array, Cursor c)
{
tv.setText(Chosen Ones:\n);

boolean inLoop = c.moveToFirst();
while(inLoop) {
if(array.get(c.getPosition() ) ) {
tv.append(c.getString(0) + \n);
}
inLoop = c.moveToNext();
}
}



--~--~-~--~~~---~--~~
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] List view scrolling while setPadding

2009-07-20 Thread Muthu Kumar K.

Hi All,
I have an list view in my project. If the list view items are more
than that page (screen size) means i am able to see the scroll bar in
the right side.
If i am restricting in to a default size using setPadding (reducing
the height of the view). This time i am not getting the scroll bar.
That means if the items are more that the device screen size scroll
bar is showing. Other wise scroll bar is not showing.
Is there any specific reason in this? How do i handle for this?

Thanks in advance,
Muthu Kumar K.
--~--~-~--~~~---~--~~
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] List View item ticker.

2009-07-15 Thread Muthu Kumar K.

Hi All,
I have the list view with the length text values. So how can i ticker
the test? Please give me your comments

Thanks in Advance,
Muthu Kumar K.
--~--~-~--~~~---~--~~
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] List View not properly updated from AsyncTask

2009-07-13 Thread pperotti

Hi Everyone,

After digging with the APIs I still cannot figure out how the
AsyncTask properly works and why some behavior occur.

I'm trying  to achieve one contact list that can be updated from a
background async task very frequently. There are situations where
invoking UI updates from the background thread just freeze the UI as
you see in example #2. or make the list not to react properly to
finger as a regular contact list. Can anyone give me some hint on how
to achieve the expected behavior?

I added here the activities that form my project (sorry for the lenght
of the post, my idea was to share the complete problem with everyone)

Example 1: Contact list without background task. This code contains
the behavior of a default contact list. This code produce the expected
behavior in responsive for the user but do not update. This activity
shows the ideal response for a contact list.

package com.pp.lists;

import android.app.ListActivity;
import android.content.Intent;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;

public class List1 extends ListActivity implements
View.OnClickListener {

Button btnBack = null;
SensorManager sensorManager = null;

String[] items = { lorem, ipsum, dolor, sit, amet,
consectetuer, adipiscing, elit, morbi, vel,
ligula, vitae, arcu, aliquet, mollis, etiam,
vel, erat, placerat, ante, porttitor,
sodales, pellentesque, augue, purus, lorem,
ipsum, dolor, sit, amet, consectetuer,
adipiscing, elit, morbi, vel, ligula, vitae,
arcu, aliquet, mollis, etiam, vel,
erat, placerat, ante, porttitor, sodales,
pellentesque, augue, purus, lorem, ipsum,
dolor, sit, amet, consectetuer, adipiscing,
elit, morbi, vel, ligula, vitae, arcu,
aliquet, mollis, etiam, vel, erat, placerat,
ante, porttitor, sodales, pellentesque,
augue, purus, lorem, ipsum, dolor, sit,
amet, consectetuer, adipiscing, elit, morbi,
vel, ligula, vitae, arcu, aliquet, mollis,
etiam, vel, erat, placerat, ante,
porttitor, sodales, pellentesque, augue,
purus };

/** Called when the activity is first created. */
@Override
public void onCreate( Bundle savedInstanceState ) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listdemo);
setListAdapter(new ArrayAdapterString(this,
R.layout.listitem, R.id.label, items));

btnBack = (Button) findViewById(R.id.btnBackFromList);
btnBack.setOnClickListener(this);
}

public void onClick( View arg0 ) {
if ( btnBack == arg0 ) {
startActivity(new Intent(this, Main.class));
}
}

public void onResume() {
System.out.println(List1.onResume!);
super.onResume();
}

public void onPause() {
System.out.println(List1.onPause!);
super.onPause();
}

}

Example 2: This example update the contact list very frequently
properly but without freezing DO NOT allow the user to even scroll.

package com.pp.lists;

import android.app.ListActivity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

public class List2 extends ListActivity implements
View.OnClickListener {

Button btnBack = null;
Handler handler = new Handler();

String[] items = { lorem, ipsum, dolor, sit, amet,
consectetuer, adipiscing, elit, morbi, vel,
ligula, vitae, arcu, aliquet, mollis, etiam,
vel, erat, placerat, ante, porttitor,
sodales, pellentesque, augue, purus, lorem,
ipsum, dolor, sit, amet, consectetuer,
adipiscing, elit, morbi, vel, ligula, vitae,
arcu, aliquet, mollis, etiam, vel,
erat, placerat, ante, porttitor, sodales,
pellentesque, augue, purus, lorem, ipsum,
dolor, sit, amet, consectetuer, adipiscing,
elit, morbi, vel, ligula, vitae, arcu,
aliquet, mollis, etiam, vel, erat, placerat,
ante, porttitor, sodales, pellentesque,
augue, purus, lorem, ipsum, dolor, sit,
amet, consectetuer, adipiscing, elit, morbi,
vel, ligula, vitae, arcu, aliquet, mollis,
etiam, vel, erat, placerat, ante,
porttitor, sodales, pellentesque, augue,
purus };

private ArrayAdapter adapter = null;
private ListView list = null;

BGSorter task = null;

EditText txtTest = null;
public boolean isRunning = true;

/** Called when the activity is first created. */
@Override
public void onCreate( Bundle savedInstanceState ) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listdemo);
adapter = new ArrayAdapterString(this, R.layout.listitem,
R.id.label, items);
setListAdapter(adapter);

[android-developers] List View setTextFilterEnabled(true) and returned id

2009-03-16 Thread Ryan


Hi,

Is there a way to use a List View with setTextFilterEnabled(true) and
get the position into the unfiltered list returned to onItemClick?

E.G.

If I have a list:-

 - Zero
 - One
 - Two
 - Three

And a user types T o filter the list to:-

 - Two
 - Three

When a user clicks on Two in the filtered list, I would like the id
or position returned to onItemClick to be 2. But instead it returns
0, which is expected as it is the first item in the filtered list. But
what's the best way to get the position in the unfiltered list?

Thanks a lot,

Ryan

FYI My code is as follows:-

 

ListString list;
ArrayAdapterString array;

list.add(Zero);
list.add(One);
list.add(Two);
list.add(Three);
array = new ArrayAdapterString
(this,android.R.layout.simple_list_item_1, list);

setListAdapter(array);
this.getListView().setOnItemClickListener(this);
this.getListView().setTextFilterEnabled(true);
 
--
--~--~-~--~~~---~--~~
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] List View scrolling issue

2009-03-03 Thread Muthu Kumar K.

Hi All,
I have problem with the List view scrolling. Here I have a list view
contains more 50 items. I am setting the list view background as
transparent. While scrolling the list view it is showing with black
background. Can any one tell me how to remove this black portion?

Thanks in Advance,
Muthu Kumar K.
--~--~-~--~~~---~--~~
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] list view

2009-01-20 Thread msmsmukesh
Hi all,I want listview for edit writing and picture please sent the coding.

--~--~-~--~~~---~--~~
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] List View

2009-01-04 Thread flashfreakmx

Right now I am extending Activity and populating 2 list views
dynamically.
How do I override the onListItemClick method for the lists if I am
extending Activity?

package com.thinknew.budget;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;

public class Budget extends Activity {


private static final int ACTIVITY_CREATE=0;
private static final int ACTIVITY_EDIT=1;

private static final int INSERT_ID = Menu.FIRST;
private static final int DELETE_ID = Menu.FIRST + 1;

ListView inlist;
ListView outlist;

private BudgetDbAdapter mDbHelper;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.budget_list);
mDbHelper = new BudgetDbAdapter(this);
mDbHelper.open();
fillData();
}

private void fillData() {

Cursor inCursor = mDbHelper.fetchIn();
startManagingCursor(inCursor);

// Create an array to specify the fields we want to display in
the list (only TITLE)
String[] fromin = new String[]{BudgetDbAdapter.KEY_TITLE,
BudgetDbAdapter.KEY_AMOUNT};

// and an array of the fields we want to bind those fields to
(in this case just text1)
int[] toin = new int[]{R.id.singletitle, R.id.singleamount};

// Now create a simple cursor adapter and set it to display
ListAdapter in =
new SimpleCursorAdapter(this, R.layout.budget_row,
inCursor, fromin, toin);

inlist = (ListView) this.findViewById(R.id.listin);

inlist.setAdapter(in);

//setListAdapter(in);

Cursor outCursor = mDbHelper.fetchOut();
startManagingCursor(outCursor);

// Create an array to specify the fields we want to display in
the list (only TITLE)
String[] from = new String[]{BudgetDbAdapter.KEY_TITLE,
BudgetDbAdapter.KEY_AMOUNT};

// and an array of the fields we want to bind those fields to
(in this case just text1)
int[] to = new int[]{R.id.singletitle, R.id.singleamount};

// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter out =
new SimpleCursorAdapter(this, R.layout.budget_row,
outCursor, from, to);

outlist = (ListView) this.findViewById(R.id.listout);

outlist.setAdapter(out);

//setListAdapter(out);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, INSERT_ID, 0, R.string.menu_insert);
menu.add(0, DELETE_ID, 0,  R.string.menu_delete);
return true;
}

@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
switch(item.getItemId()) {
case INSERT_ID:
createNote();
return true;
case DELETE_ID:
mDbHelper.deleteNote(inlist.getSelectedItemId());
mDbHelper.deleteNote(outlist.getSelectedItemId());
fillData();
return true;
}

return super.onMenuItemSelected(featureId, item);
}

private void createNote() {
Intent i = new Intent(this, BudgetEdit.class);
startActivityForResult(i, ACTIVITY_CREATE);
}

@Override
protected void onListItemClick(ListView l, View v, int position,
long id) {
super.onListItemClick(l, v, position, id);
Intent i = new Intent(this, BudgetEdit.class);
i.putExtra(BudgetDbAdapter.KEY_ROWID, id);
startActivityForResult(i, ACTIVITY_EDIT);
}

@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
fillData();
}
}
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---