2011-08-13 8 views
1

뭐죠? 코딩에 관해서 몇 가지 기본 사항을 배우려고 노력 중이며 helloworld -app와 관련하여 질문이 있습니다.Android 일식 개발 TextView Assist

기본형 Hello world! -app는 "Hello world or what .. want it it"텍스트를 보여주기 때문에 달성하기가 어렵지 않아야합니다. 어쨌든, 2 행 또는 3 행으로 나누어 표시하는 방법은 무엇입니까? 예를 들어

:

Hello, world 
[Second line] 
[Third line] 

난 그냥 사람이 올바른 방향으로 날 지점 수 있다면, 그래서 나는 그것을 대단히 감사하겠습니다,이 작업을 수행하는 방법을 알아낼 수 없습니다!

+0

텍스트 뷰 자동으로 처리하는 텍스트 배치는 '새로운 라인'을 의미 특수 문자입니다. 텍스트가 텍스트 뷰 너비를 초과하면 다음 줄로 푸시됩니다. – Ronnie

답변

4

\n 그 방법으로가는 길은 아닌가요?

다른 방법은 TextViewLinearLayout에 넣고 한 문장으로 각각 채우는 것입니다. 당신은 다음 코드를 (사용하여 프로그래밍을 할 수

Edit (response to OP):

당신의 onCreate() -

//Grab the TextView that's been deflated from the XML-file 
TextView theTextView = (TextView) findViewById(R.id.{The id of your TextView}); 

//Set the text to a three-rowed message 
theTextView.setText("Hello world!\nMy name is ninetwozero.\nLorem ipsum wouldn't fit here"); 

xml -layout에 설정되어있어 사용자의 TextView의 실제 ID로 {The id of your TextView}을 변경하는 것을 잊지 마십시오 파일

+0

잘 전에 나는 새로운 것을 말했다, 당신은 자세히 설명해 주겠니? 만약 네가 ..? – Zodiw

+0

위 내 게시물을 업데이트했습니다. – ninetwozero

3

원하는 것이 있습니까?

<LinearLayout android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="vertical"> 
    <TextView android:text="First Line" android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
    <TextView android:text="Second Line" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
    <TextView android:text="Third Line" android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
</LinearLayout> 
0
TextView yourText = (TextView)findViewById(TheId); 
yourText.setText("Hello \n World \n Welcome to my app ?"); 

다음과 같이 표시됩니다. 첫줄 : 안녕하세요. 두 번째 줄 : 세계. 세 번째 줄 : 내 앱에 환영?

원하는 것은 무엇입니까?

+0

오, 그래, 내 잘못이야. – Tsunaze

+0

Tsunaze에 감사드립니다. tiny.setText ("Hello, Users \ n snd line"); – Zodiw

1

'\ n'을 은 그래서 "안녕하세요 세계 \의 nLine 2 \ nLine 3"

+0

고마워요 :) – Zodiw