[android-developers] Re: separate views list view

2010-09-29 Thread Varun Khanduja
Thank you everyone. My problem is still not solved but I am trying to
do things. You guys have been of great help.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: separate views list view

2010-09-29 Thread TreKing
On Wed, Sep 29, 2010 at 4:52 PM, Varun Khanduja wrote:

>  Still I don't think it's working for me, can someone suggest me where I am
> going wrong?
>

You're not creating custom adapters, you just have four regular
ArrayAdapters (with the same data, it looks like).

You need something like:

class MyAdapter : ArrayAdapter
{
 @Override
 public View getView(int i, View v, ViewGroup vg)
 {
  switch (state)
  {
   case 1:
return createViewType1();
   case 2:
return createViewType2();
   case 3:
return createViewType3();
   case 4:
return createViewType4();
 }
}

Then, in your class:

setAdapter(new MyAdapter());

Then when you click your buttons you set "state" and implement the
"createView" functions to return the view you need in your ListView for that
given state. Or something. That's just one idea to get your rolling.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: separate views list view

2010-09-29 Thread Varun Khanduja
Hello I tried taking everyone's suggestion. Still I don't think it's
working for me, can someone suggest me where I am going wrong?

package com.varun.HelloListView;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Adapter;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

public class HelloListView extends ListActivity {
TextView selection;
ArrayAdapter a1=null;
ArrayAdapter a2=null;
ArrayAdapter a3=null;
ArrayAdapter a4=null;
ListActivity myActivity = null;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
a1 = new ArrayAdapter(this, R.layout.list_item,
R.id.label,AndroidPhones);
a2 = new ArrayAdapter(this, R.layout.list_item,
R.id.label,AndroidPhones1);
a3 = new ArrayAdapter(this, R.layout.list_item,
R.id.label,AndroidPhones2);
a4 = new ArrayAdapter(this, R.layout.list_item,
R.id.label,AndroidPhones3);

setContentView(R.layout.main);
setListAdapter(a1);
myActivity = this;
Button next = (Button) findViewById(R.id.Button1);
next.setOnClickListener(
new View.OnClickListener() {
public void onClick(View view) {
myActivity.setListAdapter(a1);
a1.notifyDataSetChanged();

}
}
);
setListAdapter(a2);
myActivity = this;
Button next1 = (Button) findViewById(R.id.Button2);
next.setOnClickListener(
new View.OnClickListener() {
public void onClick(View view) {
myActivity.setListAdapter(a2);
a2.notifyDataSetChanged();

}
}
);
setListAdapter(a3);
myActivity = this;
Button next2 = (Button) findViewById(R.id.Button3);
next.setOnClickListener(
new View.OnClickListener() {
public void onClick(View view) {
myActivity.setListAdapter(a3);
a3.notifyDataSetChanged();

}
}
);

setListAdapter(a4);
myActivity = this;
Button next3 = (Button) findViewById(R.id.Button4);
next.setOnClickListener(
new View.OnClickListener() {
public void onClick(View view4) {
myActivity.setListAdapter(a4);
a4.notifyDataSetChanged();

}
}
);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);

menu.add(0, Settings.ENTER_FOOD, 0, "Enter Food");
menu.add(0, Settings.ANALYZE_FOOD, 0, "Analyze Food");
menu.add(0, Settings.SETTINGS, 0, "Settings");

return true;
}


static final String[] AndroidPhones = new String[] {
"HTC Evo 4G",  "Google Nexus One", "Motorola Devour",
"Motorola CLIQ", "Samsung Galaxy S", "Motorola Droid",
"myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
"Motorola i1", "HTC Hero", "myTouch 3G Fender",
"HTC Droid Incredible",  "Samsung Moment", "LG Ally ",
};
static final String[] AndroidPhones1 = new String[] {
"HTC Evo 1G",  "Google Nexus One", "Motorola Devour",
"Motorola 2LIQ", "Samsung Galaxy S", "Motorola Droid",
"myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
"Motorola i1", "HTC Hero", "myTouch 3G Fender",
"HTC Droid Incredible",  "Samsung Moment", "LG Ally ",
};
static final String[] AndroidPhones2 = new String[] {
"HTC Evo 1G",  "Google One", "Motorola Devour",
"Motorola 2LIQ", "Samsung Galaxy S", "Motorola Droid",
"myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
"Motorola i1", "HTC Hero", "myTouch 3G Fender",
"HTC Droid Incredible",  "Samsung Moment", "LG Ally ",
};
static final String[] AndroidPhones3 = new String[] {
"HTC Evo 1G",  "Google Nexus hello", "Motorola Devour",
"Motorola 2LIQ", "Samsung Galaxy S"

[android-developers] Re: separate views list view

2010-09-29 Thread Olivier Goutet
I don't know if you can read French but there is a very good post on
this French blog: http://android.cyrilmottier.com/?p=232
It explain how to build a custom adapter (BaseAdapter in fact) to
manage 2 different types of cells on a list view. I hope the source
source code will be enough for you.

The ArrayAdapter you are using is just a very simple way to display
text cells on a listview.

To display your 4 different types of items, you will need to create 4
layout (1 for each cell type) and then inflate them in the base
adapter (as explained in the blog).

On Sep 29, 4:43 pm, TreKing  wrote:
> On Tue, Sep 28, 2010 at 8:40 PM, Varun Khanduja 
> wrote:
>
> > If anyone has time please try to help me out. Thanks, I looked into some
> > examples but really found it hard to see how I can have the custom adapter
> > runnning.
>
> The "custom" part of an adapter is basically returning the View you want to
> show in your list for a given item.
>
> Currently you have the default ArrayAdapter that works on Strings. Since you
> want something more complicated, all you have to do is create a class that
> extends ArrayAdapter and override the getView() method to return the layouts
> you want (as you described) based on the state of your list.
>
> So the first thing to do is create your custom ArrayAdapter, override
> getView, then set it as the adapter to your list and verify your views show
> up as expected.
>
> -
> TreKing  - Chicago
> transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: separate views list view

2010-09-29 Thread Olivier Goutet
I don't know if you can read French but there is a very good post on
this French blog: http://android.cyrilmottier.com/?p=232
It explain how to build a custom adapter (BaseAdapter in fact) to
manage 2 different types of cells on a list view. I hope the source
source code will be enough for you.

The ArrayAdapter you are using is just a very simple way to display
text cells on a listview.

To display your 4 different types of items, you will need to create 4
layout (1 for each cell type) and then inflate them in the base
adapter (as explained in the blog).

On Sep 29, 4:43 pm, TreKing  wrote:
> On Tue, Sep 28, 2010 at 8:40 PM, Varun Khanduja 
> wrote:
>
> > If anyone has time please try to help me out. Thanks, I looked into some
> > examples but really found it hard to see how I can have the custom adapter
> > runnning.
>
> The "custom" part of an adapter is basically returning the View you want to
> show in your list for a given item.
>
> Currently you have the default ArrayAdapter that works on Strings. Since you
> want something more complicated, all you have to do is create a class that
> extends ArrayAdapter and override the getView() method to return the layouts
> you want (as you described) based on the state of your list.
>
> So the first thing to do is create your custom ArrayAdapter, override
> getView, then set it as the adapter to your list and verify your views show
> up as expected.
>
> -
> 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] Re: separate views list view

2010-09-29 Thread TreKing
On Tue, Sep 28, 2010 at 8:40 PM, Varun Khanduja wrote:

> If anyone has time please try to help me out. Thanks, I looked into some
> examples but really found it hard to see how I can have the custom adapter
> runnning.
>

The "custom" part of an adapter is basically returning the View you want to
show in your list for a given item.

Currently you have the default ArrayAdapter that works on Strings. Since you
want something more complicated, all you have to do is create a class that
extends ArrayAdapter and override the getView() method to return the layouts
you want (as you described) based on the state of your list.

So the first thing to do is create your custom ArrayAdapter, override
getView, then set it as the adapter to your list and verify your views show
up as expected.

-
TreKing  - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: separate views list view

2010-09-28 Thread Varun Khanduja
If anyone has time please try to help me out. Thanks, I looked into
some examples but really found it hard to see how I can have the
custom adapter runnning. Thanks

On Sep 28, 12:42 pm, Varun Khanduja  wrote:
> Ohh ok.Thanks. the format is changing in the sense that one of the
> format is having a header to the same list items, another format is
> having check boxes on left and another format is having two lines in
> the same row for every list item. Thanks
>
> On Sep 28, 12:32 pm, Kumar Bibek  wrote:
>
>
>
> > > > > > > 4 different formats and when the user clicks on any of the 4 
> > > > > > > buttons
> > > > > > > they get the formats they had requested.
>
> > On Sep 29, 12:28 am, Varun Khanduja  wrote:
>
> > > Sorry this may sound silly, but I am not really sure what you mean by
> > > "which format I am trying to use? " Thanks
>
> > > On Sep 28, 11:48 am, Kumar Bibek  wrote:
>
> > > > You are using the ArrayAdapter here. You have to use a custom adapter
> > > > which extends the ArrayAdapter or the BaseAdapter. Also, what format
> > > > are you trying to change? If you can give me an example, I can help
> > > > you with that.
>
> > > > -Kumar Bibekhttp://techdroid.kbeanie.com
>
> > > > On Sep 28, 11:39 pm, Varun Khanduja  wrote:
>
> > > > > Hi Kumar,
>
> > > > > Thanks for the response. I think I am using custom adapter. Do you
> > > > > have an example or some resource where i can see how to define this
> > > > > method? Do you think I need on click event handlers? Was sort of
> > > > > confused when checking google documentation. Thanks for guidance.
>
> > > > > package com.varun.HelloListView;
>
> > > > > import android.app.ListActivity;
> > > > > import android.os.Bundle;
> > > > > import android.view.Menu;
> > > > > import android.widget.ArrayAdapter;
> > > > > import android.widget.TextView;
>
> > > > > public class HelloListView extends ListActivity {
> > > > >         TextView selection;
>
> > > > >         @Override
> > > > >         public void onCreate(Bundle icicle) {
> > > > >                 super.onCreate(icicle);
>
> > > > >                 setContentView(R.layout.main);
> > > > >                 setListAdapter(new ArrayAdapter(this, 
> > > > > R.layout.list_item,
> > > > > R.id.label,AndroidPhones));
> > > > >         }
> > > > >         @Override
> > > > >         public boolean onCreateOptionsMenu(Menu menu) {
> > > > >                 super.onCreateOptionsMenu(menu);
>
> > > > >                 menu.add(0, Settings.ENTER_FOOD, 0, "Enter Food");
> > > > >                 menu.add(0, Settings.ANALYZE_FOOD, 0, "Analyze Food");
> > > > >                 menu.add(0, Settings.SETTINGS, 0, "Settings");
>
> > > > >                 return true;
> > > > >         }
>
> > > > >         static final String[] AndroidPhones = new String[] {
> > > > >                 "HTC Evo 4G",  "Google Nexus One", "Motorola Devour",
> > > > >                 "Motorola CLIQ", "Samsung Galaxy S", "Motorola Droid",
> > > > >                 "myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
> > > > >                 "Motorola i1", "HTC Hero", "myTouch 3G Fender",
> > > > >                 "HTC Droid Incredible",  "Samsung Moment", "LG Ally ",
> > > > >         };
> > > > >         }
>
> > > > > On Sep 28, 11:29 am, Kumar Bibek  wrote:
>
> > > > > > If you are using a custom adapter, you can have a method wherein you
> > > > > > specify a method to change the format of the ListView. Through this
> > > > > > event, you can change the dataset of the ListView and ask the list
> > > > > > view to reload all these items. Thats should serve the purpose.
>
> > > > > > -Kumar Bibekhttp://kbeanie.com
>
> > > > > > On Sep 28, 11:02 pm, Varun Khanduja  wrote:
>
> > > > > > > Hello,
>
> > > > > > > I was trying to see if anyone could guide me about some keywords 
> > > > > > > or
> > > > > > > approach I should take to achieve a certain task on Android. I 
> > > > > > > have 4
> > > > > > > buttons, below these buttons is a list view. This list view is 
> > > > > > > having
> > > > > > > 4 different formats and when the user clicks on any of the 4 
> > > > > > > buttons
> > > > > > > they get the formats they had requested. I am not sure how I can 
> > > > > > > have
> > > > > > > 4 different list views. Should I declare 4 different strings or 
> > > > > > > how
> > > > > > > should one go about it?
>
> > > > > > > Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: separate views list view

2010-09-28 Thread Varun Khanduja
Ohh ok.Thanks. the format is changing in the sense that one of the
format is having a header to the same list items, another format is
having check boxes on left and another format is having two lines in
the same row for every list item. Thanks

On Sep 28, 12:32 pm, Kumar Bibek  wrote:
> > > > > > 4 different formats and when the user clicks on any of the 4 buttons
> > > > > > they get the formats they had requested.
>
> On Sep 29, 12:28 am, Varun Khanduja  wrote:
>
>
>
> > Sorry this may sound silly, but I am not really sure what you mean by
> > "which format I am trying to use? " Thanks
>
> > On Sep 28, 11:48 am, Kumar Bibek  wrote:
>
> > > You are using the ArrayAdapter here. You have to use a custom adapter
> > > which extends the ArrayAdapter or the BaseAdapter. Also, what format
> > > are you trying to change? If you can give me an example, I can help
> > > you with that.
>
> > > -Kumar Bibekhttp://techdroid.kbeanie.com
>
> > > On Sep 28, 11:39 pm, Varun Khanduja  wrote:
>
> > > > Hi Kumar,
>
> > > > Thanks for the response. I think I am using custom adapter. Do you
> > > > have an example or some resource where i can see how to define this
> > > > method? Do you think I need on click event handlers? Was sort of
> > > > confused when checking google documentation. Thanks for guidance.
>
> > > > package com.varun.HelloListView;
>
> > > > import android.app.ListActivity;
> > > > import android.os.Bundle;
> > > > import android.view.Menu;
> > > > import android.widget.ArrayAdapter;
> > > > import android.widget.TextView;
>
> > > > public class HelloListView extends ListActivity {
> > > >         TextView selection;
>
> > > >         @Override
> > > >         public void onCreate(Bundle icicle) {
> > > >                 super.onCreate(icicle);
>
> > > >                 setContentView(R.layout.main);
> > > >                 setListAdapter(new ArrayAdapter(this, 
> > > > R.layout.list_item,
> > > > R.id.label,AndroidPhones));
> > > >         }
> > > >         @Override
> > > >         public boolean onCreateOptionsMenu(Menu menu) {
> > > >                 super.onCreateOptionsMenu(menu);
>
> > > >                 menu.add(0, Settings.ENTER_FOOD, 0, "Enter Food");
> > > >                 menu.add(0, Settings.ANALYZE_FOOD, 0, "Analyze Food");
> > > >                 menu.add(0, Settings.SETTINGS, 0, "Settings");
>
> > > >                 return true;
> > > >         }
>
> > > >         static final String[] AndroidPhones = new String[] {
> > > >                 "HTC Evo 4G",  "Google Nexus One", "Motorola Devour",
> > > >                 "Motorola CLIQ", "Samsung Galaxy S", "Motorola Droid",
> > > >                 "myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
> > > >                 "Motorola i1", "HTC Hero", "myTouch 3G Fender",
> > > >                 "HTC Droid Incredible",  "Samsung Moment", "LG Ally ",
> > > >         };
> > > >         }
>
> > > > On Sep 28, 11:29 am, Kumar Bibek  wrote:
>
> > > > > If you are using a custom adapter, you can have a method wherein you
> > > > > specify a method to change the format of the ListView. Through this
> > > > > event, you can change the dataset of the ListView and ask the list
> > > > > view to reload all these items. Thats should serve the purpose.
>
> > > > > -Kumar Bibekhttp://kbeanie.com
>
> > > > > On Sep 28, 11:02 pm, Varun Khanduja  wrote:
>
> > > > > > Hello,
>
> > > > > > I was trying to see if anyone could guide me about some keywords or
> > > > > > approach I should take to achieve a certain task on Android. I have 
> > > > > > 4
> > > > > > buttons, below these buttons is a list view. This list view is 
> > > > > > having
> > > > > > 4 different formats and when the user clicks on any of the 4 buttons
> > > > > > they get the formats they had requested. I am not sure how I can 
> > > > > > have
> > > > > > 4 different list views. Should I declare 4 different strings or how
> > > > > > should one go about it?
>
> > > > > > Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: separate views list view

2010-09-28 Thread Kumar Bibek
> > > > > 4 different formats and when the user clicks on any of the 4 buttons
> > > > > they get the formats they had requested.



On Sep 29, 12:28 am, Varun Khanduja  wrote:
> Sorry this may sound silly, but I am not really sure what you mean by
> "which format I am trying to use? " Thanks
>
> On Sep 28, 11:48 am, Kumar Bibek  wrote:
>
> > You are using the ArrayAdapter here. You have to use a custom adapter
> > which extends the ArrayAdapter or the BaseAdapter. Also, what format
> > are you trying to change? If you can give me an example, I can help
> > you with that.
>
> > -Kumar Bibekhttp://techdroid.kbeanie.com
>
> > On Sep 28, 11:39 pm, Varun Khanduja  wrote:
>
> > > Hi Kumar,
>
> > > Thanks for the response. I think I am using custom adapter. Do you
> > > have an example or some resource where i can see how to define this
> > > method? Do you think I need on click event handlers? Was sort of
> > > confused when checking google documentation. Thanks for guidance.
>
> > > package com.varun.HelloListView;
>
> > > import android.app.ListActivity;
> > > import android.os.Bundle;
> > > import android.view.Menu;
> > > import android.widget.ArrayAdapter;
> > > import android.widget.TextView;
>
> > > public class HelloListView extends ListActivity {
> > >         TextView selection;
>
> > >         @Override
> > >         public void onCreate(Bundle icicle) {
> > >                 super.onCreate(icicle);
>
> > >                 setContentView(R.layout.main);
> > >                 setListAdapter(new ArrayAdapter(this, R.layout.list_item,
> > > R.id.label,AndroidPhones));
> > >         }
> > >         @Override
> > >         public boolean onCreateOptionsMenu(Menu menu) {
> > >                 super.onCreateOptionsMenu(menu);
>
> > >                 menu.add(0, Settings.ENTER_FOOD, 0, "Enter Food");
> > >                 menu.add(0, Settings.ANALYZE_FOOD, 0, "Analyze Food");
> > >                 menu.add(0, Settings.SETTINGS, 0, "Settings");
>
> > >                 return true;
> > >         }
>
> > >         static final String[] AndroidPhones = new String[] {
> > >                 "HTC Evo 4G",  "Google Nexus One", "Motorola Devour",
> > >                 "Motorola CLIQ", "Samsung Galaxy S", "Motorola Droid",
> > >                 "myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
> > >                 "Motorola i1", "HTC Hero", "myTouch 3G Fender",
> > >                 "HTC Droid Incredible",  "Samsung Moment", "LG Ally ",
> > >         };
> > >         }
>
> > > On Sep 28, 11:29 am, Kumar Bibek  wrote:
>
> > > > If you are using a custom adapter, you can have a method wherein you
> > > > specify a method to change the format of the ListView. Through this
> > > > event, you can change the dataset of the ListView and ask the list
> > > > view to reload all these items. Thats should serve the purpose.
>
> > > > -Kumar Bibekhttp://kbeanie.com
>
> > > > On Sep 28, 11:02 pm, Varun Khanduja  wrote:
>
> > > > > Hello,
>
> > > > > I was trying to see if anyone could guide me about some keywords or
> > > > > approach I should take to achieve a certain task on Android. I have 4
> > > > > buttons, below these buttons is a list view. This list view is having
> > > > > 4 different formats and when the user clicks on any of the 4 buttons
> > > > > they get the formats they had requested. I am not sure how I can have
> > > > > 4 different list views. Should I declare 4 different strings or how
> > > > > should one go about it?
>
> > > > > Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: separate views list view

2010-09-28 Thread Varun Khanduja
Sorry this may sound silly, but I am not really sure what you mean by
"which format I am trying to use? " Thanks

On Sep 28, 11:48 am, Kumar Bibek  wrote:
> You are using the ArrayAdapter here. You have to use a custom adapter
> which extends the ArrayAdapter or the BaseAdapter. Also, what format
> are you trying to change? If you can give me an example, I can help
> you with that.
>
> -Kumar Bibekhttp://techdroid.kbeanie.com
>
> On Sep 28, 11:39 pm, Varun Khanduja  wrote:
>
>
>
> > Hi Kumar,
>
> > Thanks for the response. I think I am using custom adapter. Do you
> > have an example or some resource where i can see how to define this
> > method? Do you think I need on click event handlers? Was sort of
> > confused when checking google documentation. Thanks for guidance.
>
> > package com.varun.HelloListView;
>
> > import android.app.ListActivity;
> > import android.os.Bundle;
> > import android.view.Menu;
> > import android.widget.ArrayAdapter;
> > import android.widget.TextView;
>
> > public class HelloListView extends ListActivity {
> >         TextView selection;
>
> >         @Override
> >         public void onCreate(Bundle icicle) {
> >                 super.onCreate(icicle);
>
> >                 setContentView(R.layout.main);
> >                 setListAdapter(new ArrayAdapter(this, R.layout.list_item,
> > R.id.label,AndroidPhones));
> >         }
> >         @Override
> >         public boolean onCreateOptionsMenu(Menu menu) {
> >                 super.onCreateOptionsMenu(menu);
>
> >                 menu.add(0, Settings.ENTER_FOOD, 0, "Enter Food");
> >                 menu.add(0, Settings.ANALYZE_FOOD, 0, "Analyze Food");
> >                 menu.add(0, Settings.SETTINGS, 0, "Settings");
>
> >                 return true;
> >         }
>
> >         static final String[] AndroidPhones = new String[] {
> >                 "HTC Evo 4G",  "Google Nexus One", "Motorola Devour",
> >                 "Motorola CLIQ", "Samsung Galaxy S", "Motorola Droid",
> >                 "myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
> >                 "Motorola i1", "HTC Hero", "myTouch 3G Fender",
> >                 "HTC Droid Incredible",  "Samsung Moment", "LG Ally ",
> >         };
> >         }
>
> > On Sep 28, 11:29 am, Kumar Bibek  wrote:
>
> > > If you are using a custom adapter, you can have a method wherein you
> > > specify a method to change the format of the ListView. Through this
> > > event, you can change the dataset of the ListView and ask the list
> > > view to reload all these items. Thats should serve the purpose.
>
> > > -Kumar Bibekhttp://kbeanie.com
>
> > > On Sep 28, 11:02 pm, Varun Khanduja  wrote:
>
> > > > Hello,
>
> > > > I was trying to see if anyone could guide me about some keywords or
> > > > approach I should take to achieve a certain task on Android. I have 4
> > > > buttons, below these buttons is a list view. This list view is having
> > > > 4 different formats and when the user clicks on any of the 4 buttons
> > > > they get the formats they had requested. I am not sure how I can have
> > > > 4 different list views. Should I declare 4 different strings or how
> > > > should one go about it?
>
> > > > Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: separate views list view

2010-09-28 Thread Kumar Bibek
You are using the ArrayAdapter here. You have to use a custom adapter
which extends the ArrayAdapter or the BaseAdapter. Also, what format
are you trying to change? If you can give me an example, I can help
you with that.

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

On Sep 28, 11:39 pm, Varun Khanduja  wrote:
> Hi Kumar,
>
> Thanks for the response. I think I am using custom adapter. Do you
> have an example or some resource where i can see how to define this
> method? Do you think I need on click event handlers? Was sort of
> confused when checking google documentation. Thanks for guidance.
>
> package com.varun.HelloListView;
>
> import android.app.ListActivity;
> import android.os.Bundle;
> import android.view.Menu;
> import android.widget.ArrayAdapter;
> import android.widget.TextView;
>
> public class HelloListView extends ListActivity {
>         TextView selection;
>
>         @Override
>         public void onCreate(Bundle icicle) {
>                 super.onCreate(icicle);
>
>                 setContentView(R.layout.main);
>                 setListAdapter(new ArrayAdapter(this, R.layout.list_item,
> R.id.label,AndroidPhones));
>         }
>         @Override
>         public boolean onCreateOptionsMenu(Menu menu) {
>                 super.onCreateOptionsMenu(menu);
>
>                 menu.add(0, Settings.ENTER_FOOD, 0, "Enter Food");
>                 menu.add(0, Settings.ANALYZE_FOOD, 0, "Analyze Food");
>                 menu.add(0, Settings.SETTINGS, 0, "Settings");
>
>                 return true;
>         }
>
>         static final String[] AndroidPhones = new String[] {
>                 "HTC Evo 4G",  "Google Nexus One", "Motorola Devour",
>                 "Motorola CLIQ", "Samsung Galaxy S", "Motorola Droid",
>                 "myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
>                 "Motorola i1", "HTC Hero", "myTouch 3G Fender",
>                 "HTC Droid Incredible",  "Samsung Moment", "LG Ally ",
>         };
>         }
>
> On Sep 28, 11:29 am, Kumar Bibek  wrote:
>
> > If you are using a custom adapter, you can have a method wherein you
> > specify a method to change the format of the ListView. Through this
> > event, you can change the dataset of the ListView and ask the list
> > view to reload all these items. Thats should serve the purpose.
>
> > -Kumar Bibekhttp://kbeanie.com
>
> > On Sep 28, 11:02 pm, Varun Khanduja  wrote:
>
> > > Hello,
>
> > > I was trying to see if anyone could guide me about some keywords or
> > > approach I should take to achieve a certain task on Android. I have 4
> > > buttons, below these buttons is a list view. This list view is having
> > > 4 different formats and when the user clicks on any of the 4 buttons
> > > they get the formats they had requested. I am not sure how I can have
> > > 4 different list views. Should I declare 4 different strings or how
> > > should one go about it?
>
> > > Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: separate views list view

2010-09-28 Thread Varun Khanduja
Hi Kumar,

Thanks for the response. I think I am using custom adapter. Do you
have an example or some resource where i can see how to define this
method? Do you think I need on click event handlers? Was sort of
confused when checking google documentation. Thanks for guidance.

package com.varun.HelloListView;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class HelloListView extends ListActivity {
TextView selection;

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

setContentView(R.layout.main);
setListAdapter(new ArrayAdapter(this, R.layout.list_item,
R.id.label,AndroidPhones));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);

menu.add(0, Settings.ENTER_FOOD, 0, "Enter Food");
menu.add(0, Settings.ANALYZE_FOOD, 0, "Analyze Food");
menu.add(0, Settings.SETTINGS, 0, "Settings");

return true;
}


static final String[] AndroidPhones = new String[] {
"HTC Evo 4G",  "Google Nexus One", "Motorola Devour",
"Motorola CLIQ", "Samsung Galaxy S", "Motorola Droid",
"myTouch 3G Slide", "Droid Eris", "Motorola Backflip",
"Motorola i1", "HTC Hero", "myTouch 3G Fender",
"HTC Droid Incredible",  "Samsung Moment", "LG Ally ",
};
}



On Sep 28, 11:29 am, Kumar Bibek  wrote:
> If you are using a custom adapter, you can have a method wherein you
> specify a method to change the format of the ListView. Through this
> event, you can change the dataset of the ListView and ask the list
> view to reload all these items. Thats should serve the purpose.
>
> -Kumar Bibekhttp://kbeanie.com
>
> On Sep 28, 11:02 pm, Varun Khanduja  wrote:
>
>
>
> > Hello,
>
> > I was trying to see if anyone could guide me about some keywords or
> > approach I should take to achieve a certain task on Android. I have 4
> > buttons, below these buttons is a list view. This list view is having
> > 4 different formats and when the user clicks on any of the 4 buttons
> > they get the formats they had requested. I am not sure how I can have
> > 4 different list views. Should I declare 4 different strings or how
> > should one go about it?
>
> > Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: separate views list view

2010-09-28 Thread Kumar Bibek
If you are using a custom adapter, you can have a method wherein you
specify a method to change the format of the ListView. Through this
event, you can change the dataset of the ListView and ask the list
view to reload all these items. Thats should serve the purpose.

-Kumar Bibek
http://kbeanie.com

On Sep 28, 11:02 pm, Varun Khanduja  wrote:
> Hello,
>
> I was trying to see if anyone could guide me about some keywords or
> approach I should take to achieve a certain task on Android. I have 4
> buttons, below these buttons is a list view. This list view is having
> 4 different formats and when the user clicks on any of the 4 buttons
> they get the formats they had requested. I am not sure how I can have
> 4 different list views. Should I declare 4 different strings or how
> should one go about it?
>
> 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