你鼠标移到上面去好好看看Intenti=newIntent();
i.setClass(MainActivity.this,Image2.class);
startActivity(i);
finish();
这种错误你以为有人知道吗?
对!
我知道!
startActivity
不是
starActivity!
OK!!!!!!!
额。。。你说的太对了!这么明显居然没发现。。谢谢了packagecom.example.ex07_widgetdemo;
importandroid.os.Bundle;
importandroid.app.Activity;
importandroid.content.Intent;
importandroid.view.Menu;
importandroid.view.View;
importandroid.widget.Button;
publicclassMainActivityextendsActivity{
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
find_and_modify_button();
}
@Override
publicbooleanonCreateOptionsMenu(Menumenu){
//Inflatethemenu;thisaddsitemstotheactionbarifitispresent.
getMenuInflater().inflate(R.menu.main,menu);
returntrue;
}
privatevoidfind_and_modify_button(){
Buttonbutton=(Button)findViewById(R.id.button);
button.setOnClickListener(button_listener);
Buttontext_view_button=(Button)findViewById(R.id.text_view_button);
text_view_button.setOnClickListener(text_view_button_listener);
}
privateButton.OnClickListenerbutton_listener=newButton.OnClickListener()
{
publicvoidonClick(Viewv){
setTitle("哎呦,button被点了一下");
}
};
privateButton.OnClickListenertext_view_button_listener=newButton.OnClickListener()
{
publicvoidonClick(Viewv){
Intentintent=newIntent();
intent.setClass(MainActivity.this,TextActivity.class);
//intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
};
};
@kscpackagecom.example.ex07_widgetdemo;
importandroid.os.Bundle;
importandroid.widget.TextView;
importandroid.app.Activity;
importandroid.content.Intent;
publicclassTextActivityextendsActivity{
@Override
publicvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
setTitle("ViewTextActivity");
setContentView(R.layout.text);
find_and_modify_text_view();
}
privatevoidfind_and_modify_text_view(){
//TODOAuto-generatedmethodstub
TextViewtext_view=(TextView)findViewById(R.id.text_view);
CharSequencetext_view_old=text_view.getText();
text_view.setText("修改前提:"+text_view_old+"\n修改为:TextView的值也是可以动态修改的。");
}
}
这是TextActivity.java
@ksc