【发布时间】:2012-03-02 18:14:25
【问题描述】:
我正在使用列表视图。在将主列表项添加到列表视图之前,我使用 addheaderview(v) 将标题添加到列表视图。标题有两个按钮。
在 logcat..它给出了问题 btnhome.setOnClickListener(new View.OnClickListener() {
它会强制关闭。 请帮我看看下面的代码哪里出错了。
等待您的回复 提前谢谢
enter code here
public void onCreate(Bundle 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);
}
});
【问题讨论】:
标签: android