我使用的是一個listview。在將主要列表項添加到列表視圖之前,我使用addheaderview(v)向列表視圖添加了一個標題。標題有兩個按鈕。如何將addclick事件添加到listview中的按鈕添加addheaderView?
在logcat..it在 btnhome.setOnClickListener(新View.OnClickListener(){
給人的問題,它強制關閉。 plz幫助我在哪裏,在下面的代碼錯誤。
等待您的回覆 thanx提前
enter code here
公共無效的onCreate(捆綁savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.games_by_category);
Global globalclass=((Global)getApplicationContext());
globalclass.setpageno(0);
lstview =(ListView)findViewById(android.R.id.list);
LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(R.layout.header, null);
//View v = getLayoutInflater().inflate(R.layout.header, null);
v.setMinimumHeight(10);
lstview.addHeaderView(v);
btnhome=(Button)findViewById(R.id.btnHome);
btnhome.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
btnhome.setTextColor(Color.BLACK);
Global globalclass=((Global)getApplicationContext());
Intent inte=new Intent(GamesByCatActivity.this,HotGamesActivity.class);
startActivity(inte);
}
});
答覆HII THX ..我增加了一個addheaderview到我的清單。 ñ頭部有按鈕。我想在這些按鈕上點擊事件。我怎樣才能做到這一點。 – ZooZoo 2012-03-02 07:59:28