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<String> list=Arrays.asList(AndroidPhones);
setListAdapter(new
ArrayAdapter<String>(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<String> list=Arrays.asList(AndroidPhones);
setListAdapter(new
ArrayAdapter<String>(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 <[email protected]> wrote:
> On Mon, Sep 27, 2010 at 3:47 PM, Varun Khanduja
> <[email protected]>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 <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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en