如何写在Android的一个段落 [英] How to write a paragraph in android
本文介绍了如何写在Android的一个段落的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图插入android应用一个段落。
我的code是这样的:
I am trying to insert a paragraph in android application. My code is like this:
MainActivity:
MainActivity:
public class MainActivity extends ActionBarActivity {
TextView t;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView t = (TextView) findViewById(R.id.text);
t.setText("This is the first line\nThis is the second line\nThird line...");
}
activity_main.xml中
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.helloworld_5.MainActivity$PlaceholderFragment" >
<TextView
android:text="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
不幸的是,应用程序是不是working.What别的我需要包括哪些内容?
Unfortunately The app is not working.What else I need to include?
请帮助..
推荐答案
更改您的TextView来标识的文字属性,在xml文件...
Change the text attribute of your TextView to id in your xml file...
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
这篇关于如何写在Android的一个段落的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文