我已将 Linearlayout 设置为可点击。当我运行程序并单击屏幕时,它显示错误并且无法进入活动 2。
有经验的人可以处理吗?
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// code here
LinearLayout linearlayout = (LinearLayout) findViewById(R.id.LinearLayout1);
linearlayout.setOnClickListener(new LinearLayout.OnClickListener(){
public void onClick (View v) {
Intent intent = new Intent(v.getContext(), Activity2.class);
startActivityForResult(intent, 0);
}
});
}
}