Button is not clickable or focusable

后端 未结 1 1137
孤街浪徒
孤街浪徒 2021-01-16 07:09

I have created a button in my screen\'s XML like this:

   
相关标签:
1条回答
  • 2021-01-16 07:53

    you should add a listener to listen the clic event on your button like this :

    Button btn = (Button)findViewById(R.id.btn1);
    
    //add the listener to your Button 
    btn.addOnClickListener( new OnClickListener(){
        @Override
        public void onClick(View v ){
    
            Toast.makeText(YourActivity.this, "the button is clicked ...", 3000).show();
    
        }
    });
    
    0 讨论(0)
提交回复
热议问题