Re: [android-developers] Re: Android multiple heading list view

2010-09-28 Thread TreKing
On Mon, Sep 27, 2010 at 11:58 PM, Varun Khanduja wrote:

> Sorry it took hours to figure out how I can have some buttons along with
> the linear layout.
>

Glad you got it working. No need to be sorry - this stuff can be tricky when
you're starting out. When I was starting with Android I spent like 2 days
fighting with a layout until I finally got the (now) simple concept of
weights. Good times =)

-
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: Android multiple heading list view

2010-09-27 Thread Varun Khanduja
It's done. Sorry it took hours to figure out how I can have some
buttons along with the linear layout. Thanks again Mr King. lols. I
wish how to address you :)

On Sep 27, 4:50 pm, Varun Khanduja  wrote:
> Thank you. i think I sort of got the results but I am probably not
> able to understand which property I should modify in the main.xml file
> to get the buttons properly aligned on the top. I am presently getting
> the 4 buttons but after several attempts of changing properties in xml
> file either they come vertically aligned or some other distortion
> happens. I am trying to make them equally sized with horizontal
> alignment. Help would be highly appreciated. Thanks
>
> Here is how i modified the java code.
>
> package com.varun.HelloListView;
>
> import java.util.Arrays;
> import java.util.Collections;
> import java.util.List;
>
> import android.app.ListActivity;
> import android.os.Bundle;
> import android.view.View;
> import android.widget.ArrayAdapter;
> import android.widget.Button;
> import android.widget.ListView;
> 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));
>
>         }
>
>         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 ",
>         };
>
> }
>
> Here is my main.xml code where the buttons are declared,
>
> 
> http://schemas.android.com/apk/res/
> android"
>     android:orientation="vertical"
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent"
>     >
>
>            android:id="@+id/textViewHello"
>     android:layout_width="fill_parent"
>     android:layout_height="wrap_content"
>     android:text="@string/hello"
>     />
>      android:id="@+id/button_previous"
> android:layout_height="wrap_content"
> android:layout_width="110px"
> android:layout_alignParentLeft="true"
> android:textSize="15sp"
> android:typeface="monospace"
> android:textColor="#ffFFffFF"
> android:text="@string/PreviousButton"
>
> 
>  android:id="@+id/button_next"
> android:layout_height="wrap_content"
> android:layout_width="110px"
> android:layout_alignParentRight="true"
> android:textSize="15sp"
> android:typeface="monospace"
> android:textColor="#ffFFffFF"
> android:text="@string/NextButton"
>
> 
>          android:id="@android:id/list"
>         android:layout_width="fill_parent"
>         android:layout_height="fill_parent"
>         android:drawSelectorOnTop="false"
>         />
> 
>
> On Sep 27, 2:23 pm, TreKing  wrote:
>
>
>
> > On Mon, Sep 27, 2010 at 4:15 PM, Varun Khanduja 
> > wrote:
>
> > > I am trying to declare two seperate buttons but only one of the buttons
> > > comes visible.
>
> > ListView takes one header view, AFAIK. Each function you have there returns
> > one button. Assuming you're calling listView.setHeader(buildHeader()) then
> > listView.setHeader(buildHeader2()), then the second call will overwrite the
> > first.
>
> > You should create a linear or relative layout that contains both buttons
> > then set THAT as the header view.
>
> > --- 
> > --
> > 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: Android multiple heading list view

2010-09-27 Thread Varun Khanduja
Thank you. i think I sort of got the results but I am probably not
able to understand which property I should modify in the main.xml file
to get the buttons properly aligned on the top. I am presently getting
the 4 buttons but after several attempts of changing properties in xml
file either they come vertically aligned or some other distortion
happens. I am trying to make them equally sized with horizontal
alignment. Help would be highly appreciated. Thanks

Here is how i modified the java code.

package com.varun.HelloListView;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
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));

}

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 ",
};
}


Here is my main.xml code where the buttons are declared,


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










On Sep 27, 2:23 pm, TreKing  wrote:
> On Mon, Sep 27, 2010 at 4:15 PM, Varun Khanduja 
> wrote:
>
> > I am trying to declare two seperate buttons but only one of the buttons
> > comes visible.
>
> ListView takes one header view, AFAIK. Each function you have there returns
> one button. Assuming you're calling listView.setHeader(buildHeader()) then
> listView.setHeader(buildHeader2()), then the second call will overwrite the
> first.
>
> You should create a linear or relative layout that contains both buttons
> then set THAT as the header view.
>
> --- 
> --
> 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: Android multiple heading list view

2010-09-27 Thread TreKing
On Mon, Sep 27, 2010 at 4:15 PM, Varun Khanduja wrote:

> I am trying to declare two seperate buttons but only one of the buttons
> comes visible.
>

ListView takes one header view, AFAIK. Each function you have there returns
one button. Assuming you're calling listView.setHeader(buildHeader()) then
listView.setHeader(buildHeader2()), then the second call will overwrite the
first.

You should create a linear or relative layout that contains both buttons
then set THAT as the header view.

-
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: Android multiple heading list view

2010-09-27 Thread Varun Khanduja
Here is something i have been attempting but failing.

I am trying to declare two seperate buttons but only one of the
buttons comes visible. I m sure my programming inepxereince is causing
these silly errors but some guidance would be helpful.

package com.varun.HelloListView;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

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

public class HelloListView extends ListActivity {
TextView selection;

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

setContentView(R.layout.main);
getListView().addHeaderView(buildHeader());
setListAdapter(new ArrayAdapter(this, R.layout.list_item,
R.id.label,AndroidPhones));
selection=(TextView)findViewById(R.id.textViewHello);

}

public void onListItemClick(ListView parent, View v,
int position,long id) {
selection.setText(AndroidPhones[position]);
}
private View buildHeader() {
Button btn=new Button(this);

btn.setText("Randomize!");
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
List list=Arrays.asList(AndroidPhones);

setListAdapter(new 
ArrayAdapter(HelloListView.this,

android.R.layout.simple_list_item_1,

list));
}
});
return(btn);
}
private View buildHeader2() {
Button btn1=new Button(this);
btn1.setText("Hello");

btn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
List list=Arrays.asList(AndroidPhones);

setListAdapter(new 
ArrayAdapter(HelloListView.this,

android.R.layout.simple_list_item_1,

list));
}
});

return(btn1);


}

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 27, 2:01 pm, TreKing  wrote:
> On Mon, Sep 27, 2010 at 3:47 PM, Varun Khanduja 
> wrote:
>
> > Thanks a lot Mr King.
>
> LOL, I like that :-P
>
> > I was in Chicago last week for design 4 mobile conference, is there by any
> > chance you were one of the attendee's?
>
> Nope - was not even aware. I should probably keep with this kind of stuff
> ...
>
> --- 
> --
> 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: Android multiple heading list view

2010-09-27 Thread TreKing
On Mon, Sep 27, 2010 at 3:47 PM, Varun Khanduja wrote:

> Thanks a lot Mr King.
>

LOL, I like that :-P


> I was in Chicago last week for design 4 mobile conference, is there by any
> chance you were one of the attendee's?
>

Nope - was not even aware. I should probably keep with this kind of stuff
...

-
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: Android multiple heading list view

2010-09-27 Thread Varun Khanduja
Thanks a lot Mr King. I was in Chicago last week for design 4 mobile
conference, is there by any chance you were one of the attendee's?

On Sep 27, 1:32 pm, TreKing  wrote:
> On Mon, Sep 27, 2010 at 3:25 PM, Varun Khanduja 
> wrote:
>
> > Yes the contents change in the sense the icons are replaced by check boxes.
>
> You could accomplish this by either tracking the current state in the
> adapter and having it return the correct view, or swapping out the adapters
> completely, depending on how different your multiple states are from a UI
> perspective.
>
> > Is there some resource you can suggest me which I can append to my existing
> > code?
>
> Not really, but I would look at the documentation and samples for
> customizing a list view adapter and having it return the appropriate view.
>
> Post back with more specific questions if you get stuck.
>
> --- 
> --
> 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: Android multiple heading list view

2010-09-27 Thread TreKing
On Mon, Sep 27, 2010 at 3:25 PM, Varun Khanduja wrote:

> Yes the contents change in the sense the icons are replaced by check boxes.
>

You could accomplish this by either tracking the current state in the
adapter and having it return the correct view, or swapping out the adapters
completely, depending on how different your multiple states are from a UI
perspective.


> Is there some resource you can suggest me which I can append to my existing
> code?
>

Not really, but I would look at the documentation and samples for
customizing a list view adapter and having it return the appropriate view.

Post back with more specific questions if you get stuck.

-
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: Android multiple heading list view

2010-09-27 Thread Varun Khanduja
Yes the contents change in the sense the icons are replaced by check
boxes. Is there some resource you can suggest me which I can append to
my existing code? I had been trying to use certain list view adapters
but was not succesful. If you have some online resource which may be a
good starting point I would appreciate the link. Searching through
google with what I want has been a pain considering I am not very sure
of the keywords. Thanks

On Sep 27, 1:12 pm, TreKing  wrote:
> On Mon, Sep 27, 2010 at 3:03 PM, Varun Khanduja 
> wrote:
>
> > Multiple headings in my work are possibly buttons which help a list to be
> > sorted.
>
> OK. You probably just need a custom view that has your 4 buttons and set
> that as the header.
>
> > So 4 buttons on top of the list view and each button having seperate view(
> > 4 views) of the same list.
>
> Are you saying on clicking the buttons the list view contents will change?
>
> --- 
> --
> 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: Android multiple heading list view

2010-09-27 Thread TreKing
On Mon, Sep 27, 2010 at 3:03 PM, Varun Khanduja wrote:

> Multiple headings in my work are possibly buttons which help a list to be
> sorted.
>

OK. You probably just need a custom view that has your 4 buttons and set
that as the header.


> So 4 buttons on top of the list view and each button having seperate view(
> 4 views) of the same list.
>

Are you saying on clicking the buttons the list view contents will change?

-
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: Android multiple heading list view

2010-09-27 Thread Varun Khanduja
Multiple headings in my work are possibly buttons which help a list to
be sorted. I am not allowed to use a tab view. So 4 buttons on top of
the list view and each button having seperate view( 4 views) of the
same list.

On Sep 27, 12:58 pm, TreKing  wrote:
> On Mon, Sep 27, 2010 at 2:43 PM, Varun Khanduja 
> wrote:
>
> > I am trying to get multiple heading in the same list view.
>
> First - what do you mean my "multiple headings"?
>
> --- 
> --
> 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