How to set the part of the text view is clickable

后端 未结 20 1474
无人共我
无人共我 2020-11-22 01:29

I have the text \"Android is a Software stack\". In this text i want to set the \"stack\" text is clickable. in the sense if you click on t

20条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-22 02:33

    To add a linked text in a text view, you can use the "footer_text" string resource example below and also edit your onCreate method for your activity, you can use the example below

    string.xml

    
    
         Name of My Application
    
        
            Terms of Service
            Contact
            Privacy Policy
        
    
    

    MainActivity.java

    ...
    
    @Override
    public void onCreate(Bundle savedInstance) {
        super.onCreate(savedInstance);
        setContentView(R.layout.activity_main);
    
        TextView textView = findViewById(R.id.textViewLink);
        textView.setMovementMethod(LinkMovermentMethod.getInstance());
    }
    
    ....
    

提交回复
热议问题