精华内容
下载资源
问答
  • In contrast, we do want to call the area of height 2 on the right a summit, since if we would want to walk to the summit of height 3, we first have to descend to a point with height 0. After the ...
  • 怎么用cron?

    2013-08-14 23:07:20
    ...Would not it be better to use <a href="http://pear.php.net/package/System_Daemon/download" rel="nofollow">System_Daemon</a> to reload the php script? I have Debian System. </div>
  • Your task is to write a software that would help evaluating this risk. Your program is given a description of the network, and it should determine the maximum number of non-connected parts from that ...
  • Farmer John's cows would like to jump over the moon, just like the cows in their favorite nursery rhyme. Unfortunately, cows can not jump. The local witch doctor has mixed up P (1 ,000) potions to ...
  • It’s guaranteed that all (xi, yi) would be distinct. Output For each test case, output a single line “Case #x: y”, where x is the case number (starting from 1) and y is the number of pairs....
  • Your kind help would be highly appreciated by him. Since the result may be very large and rather difficult to compute, you only need to tell Harry the last four digits of the result. Input ...
  • If there is more than one solution then the combination is the one that is lexicographically greatest, i.e., the one that would appear last in a dictionary." v - w^2 + x^3 - y^4 + z^5 = target ...
  • For example, (1, 2, 3, 4, 5),if the Queen arranged Knights 3 and 4 for a match and Knight 3 lost, then Knights 2 and 4 would be adjacent to each other (the result of each Knight competing with others...
  • You have gone on a hiking trip, but now you are getting tired and would like to return home. As a precaution, you always take your mobile phone with you, so you can call for help in case of an ...
  • A naive method of enumerating all possible mapping functions would require generating all possible n! different mappings. What resulted is a very time-consuming O(n!) time algorithm just to test two ...
  •  For some reason, if L is equal to or larger than 1000000, ivankevin would think the switch sequence you found is so ugly that it is ungelieveble and unacceptable. Otherwise, if L , he will accept ...
  • And there would be some magnetic robs with length √2 (long rob) connecting to diagonal balls to make it rigid. Adjacent cubes can share balls and robs. Before long he realize that there is no need ...
  • For example, if he has visited a spot whose satisfaction value is 50, he would only visit spot whose satisfaction value is 51 or more then. The paths between the spots are bi-directional, of course. ...
  • Consider what would happen if Lawrence attacked this rail line right in the middle: The Strategic Value of the remaining railroad is 4*5 + 1*2 = 22. But, suppose Lawrence attacks between the 4...
  • Technical note: To ease the problem of rounding errors, there will be no edge cases where an infinitesimal perturbation of the input values would cause a different answer. Input The first line ...
  • Destroy-ing the lights with his shurikens would be too loud, so he needs to turn them off the old-fashioned way, using light switches. Luckily, there is a switch box nearby with a light switch Si for...
  • API 中Button的OnClickListener的一个小例子。   D:\data\android-sdk-windows\docs\reference\android\widget\...   A typical use of a push-button in an activity would be the following:  public class

    1)OnClickListener是interface

    D:\data\android-sdk-windows\docs\reference\android\view\View.OnClickListener.html

    public static interface
    View.OnClickListener


    Public Methods 
     public abstract void  onClick (View v)

     Called when a view has been clicked.

     

    2)API 中Button的OnClickListener的一个小例子。

    D:\data\android-sdk-windows\docs\reference\android\widget\Button.html

    A typical use of a push-button in an activity would be the following: 

     public class MyActivity extends Activity {
         protected void onCreate(Bundle icicle) {
             super.onCreate(icicle);
    
             setContentView(R.layout.content_layout_id);
    
             final Button button = (Button) findViewById(R.id.button_id);
             button.setOnClickListener(new View.OnClickListener() {
                 public void onClick(View v) {
                     // Perform action on click
                 }
             });
         }
     }
    3)
     
    下面的是转帖:http://blog.csdn.net/dickren123/article/details/7216975     

    新手Android开发之二:onclicklistener到底怎么用?

    分类: android 开发 20969人阅读 评论(14) 收藏 举报

    相信很多像我一样的新手学习ANDROID开发会遇到这个问题,通过这几天的归类和总结,将我的理解写在下面,欢迎大家一起前来讨论:

    以按钮BUTTON的监听事件为例,以下的监听实现都是等价的:

    1.使用接口继承按钮监听方法:

    使用implements,实现interface的onClick方法

     

    1. package dickren123.hui.say_hello_to_world;  
    2.   
    3. import android.app.Activity;  
    4. import android.os.Bundle;  
    5. import android.view.View;  
    6. import android.widget.Button;  
    7. import android.widget.TextView;  
    8. /* 这里接口继承的方法是隶属于按钮BUTTON的,因此前面导入的头文件只需有BUTTON即可*/  
    9. public class Hello_to_worldActivity extends Activity implements Button.OnClickListener{  
    10. /** Called when the activity is first created. */  
    11. private Button btn_say_hello;  
    12. private TextView hello_world;  
    13. @Override  
    14. public void onCreate(Bundle savedInstanceState) {  
    15. super.onCreate(savedInstanceState);  
    16. setContentView(R.layout.main);  
    17. btn_say_hello = (Button)findViewById(R.id.bnt_SAY_HELLO_TO_WORLD);  
    18. hello_world = (TextView)findViewById(R.id.textView1);  
    19. btn_say_hello.setOnClickListener(this) ;//由于该类继承了BUTTON的监听,  
    20. //因此设置监听的参数只需传本类的对象即可  
    21. public void onClick(View v) {  
    22. // TODO Auto-generated method stub  
    23. hello_world.setText("dickren123!");//抽象接口的内部方法的实现  
    24. }  
    25. }  
    package dickren123.hui.say_hello_to_world;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.TextView;
    /* 这里接口继承的方法是隶属于按钮BUTTON的,因此前面导入的头文件只需有BUTTON即可*/
    public class Hello_to_worldActivity extends Activity implements Button.OnClickListener{
    /** Called when the activity is first created. */
    private Button btn_say_hello;
    private TextView hello_world;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    btn_say_hello = (Button)findViewById(R.id.bnt_SAY_HELLO_TO_WORLD);
    hello_world = (TextView)findViewById(R.id.textView1);
    btn_say_hello.setOnClickListener(this) ;//由于该类继承了BUTTON的监听,
    } //因此设置监听的参数只需传本类的对象即可
    public void onClick(View v) {
    // TODO Auto-generated method stub
    hello_world.setText("dickren123!");//抽象接口的内部方法的实现
    }
    }


    使用implements,实现interface的onClick方法(和上例的区别是OnClickListener是View类的interface ?)

    2.使用接口继承view类的监听方法

    1. package dickren123.hui.say_hello_to_world;  
    2.   
    3.   
    4. import android.app.Activity;  
    5. import android.os.Bundle;  
    6. import android.view.View;  
    7. import android.view.View.OnClickListener;/* 导入的头文件需要有view类监听*/  
    8. import android.widget.Button;  
    9. import android.widget.TextView;  
    10.   
    11.   
    12. public class Hello_to_worldActivity extends Activity implements OnClickListener{  
    13.     /** Called when the activity is first created. */  
    14. private Button btn_say_hello;  
    15. private TextView hello_world;  
    16.     @Override  
    17.     public void onCreate(Bundle savedInstanceState) {  
    18.         super.onCreate(savedInstanceState);  
    19.         setContentView(R.layout.main);  
    20.         btn_say_hello = (Button)findViewById(R.id.bnt_SAY_HELLO_TO_WORLD);  
    21.         hello_world = (TextView)findViewById(R.id.textView1);  
    22.         btn_say_hello.setOnClickListener(this) ;//由于该类继承了view的监听,  
    23.     } //因此设置监听的参数只需传本类的对象即可  
    24. public void onClick(View v) {  
    25. // TODO Auto-generated method stub  
    26. hello_world.setText("dickren123!");//抽象接口的内部方法的实现  
    27. }  
    28. }  
    package dickren123.hui.say_hello_to_world;
    
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;/* 导入的头文件需要有view类监听*/
    import android.widget.Button;
    import android.widget.TextView;
    
    
    public class Hello_to_worldActivity extends Activity implements OnClickListener{
        /** Called when the activity is first created. */
    private Button btn_say_hello;
    private TextView hello_world;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            btn_say_hello = (Button)findViewById(R.id.bnt_SAY_HELLO_TO_WORLD);
            hello_world = (TextView)findViewById(R.id.textView1);
            btn_say_hello.setOnClickListener(this) ;//由于该类继承了view的监听,
        } //因此设置监听的参数只需传本类的对象即可
    public void onClick(View v) {
    // TODO Auto-generated method stub
    hello_world.setText("dickren123!");//抽象接口的内部方法的实现
    }
    }


    3.不用接口,在类内部直接实现监听

    不使用implements, 直接new(java的特殊技术)

     

    1. package dickren123.hui.say_hello_to_world;  
    2.   
    3. import android.app.Activity;  
    4. import android.os.Bundle;  
    5. import android.view.View;  
    6. import android.widget.Button;  
    7. import android.widget.TextView;  
    8.   
    9. public class Hello_to_worldActivity extends Activity {  
    10. /** Called when the activity is first created. */  
    11. private Button btn_say_hello;  
    12. private TextView hello_world;  
    13. @Override  
    14. public void onCreate(Bundle savedInstanceState) {  
    15. super.onCreate(savedInstanceState);  
    16. setContentView(R.layout.main);  
    17. btn_say_hello = (Button)findViewById(R.id.bnt_SAY_HELLO_TO_WORLD);  
    18. hello_world = (TextView)findViewById(R.id.textView1);  
    19. btn_say_hello.setOnClickListener(new Button.OnClickListener(){  
    20. public void onClick(View v) { //使用匿名的Button实例  
    21. // TODO Auto-generated method stub  
    22. hello_world.setText("dickren123!");//抽象接口的内部方法的实现  
    23. }  
    24. }) ;  
    25. }   
    26. }  
    package dickren123.hui.say_hello_to_world;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.TextView;
    
    public class Hello_to_worldActivity extends Activity {
    /** Called when the activity is first created. */
    private Button btn_say_hello;
    private TextView hello_world;
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    btn_say_hello = (Button)findViewById(R.id.bnt_SAY_HELLO_TO_WORLD);
    hello_world = (TextView)findViewById(R.id.textView1);
    btn_say_hello.setOnClickListener(new Button.OnClickListener(){
    public void onClick(View v) { //使用匿名的Button实例
    // TODO Auto-generated method stub
    hello_world.setText("dickren123!");//抽象接口的内部方法的实现
    }
    }) ;
    } 
    }


    如果不使用匿名实例,也可以定义一个具体的实例,如下:

    使用内部类

    1. package dickren123.hui.say_hello_to_world;  
    2.   
    3. import android.app.Activity;  
    4. import android.os.Bundle;  
    5. import android.view.View;  
    6. import android.widget.Button;  
    7.   
    8. public class Hello_to_worldActivity extends Activity {  
    9. /** Called when the activity is first created. */  
    10. private Button btn_say_hello;  
    11.   
    12. @Override  
    13. public void onCreate(Bundle savedInstanceState) {  
    14. super.onCreate(savedInstanceState);  
    15. setContentView(R.layout.main);  
    16. btn_say_hello = (Button)findViewById(R.id.bnt_SAY_HELLO_TO_WORLD);  
    17. btn_listener bl = new btn_listener();  
    18. btn_say_hello.setOnClickListener(bl); //bl是类btn_listener的实例,而btn_listener为监听方法的接口  
    19. //因此设置监听的参数只需传本类的对象即可  
    20. }  
    21. class btn_listener implements Button.OnClickListener  
    22. {  
    23. public void onClick(View v) {  
    24. // TODO Auto-generated method stub  
    25.   
    26. }  
    27. }  
    package dickren123.hui.say_hello_to_world;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    
    public class Hello_to_worldActivity extends Activity {
    /** Called when the activity is first created. */
    private Button btn_say_hello;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    btn_say_hello = (Button)findViewById(R.id.bnt_SAY_HELLO_TO_WORLD);
    btn_listener bl = new btn_listener();
    btn_say_hello.setOnClickListener(bl); //bl是类btn_listener的实例,而btn_listener为监听方法的接口
    } //因此设置监听的参数只需传本类的对象即可
    }
    class btn_listener implements Button.OnClickListener
    {
    public void onClick(View v) {
    // TODO Auto-generated method stub
    
    }
    }

    展开全文
  • Your task is to write a program that simulates such a queue with people jumping in every now and then, assume that, if one in the queue has several friends asking for favors, he would arrange their ...
  • What would addition and equality mean? Given two strings x and y, we define x + y to be the concatenation of the two strings. We also define x = y to mean that x is an anagram of y. That is, the ...
  • <p>But what I would like to know is how can I echo all of the variables including line breaks into one line of code? <pre><code><?php function findworld($var) { return strpos($var, "world"); } ...
  • Destroy-ing the lights with his shurikens would be too loud, so he needs to turn them off the old-fashioned way, using light switches. Luckily, there is a switch box nearby with a light switch Si for...
  • Coco would like to pick out some chains any two of which do not share common vertices. Find out the maximum sum of the weight Coco can pick Input The input consists of several test cases. The...
  • 怎么用命令提示符打开浏览器Ever been doing some work at the command line when you realized… it would be a lot easier if I could just use the mouse for this task? One command later, you’ll have a ...
    怎么用命令提示符打开浏览器

    怎么用命令提示符打开浏览器

    Ever been doing some work at the command line when you realized… it would be a lot easier if I could just use the mouse for this task? One command later, you’ll have a window open to the same place that you’re at.

    当您意识到时,曾经在命令行上做过一些工作吗……如果我可以只使用鼠标来完成此任务,会容易得多吗? 一个命令之后,您将打开一个窗口,该窗口指向您所在的位置。

    This same tip works in more than one operating system, so we’ll detail how to do it in every way we know how.

    相同的技巧可以在多个操作系统上使用,因此我们将详细介绍如何以我们知道的所有方式进行操作。

    Open a File Browser in Windows

    在Windows中打开文件浏览器

    We’ve actually covered this before when we told you how to open an Explorer window from the command prompt’s current directory, but we’ll briefly review: Just type the follow command into your command prompt:

    在告诉您如何从命令提示符的当前目录打开资源管理器窗口之前,我们实际上已经进行了介绍,但是我们将简要回顾一下:只需在命令提示符下键入follow命令:

    explorer .

    探险家。

    image

    Note: You could actually just type “start .” instead.

    注意:您实际上可以只输入“开始”。 代替。

    And you’ll then see a file browsing window set to the same directory you were previous at. And yes, this screenshot is from Vista, but it works the same in every version of Windows.

    然后,您将看到一个文件浏览窗口,该窗口设置为先前的目录。 是的,此屏幕截图来自Vista,但在每个Windows版本中都可以使用。

    image

    If that wasn’t good enough, you should really read how you can navigate in the File Open/Save dialogs with just the keyboard—now that’s a Stupid Geek Trick!

    如果这还不够好,那么您应该真正阅读如何使用键盘在“文件打开/保存”对话框中导航,这真是个愚蠢的怪胎把戏!

    Open a File Browser in Linux

    在Linux中打开文件浏览器

    For this exercise, we’re going to assume that you’re using Gnome under a Linux flavor like Ubuntu, because that’s the most common. From your terminal window, just type in the following command:

    在本练习中,我们将假设您在Linux风格(如Ubuntu)下使用Gnome,因为这是最常见的。 在终端窗口中,只需输入以下命令:

    nautilus .

    鹦鹉螺。

    sshot-2010-04-26-20-15-10

    And the next thing you know, you’ll have a file browser window open at the current location. You’ll see some type of error message at the prompt, but you can pretty much ignore that.

    接下来,您将在当前位置打开一个文件浏览器窗口。 您将在提示符下看到某种类型的错误消息,但是您几乎可以忽略它。

    sshot-2010-04-26-20-16-33

    You can also use “gnome-open .” if you want.

    您还可以使用“ gnome-open”。 如果你想。

    Open Finder in Mac OS X

    在Mac OS X中打开Finder

    All the Mac computers in this office are running Linux, so we haven’t had a chance to verify, but you should be able to use the following command on OS X to open Finder in the current terminal location:

    该办公室中的所有Mac计算机都在运行Linux,因此我们没有机会进行验证,但是您应该能够在OS X上使用以下命令在当前终端位置打开Finder:

    open .

    打开。

    Open Dolphin on Linux KDE4

    在Linux KDE4上打开Dolphin

    dolphin .

    海豚

    Got any extra tips to help out your fellow readers? How do you do the same thing in KDE3? What about OS X? Leave your savvy advice in the comments, and maybe we’ll update the article. Or not. Either way, it’ll help somebody!

    还有其他提示可以帮助您的其他读者吗? 您如何在KDE3中做同样的事情? OS X呢? 在评论中留下您精明的建议,也许我们会更新本文。 或不。 无论哪种方式,它都会对某人有所帮助!

    翻译自: https://www.howtogeek.com/howto/15781/open-a-file-browser-from-your-current-command-promptterminal-directory/

    怎么用命令提示符打开浏览器

    展开全文
  • If a person took a long trip and finally got back to his own star, however, his chirality might be changed to the opposite state other than his original, which would cause fatal mental disorder, or ...
  • Based on the above maze, your program would output the minimum no-left-turns path length of 29. Hint Additional Constraints/Information: Right Head is capable of moving from the start position...
  • I want to write a query that when a user tries sending a file to another user, the share function should capture the title of the file and department of the user sending the file which would be saved ...
  • If JRY rides across from the i-th section to the j-th section, he would gain j−i+1 pleasure. Now JRY wants to know, if he tries all the ways whose length is s, what's the total pleasure he can get. ...
  • Technical note: To ease the problem of rounding errors, there will be no edge cases where an infinitesimal perturbation of the input values would cause a different answer. Input The first line ...
  • We would love to see how you use this awesome admin template. You can notify us about your site, app or service by tweeting to @colorlib. Once the list will grown long enough we will write a post ...

空空如也

空空如也

1 2 3 4 5 ... 7
收藏数 134
精华内容 53
关键字:

would怎么用