Java – Android: use anonymous classes to programmatically create click listeners
                                        
                    •
                    Android                                    
                I see some examples of making textview clickable by setting onclick = "clickhandler" and clickable = "true". Is there any way to use anonymous classes instead of hard coding "clickhandler" methods in activities
resolvent:
You go
TextView tv = (TextView)findViewById(R.id.textview);
tv.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        // do whatever stuff you wanna do here
    }
});
                
                            The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
                        
                                            
                        THE END
                    
                    
                    
                                                        二维码
                        
                        
                                                
                        