2014-04-20 26 views
0

我对Android应用程序开发非常新颖,所以会问一个非常基本的问题。 setOnClickListener()的工作是什么?使用setOnClickListener()

在下面的代码:

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.fragment_sudoku); 

    View continueButton = findViewById(R.id.continue_button); 
    continueButton.setOnClickListener(this); 
    View newButton = findViewById(R.id.new_button); 
    newButton.setOnClickListener(this); 
    View aboutButton = findViewById(R.id.about_button); 
    aboutButton.setOnClickListener(this); 
    View exitButton = findViewById(R.id.exit_button); 
    exitButton.setOnClickListener(this); 
}` 

什么是aboutButton.setOnClickListener(this)功能?

回答

3

setOnClickListener()表示在点击视图时应使用onClick()调用提供的OnClickListener

在这种情况下,OnClickListenerActivity本身。 OnClickListener是这个Activity实现的接口。