来源:
package dreamcode.tutorials.part_two;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.EditText;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
public class dic_tut2 extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button)this.findViewById(R.id.btn_confirm);
b.setOnClickListener(this);
}
@Override
public void onClick(View v) {
TextView tv = (TextView)this.findViewById(R.id.tv_welcome);
EditText et = (EditText)this.findViewById(R.id.txt_name);
String text = "Hello, " + et.getText().toString() + ".
";
text += "Welcome to android development. :)";
tv.setText(text);
}
}
简讯信息:
Android [Android Application]
DalvikVM[localhost:8610]
Thread [<3> main] (Suspended (exception RuntimeException))
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2417
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2512
ActivityThread.access$2200(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 119
ActivityThread$H.handleMessage(Message) line: 1863
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4363
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 860
ZygoteInit.main(String[]) line: 618
NativeStart.main(String[]) line: not available [native method]
Thread [<13> Binder Thread #2] (Running)
Thread [<11> Binder Thread #1] (Running)
question : As I Understand this is something wrong with my functions or incompobility for versions of Android. Source codes are taked from version 1.5. And used for Version 2.1. So any way can any one explain or show Right direction, where I can Find correct function creating to the Buttons. Or please fix this code to start work.
My goal : create function that does something. Version compobility 2.1.
编辑说:
[2011-05-14 12:10:33 - dic_tut2] ------------------------------
[2011-05-14 12:10:33 - dic_tut2] Android Launch!
[2011-05-14 12:10:33 - dic_tut2] adb is running normally.
[2011-05-14 12:10:33 - dic_tut2] Performing dreamcode.tutorials.part_two.dic_tut2 activity launch
[2011-05-14 12:10:33 - dic_tut2] Automatic Target Mode: using existing emulator emulator-5554 running compatible AVD my_avd
[2011-05-14 12:10:33 - dic_tut2] Uploading dic_tut2.apk onto device emulator-5554
[2011-05-14 12:10:33 - dic_tut2] Installing dic_tut2.apk...
[2011-05-14 12:10:39 - dic_tut2] Success!
[2011-05-14 12:10:40 - dic_tut2] Starting activity dreamcode.tutorials.part_two.dic_tut2 on device emulator-5554
[2011-05-14 12:10:45 - dic_tut2] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=dreamcode.tutorials.part_two/.dic_tut2 }
有用:
我 throw倒了两点。 首先,当与ec子一起工作时,它就在ec和 s之间工作。 如果你修改了Xml文档,就可以节省费用,并试图建造,通常会给你造成 par误。 如果你从问题窗口中删除错误,那就修改了java案卷并予以节省。 现在应该汇编。 当我说你可以添加一条线,然后删除一条线。 如果在Xml案卷之后将java案存档,则应汇编。 (第6号法典)
我这样做了,错误消失了=]。