我使用的是一个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