【问题标题】:How to show Toast when I click on the LayoutParams TextView当我单击 LayoutParams TextView 时如何显示 Toast
【发布时间】:2018-10-26 20:07:15
【问题描述】:

这是单个TextView,其中包含来自数据库的值。所以我希望当我点击TextView, 时,它应该在我点击的位置显示Toast 相同的文本。

The image showing the text view

【问题讨论】:

    标签: java textview android-layoutparams android


    【解决方案1】:

    这是代码 TextView 显示来自 firebase 的数据。

    textView = new TextView(Chat.this);                                                                                                       
    textView.setText(message);                                                                                                                  
    final Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/fnt1.otf");                                                  
    
      textView.setTypeface(typeface);                                                                                                             
      LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      lp.setMargins(0, 0, 0, 20);
      textView.setLayoutParams(lp);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多