Hi,
I am trying to get multiple heading in the same list view. These
headings are clickable to give a different view of the same list to
the user. Firstly I was sucesfull in getting one heading which was
clickable on top but i am not able to get multiple headings. Any idea
how I can set it right.
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);
Button btn1=new Button(this);
btn.setText("Randomize!");
btn1.setText("Hello");
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);
}
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 ",
};
}
--
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