English 中文(简体)
帮助启动方案
原标题:Android Help to beginning programmer
  • 时间:2011-05-14 08:33:11
  •  标签:
  • android

来源:

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号法典)

我这样做了,错误消失了=]。

问题回答

首先,你为什么开始对纽特人点击问题发表意见? 你们必须用你的宝贵方法这样做,并在浮标上改变其案文价值。 不管怎么说,很难说什么是基于你的欺骗。

在你的活动中采用浮标接口。 然后用你惯用的方法书写浮 but子。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签