2017-07-25 120 views

回答

0

我告訴你如何做到這一點。

第一:有兩種方式做到這一點

設計(.XML) 我會分開這些:(全名)和(年)

<TextView 
    android:id="@+id/notice_event" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:maxLines="2" 
    android:text="Gustavo Tufiño Fernández \n 21 Years Old"/> 

很好的解決方案,對嗎?,但如果你想做這個動態,你會做什麼?

類(活動/片段/適配器)動態形式

@Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 

      // put values I need in String variables 
      String title = listNoticiasEventosFinal.get(0).getTitle(); 
      String detail = listNoticiasEventosFinal.get(0).getDescription(); 

      //Concat Strings with linespace and put int TextView 
      String final_text = title + System.getProperty ("line.separator") + detail; 
      TextView textView = (TextView) findViewById(R.id.notice_event); 
      textView.setText(final_text); 
    } 

我希望我幫助你,在這方面關於(Y)

+0

感謝您的答案:) –

相關問題